# HG changeset patch # User Gabriel Schulhof # Date 1185306866 0 # Node ID d5e2a4897bbc29d627c7032f6cb9e0bbc172d4cb # Parent 13a779fe3f1e2593995c7eb376b7df74630935a6 Generic transience mechanism ... *shudder* diff -r 13a779fe3f1e -r d5e2a4897bbc pidgin/gtkblist.c --- a/pidgin/gtkblist.c Tue Jul 24 18:08:23 2007 +0000 +++ b/pidgin/gtkblist.c Tue Jul 24 19:54:26 2007 +0000 @@ -2828,6 +2828,12 @@ !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled")); } +static void +blist_show_plugins_cb(GtkWidget *widget, gpointer null) +{ + pidgin_set_toplevel(GTK_WINDOW(gtkblist->window)); + pidgin_plugin_dialog_show(); +} /*************************************************** * Crap * @@ -2860,7 +2866,7 @@ /* Tools */ { N_("/_Tools"), NULL, NULL, 0, "", NULL }, { N_("/Tools/Buddy _Pounces"), NULL, pidgin_pounces_manager_show, 0, "", NULL }, - { N_("/Tools/Plu_gins"), "U", pidgin_plugin_dialog_show, 0, "", PIDGIN_STOCK_TOOLBAR_PLUGINS }, + { N_("/Tools/Plu_gins"), "U", blist_show_plugins_cb, 0, "", PIDGIN_STOCK_TOOLBAR_PLUGINS }, { N_("/Tools/Pr_eferences"), "P", pidgin_prefs_show, 0, "", GTK_STOCK_PREFERENCES }, { N_("/Tools/Pr_ivacy"), NULL, pidgin_privacy_dialog_show, 0, "", NULL }, { "/Tools/sep2", NULL, NULL, 0, "", NULL }, diff -r 13a779fe3f1e -r d5e2a4897bbc pidgin/gtkplugin.c --- a/pidgin/gtkplugin.c Tue Jul 24 18:08:23 2007 +0000 +++ b/pidgin/gtkplugin.c Tue Jul 24 19:54:26 2007 +0000 @@ -30,7 +30,6 @@ #include "debug.h" #include "prefs.h" #include "request.h" -#include "gtkblist.h" #include @@ -522,17 +521,14 @@ GtkCellRenderer *rend, *rendt; GtkTreeViewColumn *col; GtkTreeSelection *sel; - PidginBuddyList *blist; if (plugin_dialog != NULL) { gtk_window_present(GTK_WINDOW(plugin_dialog)); return; } - blist = pidgin_blist_get_default_gtk_blist(); - plugin_dialog = gtk_dialog_new_with_buttons(_("Plugins"), - NULL == blist ? NULL : NULL == blist->window ? NULL : blist->window, + pidgin_get_current_toplevel(), GTK_DIALOG_NO_SEPARATOR, NULL); diff -r 13a779fe3f1e -r d5e2a4897bbc pidgin/gtkpounce.c --- a/pidgin/gtkpounce.c Tue Jul 24 18:08:23 2007 +0000 +++ b/pidgin/gtkpounce.c Tue Jul 24 19:54:26 2007 +0000 @@ -516,6 +516,7 @@ dialog->window = window = pidgin_create_window((cur_pounce == NULL ? _("New Buddy Pounce") : _("Edit Buddy Pounce")), PIDGIN_HIG_BORDER, "buddy_pounce", FALSE) ; gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); + gtk_window_set_transient_for(GTK_WINDOW(window), pidgin_get_toplevel()); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_win_cb), dialog); @@ -1057,6 +1058,7 @@ static void pounces_manager_add_cb(GtkButton *button, gpointer user_data) { + pidgin_set_toplevel(gtk_widget_get_toplevel(button)); pidgin_pounce_editor_show(NULL, NULL, NULL); } diff -r 13a779fe3f1e -r d5e2a4897bbc pidgin/gtkutils.c --- a/pidgin/gtkutils.c Tue Jul 24 18:08:23 2007 +0000 +++ b/pidgin/gtkutils.c Tue Jul 24 19:54:26 2007 +0000 @@ -61,6 +61,8 @@ #include "gtkthemes.h" #include "gtkutils.h" +#define PIDGIN_TOPLEVEL_REFFED_FLAG "pidgin-toplevel-is-weakly-reffed" + typedef struct { GtkWidget *menu; gint default_item; @@ -68,6 +70,38 @@ static guint accels_save_timer = 0; +static GtkWindow *toplevel = NULL; + +static void +toplevel_weak_notify(gpointer null, GtkWindow *window) +{ + if (toplevel == window) + toplevel = NULL; +} + +void +pidgin_set_toplevel(GtkWindow *new_toplevel) +{ + g_return_if_fail(toplevel != NULL); + g_return_if_fail(GTK_IS_WINDOW(toplevel)); + + if (toplevel) { + g_object_weak_unref(G_OBJECT(toplevel), toplevel_weak_notify, NULL); + toplevel = NULL; + } + + if (new_topleve) { + g_object_weak_ref(G_OBJECT(new_toplevel), toplevel_weak_notify, NULL); + toplevel = new_toplevel; + } +} + +GtkWindow * +pidgin_get_toplevel() +{ + return toplevel; +} + static gboolean url_clicked_idle_cb(gpointer data) { diff -r 13a779fe3f1e -r d5e2a4897bbc pidgin/gtkutils.h --- a/pidgin/gtkutils.h Tue Jul 24 18:08:23 2007 +0000 +++ b/pidgin/gtkutils.h Tue Jul 24 19:54:26 2007 +0000 @@ -65,6 +65,24 @@ #endif /* _WIN32 */ /** + * Designate new_toplevel as the preferred window for ensuring proper + * transience relationships for subsequent dialogs. + * + * @param new_toplevel The GtkWindow to be used for transience. + */ +void pidgin_set_toplevel(GtkWindow *new_toplevel); + +/** + * Retrieve the currently preferred toplevel window (set by a previous + * call top pidgin_set_toplevel()) and *not* since destroyed. + * + * @return The GtkWindow most recently given to pidgin_set_toplevel(), or #NULL. + * #NULL will be returned either if no toplevel has been set, or if the + * most recently set toplevel has since been destroyed. + */ +GtkWindow *pidgin_get_toplevel(); + +/** * Sets up a gtkimhtml widget, loads it with smileys, and sets the * default signal handlers. *