pidgin/gtkutils.c

changeset 18918
eab3d9b215b0
parent 18672
da4db1be5d98
child 18921
273cae0f3130
equal deleted inserted replaced
18917:2de25c9cf9c1 18918:eab3d9b215b0
59 #include "gtkimhtmltoolbar.h" 59 #include "gtkimhtmltoolbar.h"
60 #include "pidginstock.h" 60 #include "pidginstock.h"
61 #include "gtkthemes.h" 61 #include "gtkthemes.h"
62 #include "gtkutils.h" 62 #include "gtkutils.h"
63 63
64 #define PIDGIN_TOPLEVEL_REFFED_FLAG "pidgin-toplevel-is-weakly-reffed"
65
64 typedef struct { 66 typedef struct {
65 GtkWidget *menu; 67 GtkWidget *menu;
66 gint default_item; 68 gint default_item;
67 } AopMenu; 69 } AopMenu;
68 70
69 static guint accels_save_timer = 0; 71 static guint accels_save_timer = 0;
72
73 static GtkWindow *toplevel = NULL;
74
75 static void
76 toplevel_weak_notify(gpointer null, GtkWindow *window)
77 {
78 if (toplevel == window)
79 toplevel = NULL;
80 }
81
82 void
83 pidgin_set_toplevel(GtkWindow *new_toplevel)
84 {
85 g_return_if_fail(toplevel != NULL);
86 g_return_if_fail(GTK_IS_WINDOW(toplevel));
87
88 if (toplevel) {
89 g_object_weak_unref(G_OBJECT(toplevel), toplevel_weak_notify, NULL);
90 toplevel = NULL;
91 }
92
93 if (new_topleve) {
94 g_object_weak_ref(G_OBJECT(new_toplevel), toplevel_weak_notify, NULL);
95 toplevel = new_toplevel;
96 }
97 }
98
99 GtkWindow *
100 pidgin_get_toplevel()
101 {
102 return toplevel;
103 }
70 104
71 static gboolean 105 static gboolean
72 url_clicked_idle_cb(gpointer data) 106 url_clicked_idle_cb(gpointer data)
73 { 107 {
74 purple_notify_uri(NULL, data); 108 purple_notify_uri(NULL, data);

mercurial