comparison plugins/docklet/eggtrayicon.c @ 4261:e252238f99df

[gaim-migrate @ 4512] <Robot101> commit message: <Robot101> wait <Robot101> don't apply that <Robot101> bloody gedit <Robot101> there we go <Robot101> fixed it <Robot101> patch to fix docklet crash on unload, thanks to Nicol?s Lichtmaier for identifying the problem and fix, and Kristian Rietveld for implementing it <Robot101> also implements a blinking icon when messages are pending & credits people correctly in ChangeLog <Robot101> and for the record, it was Nicol?s Lichtmaier who did the icon factory stuff last night * Robot101 hops up and down <Robot101> patchy merge merge! < ChipX86> fine. <Robot101> yay =) committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 09 Jan 2003 01:48:04 +0000
parents e23909729192
children 92cbf9713795
comparison
equal deleted inserted replaced
4260:43864b6a28a2 4261:e252238f99df
29 static GtkPlugClass *parent_class = NULL; 29 static GtkPlugClass *parent_class = NULL;
30 30
31 static void egg_tray_icon_init (EggTrayIcon *icon); 31 static void egg_tray_icon_init (EggTrayIcon *icon);
32 static void egg_tray_icon_class_init (EggTrayIconClass *klass); 32 static void egg_tray_icon_class_init (EggTrayIconClass *klass);
33 33
34 static void egg_tray_icon_unrealize (GtkWidget *widget);
35
34 static void egg_tray_icon_update_manager_window (EggTrayIcon *icon); 36 static void egg_tray_icon_update_manager_window (EggTrayIcon *icon);
35 37
36 GType 38 GType
37 egg_tray_icon_get_type (void) 39 egg_tray_icon_get_type (void)
38 { 40 {
55 (GInstanceInitFunc) egg_tray_icon_init 57 (GInstanceInitFunc) egg_tray_icon_init
56 }; 58 };
57 59
58 our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0); 60 our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0);
59 } 61 }
62 else if (parent_class == NULL) {
63 /* we're reheating the old class from a previous instance - engage ugly hack =( */
64 egg_tray_icon_class_init((EggTrayIconClass *)g_type_class_peek(our_type));
65 }
60 66
61 return our_type; 67 return our_type;
62 } 68 }
63 69
64 static void 70 static void
70 } 76 }
71 77
72 static void 78 static void
73 egg_tray_icon_class_init (EggTrayIconClass *klass) 79 egg_tray_icon_class_init (EggTrayIconClass *klass)
74 { 80 {
81 GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
82
75 parent_class = g_type_class_peek_parent (klass); 83 parent_class = g_type_class_peek_parent (klass);
84
85 widget_class->unrealize = egg_tray_icon_unrealize;
76 } 86 }
77 87
78 static GdkFilterReturn 88 static GdkFilterReturn
79 egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data) 89 egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
80 { 90 {
94 egg_tray_icon_update_manager_window (icon); 104 egg_tray_icon_update_manager_window (icon);
95 } 105 }
96 } 106 }
97 107
98 return GDK_FILTER_CONTINUE; 108 return GDK_FILTER_CONTINUE;
109 }
110
111 static void
112 egg_tray_icon_unrealize (GtkWidget *widget)
113 {
114 EggTrayIcon *icon = EGG_TRAY_ICON (widget);
115 GdkWindow *root_window;
116
117 if (icon->manager_window != None)
118 {
119 GdkWindow *gdkwin;
120
121 #if HAVE_GTK_MULTIHEAD
122 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
123 icon->manager_window);
124 #else
125 gdkwin = gdk_window_lookup (icon->manager_window);
126 #endif
127
128 gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
129 }
130
131 #if HAVE_GTK_MULTIHEAD
132 root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
133 #else
134 root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
135 #endif
136
137 gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
138
139 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
140 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
99 } 141 }
100 142
101 static void 143 static void
102 egg_tray_icon_send_manager_message (EggTrayIcon *icon, 144 egg_tray_icon_send_manager_message (EggTrayIcon *icon,
103 long message, 145 long message,
156 if (icon->manager_window != None) 198 if (icon->manager_window != None)
157 { 199 {
158 GdkWindow *gdkwin; 200 GdkWindow *gdkwin;
159 201
160 #if HAVE_GTK_MULTIHEAD 202 #if HAVE_GTK_MULTIHEAD
161 gdkwin = gdk_window_lookup_for_display (display, 203 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
162 icon->manager_window); 204 icon->manager_window);
163 #else 205 #else
164 gdkwin = gdk_window_lookup (icon->manager_window); 206 gdkwin = gdk_window_lookup (icon->manager_window);
165 #endif 207 #endif
166 208
208 250
209 icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL); 251 icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL);
210 gtk_window_set_title (GTK_WINDOW (icon), name); 252 gtk_window_set_title (GTK_WINDOW (icon), name);
211 253
212 #if HAVE_GTK_MULTIHEAD 254 #if HAVE_GTK_MULTIHEAD
255 /* FIXME: this code does not compile, screen is undefined. Now try
256 * getting the GdkScreen from xscreen (:. Dunno how to solve this
257 * (there is prolly some easy way I cant think of right now)
258 */
213 gtk_plug_construct_for_display (GTK_PLUG (icon), 259 gtk_plug_construct_for_display (GTK_PLUG (icon),
214 gdk_screen_get_display (screen), 0); 260 gdk_screen_get_display (screen), 0);
215 #else 261 #else
216 gtk_plug_construct (GTK_PLUG (icon), 0); 262 gtk_plug_construct (GTK_PLUG (icon), 0);
217 #endif 263 #endif
233 "_NET_SYSTEM_TRAY_OPCODE", False); 279 "_NET_SYSTEM_TRAY_OPCODE", False);
234 280
235 egg_tray_icon_update_manager_window (icon); 281 egg_tray_icon_update_manager_window (icon);
236 282
237 #if HAVE_GTK_MULTIHEAD 283 #if HAVE_GTK_MULTIHEAD
238 root_window = gdk_screen_get_root_window (screen); 284 root_window = gdk_screen_get_root_window (gtk_widget_get_screen (screen));
239 #else 285 #else
240 root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ()); 286 root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
241 #endif 287 #endif
242 288
243 /* Add a root window filter so that we get changes on MANAGER */ 289 /* Add a root window filter so that we get changes on MANAGER */