changeset 19915:8feb06a1c3c1

Finished implem in gtkrequest.c
author Gabriel Schulhof <nix@go-nix.ca>
date Fri, 17 Aug 2007 20:21:04 +0000
parents ad214eb84054
children df070477394e
files pidgin/gtklog.c pidgin/gtkplugin.c pidgin/gtkpounce.c pidgin/gtkprefs.c pidgin/gtkprivacy.c pidgin/gtkrequest.c pidgin/gtksavedstatuses.c
diffstat 7 files changed, 73 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtklog.c	Thu Aug 16 21:40:47 2007 +0000
+++ b/pidgin/gtklog.c	Fri Aug 17 20:21:04 2007 +0000
@@ -322,7 +322,7 @@
 	data2[2] = log;
 	purple_request_action(lv, NULL, "Delete Log?", tmp, 0, 
 						NULL, NULL, NULL,
-						"pidgin-log", data2, 2,
+						"log_viewer", data2, 2,
 						_("Delete"), delete_log_cb,
 						_("Cancel"), delete_log_cleanup_cb);
 	g_free(tmp);
--- a/pidgin/gtkplugin.c	Thu Aug 16 21:40:47 2007 +0000
+++ b/pidgin/gtkplugin.c	Fri Aug 17 20:21:04 2007 +0000
@@ -283,7 +283,7 @@
 			                    _("Multiple plugins will be unloaded."),
 			                    tmp->str, 0,
 								NULL, NULL, NULL,
-								"pidgin-plugins", cb_data, 2,
+								"plugins", cb_data, 2,
 			                    _("Unload Plugins"), G_CALLBACK(plugin_unload_confirm_cb),
 			                    _("Cancel"), g_free);
 			g_string_free(tmp, TRUE);
--- a/pidgin/gtkpounce.c	Thu Aug 16 21:40:47 2007 +0000
+++ b/pidgin/gtkpounce.c	Fri Aug 17 20:21:04 2007 +0000
@@ -156,7 +156,7 @@
 	purple_request_file(entry, _("Select a file"), name, FALSE,
 					  G_CALLBACK(pounce_update_entry_fields), NULL,
 					  NULL, NULL, NULL,
-					  "pidgin-pounce-editor", entry);
+					  "buddy_pounce", entry);
 	g_signal_connect_swapped(G_OBJECT(entry), "destroy",
 			G_CALLBACK(purple_request_close_with_handle), entry);
 }
@@ -1110,7 +1110,7 @@
 	buf = g_strdup_printf(_("Are you sure you want to delete the pounce on %s for %s?"), pouncee, pouncer);
 	purple_request_action(pounce, NULL, buf, NULL, 0,
 						account, pouncee, NULL,
-						"pidgin-pounces", pounce, 2,
+						"pounces", pounce, 2,
 						_("Delete"), pounces_manager_delete_confirm_cb,
 						_("Cancel"), NULL);
 	g_free(buf);
--- a/pidgin/gtkprefs.c	Thu Aug 16 21:40:47 2007 +0000
+++ b/pidgin/gtkprefs.c	Fri Aug 17 20:21:04 2007 +0000
@@ -641,7 +641,7 @@
 add_theme_button_clicked_cb(GtkWidget *widget, gpointer null)
 {
 	purple_request_file(NULL, _("Install Theme"), NULL, FALSE,
-	    (GCallback)request_theme_file_name_cb, NULL, NULL, NULL, NULL, "pidgin-prefs", NULL) ;
+	    (GCallback)request_theme_file_name_cb, NULL, NULL, NULL, NULL, "preferences", NULL) ;
 }
 
 static void
@@ -1620,7 +1620,7 @@
 
 	purple_request_file(prefs, _("Sound Selection"), filename, FALSE,
 					  G_CALLBACK(sound_chosen_cb), NULL, 
-					  NULL, NULL, NULL, "pidgin-prefs",
+					  NULL, NULL, NULL, "preferences",
 					  GINT_TO_POINTER(sound_row_sel));
 }
 
--- a/pidgin/gtkprivacy.c	Thu Aug 16 21:40:47 2007 +0000
+++ b/pidgin/gtkprivacy.c	Fri Aug 17 20:21:04 2007 +0000
@@ -561,7 +561,7 @@
 			_("_Permit"), G_CALLBACK(add_permit_block_cb),
 			_("Cancel"), G_CALLBACK(destroy_request_data),
 			account, name, NULL,
-			"pidgin-privacy", data);
+			"privacy", data);
 	}
 	else {
 		char *primary = g_strdup_printf(_("Allow %s to contact you?"), name);
@@ -573,7 +573,7 @@
 		purple_request_action(account, _("Permit User"), primary, secondary,
 							0,
 							account, name, NULL,
-							"pidgin-privacy", data, 2,
+							"privacy", data, 2,
 							_("_Permit"), G_CALLBACK(confirm_permit_block_cb),
 							_("Cancel"), G_CALLBACK(destroy_request_data));
 
@@ -602,7 +602,7 @@
 			_("_Block"), G_CALLBACK(add_permit_block_cb),
 			_("Cancel"), G_CALLBACK(destroy_request_data),
 			account, name, NULL,
-			"pidgin-privacy", data);
+			"privacy", data);
 	}
 	else {
 		char *primary = g_strdup_printf(_("Block %s?"), name);
@@ -612,7 +612,7 @@
 		purple_request_action(account, _("Block User"), primary, secondary,
 							0,
 							account, name, NULL,
-							"pidgin-privacy", data, 2,
+							"privacy", data, 2,
 							_("_Block"), G_CALLBACK(confirm_permit_block_cb),
 							_("Cancel"), G_CALLBACK(destroy_request_data));
 
--- a/pidgin/gtkrequest.c	Thu Aug 16 21:40:47 2007 +0000
+++ b/pidgin/gtkrequest.c	Fri Aug 17 20:21:04 2007 +0000
@@ -78,6 +78,55 @@
 
 } PidginRequestData;
 
