Mercurial > pidgin
comparison src/dialogs.c @ 1387:595a844dbe0b
[gaim-migrate @ 1397]
I'm bored.
committer: Tailor Script <tailor@pidgin.im>
| author | Rob Flynn <gaim@robflynn.com> |
|---|---|
| date | Fri, 05 Jan 2001 09:07:49 +0000 |
| parents | 0b4278a90323 |
| children | 7dc0a8bb4dcb |
comparison
equal
deleted
inserted
replaced
| 1386:f8f9c68960ea | 1387:595a844dbe0b |
|---|---|
| 3063 | 3063 |
| 3064 if (!ca->mess) | 3064 if (!ca->mess) |
| 3065 am = g_new0(struct away_message, 1); | 3065 am = g_new0(struct away_message, 1); |
| 3066 else | 3066 else |
| 3067 am = ca->mess; | 3067 am = ca->mess; |
| 3068 | |
| 3068 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | 3069 g_snprintf(am->name, sizeof(am->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); |
| 3069 text_len = gtk_text_get_length(GTK_TEXT(ca->text)); | 3070 text_len = gtk_text_get_length(GTK_TEXT(ca->text)); |
| 3070 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); | 3071 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); |
| 3071 | 3072 |
| 3072 g_snprintf(am->message, sizeof(am->message), "%s", away_message); | 3073 g_snprintf(am->message, sizeof(am->message), "%s", away_message); |
| 3082 gtk_list_select_item(GTK_LIST(prefs_away_list), g_slist_index(away_messages, am)); | 3083 gtk_list_select_item(GTK_LIST(prefs_away_list), g_slist_index(away_messages, am)); |
| 3083 | 3084 |
| 3084 return am; | 3085 return am; |
| 3085 } | 3086 } |
| 3086 | 3087 |
| 3088 int check_away_mess(struct create_away *ca, int type) | |
| 3089 { | |
| 3090 if ((strlen(gtk_entry_get_text(GTK_ENTRY(ca->entry))) == 0) && (type == 1)) | |
| 3091 { | |
| 3092 /* We shouldn't allow a blank title */ | |
| 3093 do_error_dialog(_("You cannot create an away message with a blank title"), _("Gaim - Error")); | |
| 3094 return 0; | |
| 3095 } | |
| 3096 | |
| 3097 if ((gtk_text_get_length(GTK_TEXT(ca->text)) == 0) && (type <= 1)) | |
| 3098 { | |
| 3099 /* We shouldn't allow a blank message */ | |
| 3100 do_error_dialog(_("You cannot create an empty away message"), _("Gaim - Error")); | |
| 3101 return 0; | |
| 3102 } | |
| 3103 | |
| 3104 return 1; | |
| 3105 } | |
| 3106 | |
| 3087 void save_away_mess(GtkWidget *widget, struct create_away *ca) | 3107 void save_away_mess(GtkWidget *widget, struct create_away *ca) |
| 3088 { | 3108 { |
| 3109 if (!check_away_mess(ca, 1)) | |
| 3110 return; | |
| 3111 | |
| 3089 save_away_message(ca); | 3112 save_away_message(ca); |
| 3090 destroy_dialog(NULL, ca->window); | 3113 destroy_dialog(NULL, ca->window); |
| 3091 g_free(ca); | 3114 g_free(ca); |
| 3092 } | 3115 } |
| 3093 | 3116 |
| 3094 void use_away_mess(GtkWidget *widget, struct create_away *ca) | 3117 void use_away_mess(GtkWidget *widget, struct create_away *ca) |
| 3095 { | 3118 { |
| 3096 static struct away_message am; | 3119 static struct away_message am; |
| 3097 guint text_len; | 3120 guint text_len; |
| 3098 gchar *away_message; | 3121 gchar *away_message; |
| 3122 | |
| 3123 if (!check_away_mess(ca, 0)) | |
| 3124 return; | |
| 3099 | 3125 |
| 3100 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | 3126 g_snprintf(am.name, sizeof(am.name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); |
| 3101 text_len = gtk_text_get_length(GTK_TEXT(ca->text)); | 3127 text_len = gtk_text_get_length(GTK_TEXT(ca->text)); |
| 3102 if (text_len < 0) return; | 3128 if (text_len < 0) return; |
| 3103 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); | 3129 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); |
| 3111 g_free(ca); | 3137 g_free(ca); |
| 3112 } | 3138 } |
| 3113 | 3139 |
| 3114 void su_away_mess(GtkWidget *widget, struct create_away *ca) | 3140 void su_away_mess(GtkWidget *widget, struct create_away *ca) |
| 3115 { | 3141 { |
| 3142 if (!check_away_mess(ca, 1)) | |
| 3143 return; | |
| 3116 do_away_message(NULL, save_away_message(ca)); | 3144 do_away_message(NULL, save_away_message(ca)); |
| 3117 destroy_dialog(NULL, ca->window); | 3145 destroy_dialog(NULL, ca->window); |
| 3118 g_free(ca); | 3146 g_free(ca); |
| 3119 } | 3147 } |
| 3120 | 3148 |
