Mercurial > pidgin.yaz
changeset 19799:d5e2a4897bbc
Generic transience mechanism ... *shudder*
author | Gabriel Schulhof <nix@go-nix.ca> |
---|---|
date | Tue, 24 Jul 2007 19:54:26 +0000 |
parents | 13a779fe3f1e |
children | c86f3c6cf698 |
files | pidgin/gtkblist.c pidgin/gtkplugin.c pidgin/gtkpounce.c pidgin/gtkutils.c pidgin/gtkutils.h |
diffstat | 5 files changed, 62 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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, "<Branch>", NULL }, { N_("/Tools/Buddy _Pounces"), NULL, pidgin_pounces_manager_show, 0, "<Item>", NULL }, - { N_("/Tools/Plu_gins"), "<CTL>U", pidgin_plugin_dialog_show, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_PLUGINS }, + { N_("/Tools/Plu_gins"), "<CTL>U", blist_show_plugins_cb, 0, "<StockItem>", PIDGIN_STOCK_TOOLBAR_PLUGINS }, { N_("/Tools/Pr_eferences"), "<CTL>P", pidgin_prefs_show, 0, "<StockItem>", GTK_STOCK_PREFERENCES }, { N_("/Tools/Pr_ivacy"), NULL, pidgin_privacy_dialog_show, 0, "<Item>", NULL }, { "/Tools/sep2", NULL, NULL, 0, "<Separator>", NULL },
--- 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 <string.h> @@ -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);
--- 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); }
--- 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) {
--- 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. *