+static GtkWindow *
+find_toplevel(GList *ll_toplevels, const char *role)
+{
+	const char *window_role = NULL;
+	GList *ll_itr = NULL;
+
+	for (ll_itr = ll_toplevels ; ll_itr ; ll_itr = ll_itr->next) {
+		if ((window_role = gtk_window_get_role(GTK_WINDOW(ll_itr->data))) != NULL) {
+			if (!strcmp(window_role, role))
+				return GTK_WINDOW(ll_itr->data);
+		}
+	}
+
+	return NULL;
+}
+
+static GtkWindow *
+get_request_parent(const char *ui_hint, PidginConversation *convo)
+{
+	GtkWindow *toplevel = NULL;
+	PidginBuddyList *blist = NULL;
+
+	if (convo)
+		return GTK_WINDOW(convo->win->window);
+
+	if (strcmp(ui_hint, "blist")) {
+		GList *ll_toplevels = NULL;
+
+		ll_toplevels = gtk_window_list_toplevels();
+
+		if (!(toplevel = find_toplevel(ll_toplevels, ui_hint))) {
+			if (!strcmp(ui_hint, "register-account"))
+				toplevel = find_toplevel(ll_toplevels, "account");
+			else
+			if (!strcmp(ui_hint, "xfer"))
+				toplevel = find_toplevel(ll_toplevels, "file transfer");
+		}
+		
+		g_list_free(ll_toplevels);
+	}
+
+	/* Takes care of "pidgin-statusbox" as well */
+	if (!toplevel)
+		if ((blist = pidgin_blist_get_default_gtk_blist()) != NULL)
+			return GTK_WINDOW(blist->window);
+
+	return NULL;
+}
+
 static void
 generic_response_start(PidginRequestData *data)
 {
@@ -311,7 +360,7 @@
 
 	/* Create the dialog. */
 	dialog = gtk_dialog_new_with_buttons(title ? title : PIDGIN_ALERT_TITLE,
-					     NULL, 0,
+					     get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL), 0,
 					     text_to_stock(cancel_text), 1,
 					     text_to_stock(ok_text),     0,
 					     NULL);
@@ -470,6 +519,8 @@
 
 	/* Create the dialog. */
 	data->dialog = dialog = gtk_dialog_new();
+	gtk_window_set_transient_for(GTK_WINDOW(dialog),
+		get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL));
 
 	if (title != NULL)
 		gtk_window_set_title(GTK_WINDOW(dialog), title);
@@ -580,6 +631,8 @@
 
 	/* Create the dialog. */
 	data->dialog = dialog = gtk_dialog_new();
+	gtk_window_set_transient_for(GTK_WINDOW(dialog),
+		get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL));
 
 #if GTK_CHECK_VERSION(2,10,0)
 	gtk_window_set_deletable(GTK_WINDOW(data->dialog), FALSE);
@@ -1089,6 +1142,8 @@
 #else /* !_WIN32 */
 	data->dialog = win = pidgin_create_window(title, PIDGIN_HIG_BORDER, "multifield", TRUE) ;
 #endif /* _WIN32 */
+	gtk_window_set_transient_for(GTK_WINDOW(win),
+		get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL));
 
 	g_signal_connect(G_OBJECT(win), "delete_event",
 					 G_CALLBACK(destroy_multifield_cb), data);
@@ -1604,6 +1659,9 @@
 	g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), "clicked",
 					 G_CALLBACK(file_ok_check_if_exists_cb), data);
 #endif /* FILECHOOSER */
+	gtk_window_set_role(GTK_WINDOW(filesel), "pidgin-request-file");
+	gtk_window_set_transient_for(GTK_WINDOW(filesel),
+		get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL));
 
 	data->dialog = filesel;
 	gtk_widget_show(filesel);
@@ -1654,6 +1712,9 @@
 	g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(dirsel)->ok_button), "clicked",
 					 G_CALLBACK(file_ok_check_if_exists_cb), data);
 #endif
+	gtk_window_set_role(GTK_WINDOW(filesel), "pidgin-request-dir");
+	gtk_window_set_transient_for(GTK_WINDOW(filesel),
+		get_request_parent(ui_hint, conv ? PIDGIN_CONVERSATION(conv) : NULL));
 
 	data->dialog = dirsel;
 	gtk_widget_show(dirsel);
--- a/pidgin/gtksavedstatuses.c	Thu Aug 16 21:40:47 2007 +0000
+++ b/pidgin/gtksavedstatuses.c	Fri Aug 17 20:21:04 2007 +0000
@@ -339,7 +339,7 @@
 
 	purple_request_action(handle, NULL, title, NULL, 0,
 		 NULL, NULL, NULL,
-		 sel_titles, 2,
+		 "statuses", sel_titles, 2,
 		_("Delete"), status_window_delete_confirm_cb,
 		_("Cancel"), status_window_delete_cancel_cb);