/pidgin/main: f85e2e6fb6ed: Request API bugfixing

Tomasz Wasilczyk twasilczyk at pidgin.im
Fri Sep 13 05:11:37 EDT 2013


Changeset: f85e2e6fb6eda523ce17c4ac1951eed9770388d2
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2013-09-13 11:11 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/f85e2e6fb6ed

Description:

Request API bugfixing

diffstat:

 pidgin/gtkrequest.c |  45 +++++++++++++++++++++++++++++----------------
 1 files changed, 29 insertions(+), 16 deletions(-)

diffs (105 lines):

diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c
--- a/pidgin/gtkrequest.c
+++ b/pidgin/gtkrequest.c
@@ -1061,9 +1061,10 @@ create_choice_field(PurpleRequestField *
 	GList *l;
 	gpointer *values = g_new(gpointer, num_labels);
 	gpointer default_value;
+	gboolean default_found = FALSE;
 	int i;
 
-	default_value = purple_request_field_choice_get_default_value(field);
+	default_value = purple_request_field_choice_get_value(field);
 	if (num_labels > 5 || purple_request_cpar_is_compact(cpar))
 	{
 		int default_index = 0;
@@ -1082,8 +1083,10 @@ create_choice_field(PurpleRequestField *
 			l = g_list_next(l);
 
 			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widget), text);
-			if (value == default_value)
+			if (value == default_value) {
 				default_index = i;
+				default_found = TRUE;
+			}
 			values[i++] = value;
 		}
 
@@ -1128,8 +1131,10 @@ create_choice_field(PurpleRequestField *
 			if (first_radio == NULL)
 				first_radio = radio;
 
-			if (value == default_value)
+			if (value == default_value) {
 				gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
+				default_found = TRUE;
+			}
 			values[i++] = value;
 
 			gtk_box_pack_start(GTK_BOX(box), radio, TRUE, TRUE, 0);
@@ -1140,6 +1145,9 @@ create_choice_field(PurpleRequestField *
 		}
 	}
 
+	if (!default_found && i > 0)
+		purple_request_field_choice_set_value(field, values[0]);
+
 	g_object_set_data_full(G_OBJECT(widget), "values", values, g_free);
 
 	return widget;
@@ -1890,26 +1898,34 @@ pidgin_request_folder(const char *title,
 	return (void *)data;
 }
 
-#ifdef _WIN32
-
-/* Not needed (yet) for non-win32, but should work everywhere. */
+/* if request callback issues another request, it should be attached to the
+ * primary request parent */
 static void
-pidgin_window_detach_children(GtkWindow* parent)
+pidgin_window_detach_children(GtkWindow* win)
 {
 	GList *it;
+	GtkWindow *par;
 
-	g_return_if_fail(parent != NULL);
+	g_return_if_fail(win != NULL);
 
+	par = gtk_window_get_transient_for(win);
 	it = gtk_window_list_toplevels();
 	for (it = g_list_first(it); it != NULL; it = g_list_next(it)) {
-		GtkWindow *win = GTK_WINDOW(it->data);
-		if (gtk_window_get_transient_for(win) == parent)
-			gtk_window_set_transient_for(win, NULL);
+		GtkWindow *child = GTK_WINDOW(it->data);
+		if (gtk_window_get_transient_for(child) != win)
+			continue;
+		if (gtk_window_get_destroy_with_parent(child)) {
+#ifdef _WIN32
+			/* XXX test/verify it: Win32 gtk ignores
+			 * gtk_window_set_destroy_with_parent(..., FALSE). */
+			gtk_window_set_transient_for(child, NULL);
+#endif
+			continue;
+		}
+		gtk_window_set_transient_for(child, par);
 	}
 }
 
-#endif
-
 static void
 pidgin_close_request(PurpleRequestType type, void *ui_handle)
 {
@@ -1917,10 +1933,7 @@ pidgin_close_request(PurpleRequestType t
 
 	g_free(data->cbs);
 
-#ifdef _WIN32
-	/* Win32 gtk ignores gtk_window_set_destroy_with_parent(..., FALSE). */
 	pidgin_window_detach_children(GTK_WINDOW(data->dialog));
-#endif
 
 	gtk_widget_destroy(data->dialog);
 



More information about the Commits mailing list