Mercurial > pidgin
changeset 18343:27e54692b2b4
merge of 'd08e73765328352fb955bb0b4e908eb39bea7b5d'
and 'd1078f122bb98d1830a87bb96e549b5c3b2c75b8'
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Thu, 28 Jun 2007 18:35:38 +0000 |
parents | b4f5a2c0f00a (current diff) 65fedb03ac05 (diff) |
children | 310bad6dafe4 |
files | |
diffstat | 2 files changed, 49 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/gntprefs.c Thu Jun 28 14:53:47 2007 +0000 +++ b/finch/gntprefs.c Thu Jun 28 18:35:38 2007 +0000 @@ -32,7 +32,10 @@ #include <string.h> -static GList *freestrings; /* strings to be freed when the pref-window is closed */ +static struct { + GList *freestrings; /* strings to be freed when the pref-window is closed */ + gboolean showing; +} pref_request; void finch_prefs_init() { @@ -98,7 +101,7 @@ str = g_strdup_printf("%ld", purple_savedstatus_get_creation_time(iter->data)); list = g_list_append(list, (char*)purple_savedstatus_get_title(iter->data)); list = g_list_append(list, str); - freestrings = g_list_prepend(freestrings, str); + pref_request.freestrings = g_list_prepend(pref_request.freestrings, str); } return list; } @@ -190,22 +193,22 @@ {PURPLE_PREF_NONE, NULL, NULL, NULL}, }; -/* XXX: Translate after the freeze */ static Prefs idle[] = { - {PURPLE_PREF_STRING, "/purple/away/idle_reporting", "Report Idle time", get_idle_options}, - {PURPLE_PREF_BOOLEAN, "/purple/away/away_when_idle", "Change status when idle", NULL}, - {PURPLE_PREF_INT, "/purple/away/mins_before_away", "Minutes before changing status", NULL}, - {PURPLE_PREF_INT, "/purple/savedstatus/idleaway", "Change status to", get_status_titles}, + {PURPLE_PREF_STRING, "/purple/away/idle_reporting", N_("Report Idle time"), get_idle_options}, + {PURPLE_PREF_BOOLEAN, "/purple/away/away_when_idle", N_("Change status when idle"), NULL}, + {PURPLE_PREF_INT, "/purple/away/mins_before_away", N_("Minutes before changing status"), NULL}, + {PURPLE_PREF_INT, "/purple/savedstatus/idleaway", N_("Change status to"), get_status_titles}, {PURPLE_PREF_NONE, NULL, NULL, NULL}, }; static void free_strings() { - g_list_foreach(freestrings, (GFunc)g_free, NULL); - g_list_free(freestrings); - freestrings = NULL; + g_list_foreach(pref_request.freestrings, (GFunc)g_free, NULL); + g_list_free(pref_request.freestrings); + pref_request.freestrings = NULL; + pref_request.showing = FALSE; } static void @@ -236,6 +239,9 @@ { PurpleRequestFields *fields; + if (pref_request.showing) + return; + fields = purple_request_fields_new(); add_pref_group(fields, _("Buddy List"), blist); @@ -243,6 +249,7 @@ add_pref_group(fields, _("Logging"), logging); add_pref_group(fields, _("Idle"), idle); + pref_request.showing = TRUE; purple_request_fields(NULL, _("Preferences"), NULL, NULL, fields, _("Save"), G_CALLBACK(save_cb), _("Cancel"), free_strings, NULL, NULL, NULL,
--- a/finch/gntrequest.c Thu Jun 28 14:53:47 2007 +0000 +++ b/finch/gntrequest.c Thu Jun 28 18:35:38 2007 +0000 @@ -67,8 +67,32 @@ return window; } +/** + * If the window is closed by the wm (ie, without triggering any of + * the buttons, then do some default callback. + */ +static void +setup_default_callback(GntWidget *window, gpointer default_cb, gpointer data) +{ + g_signal_connect_swapped(G_OBJECT(window), "destroy", G_CALLBACK(default_cb), data); +} + +static void +action_performed(GntWidget *button, gpointer data) +{ + g_signal_handlers_disconnect_matched(data, G_SIGNAL_MATCH_FUNC, + 0, 0, NULL, setup_default_callback, NULL); +} + +/** + * window: this is the window + * userdata: the userdata to pass to the primary callbacks + * cb: the callback + * data: data for the callback + * (text, primary-callback) pairs, ended by a NULL + */ static GntWidget * -setup_button_box(gpointer userdata, gpointer cb, gpointer data, ...) +setup_button_box(GntWidget *win, gpointer userdata, gpointer cb, gpointer data, ...) { GntWidget *box, *button; va_list list; @@ -87,6 +111,7 @@ g_object_set_data(G_OBJECT(button), "activate-callback", callback); g_object_set_data(G_OBJECT(button), "activate-userdata", userdata); g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(cb), data); + g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(action_performed), win); } va_end(list); @@ -127,10 +152,11 @@ gnt_entry_set_masked(GNT_ENTRY(entry), TRUE); gnt_box_add_widget(GNT_BOX(window), entry); - box = setup_button_box(user_data, notify_input_cb, entry, + box = setup_button_box(window, user_data, notify_input_cb, entry, ok_text, ok_cb, cancel_text, cancel_cb, NULL); gnt_box_add_widget(GNT_BOX(window), box); + setup_default_callback(window, cancel_cb, user_data); gnt_widget_show(window); return window; @@ -189,10 +215,11 @@ } gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(default_value + 1)); - box = setup_button_box(user_data, request_choice_cb, combo, + box = setup_button_box(window, user_data, request_choice_cb, combo, ok_text, ok_cb, cancel_text, cancel_cb, NULL); gnt_box_add_widget(GNT_BOX(window), box); + setup_default_callback(window, cancel_cb, user_data); gnt_widget_show(window); return window; @@ -538,10 +565,11 @@ } gnt_box_add_widget(GNT_BOX(window), box); - box = setup_button_box(userdata, request_fields_cb, allfields, + box = setup_button_box(window, userdata, request_fields_cb, allfields, ok, ok_cb, cancel, cancel_cb, NULL); gnt_box_add_widget(GNT_BOX(window), box); + setup_default_callback(window, cancel_cb, userdata); gnt_widget_show(window); g_object_set_data(G_OBJECT(window), "fields", allfields);