comparison plugins/docklet/docklet.c @ 4274:906f61f27479

[gaim-migrate @ 4525] (01:26:02) Robot101: guess which bugs I fixed (01:26:14) Me: i can't (01:26:26) Robot101: really common crash... (01:26:35) Robot101: I fixed the return from away crash! =) committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 10 Jan 2003 06:32:14 +0000
parents e252238f99df
children 3196d9044a45
comparison
equal deleted inserted replaced
4273:a345395c8794 4274:906f61f27479
56 static EggTrayIcon *docklet = NULL; 56 static EggTrayIcon *docklet = NULL;
57 static GtkWidget *image = NULL; 57 static GtkWidget *image = NULL;
58 static GtkIconFactory *icon_factory = NULL; 58 static GtkIconFactory *icon_factory = NULL;
59 static enum docklet_status status; 59 static enum docklet_status status;
60 static enum docklet_status icon; 60 static enum docklet_status icon;
61 static guint blinker = 0;
62 61
63 static void docklet_toggle_mute(GtkWidget *toggle, void *data) { 62 static void docklet_toggle_mute(GtkWidget *toggle, void *data) {
64 mute_sounds = GTK_CHECK_MENU_ITEM(toggle)->active; 63 mute_sounds = GTK_CHECK_MENU_ITEM(toggle)->active;
65 } 64 }
66 65
74 save_prefs(); 73 save_prefs();
75 } */ 74 } */
76 75
77 static void docklet_flush_queue() { 76 static void docklet_flush_queue() {
78 if (unread_message_queue) { 77 if (unread_message_queue) {
79 purge_away_queue(unread_message_queue); 78 purge_away_queue(&unread_message_queue);
80 unread_message_queue = NULL;
81 } 79 }
82 } 80 }
83 81
84 static void docklet_menu(GdkEventButton *event) { 82 static void docklet_menu(GdkEventButton *event) {
85 static GtkWidget *menu = NULL; 83 static GtkWidget *menu = NULL;
277 icon = status; 275 icon = status;
278 docklet_update_icon(); 276 docklet_update_icon();
279 277
280 /* and schedule the blinker function if messages are pending */ 278 /* and schedule the blinker function if messages are pending */
281 if (status == online_pending || status == away_pending) { 279 if (status == online_pending || status == away_pending) {
282 blinker = g_timeout_add(500, docklet_blink_icon, NULL); 280 g_timeout_add(500, docklet_blink_icon, &docklet);
283 } 281 }
284 } 282 }
285 283
286 return FALSE; /* for when we're called by the glib idle handler */ 284 return FALSE; /* for when we're called by the glib idle handler */
287 } 285 }
289 static void docklet_embedded(GtkWidget *widget, void *data) { 287 static void docklet_embedded(GtkWidget *widget, void *data) {
290 debug_printf("Tray Icon: embedded\n"); 288 debug_printf("Tray Icon: embedded\n");
291 docklet_add(); 289 docklet_add();
292 } 290 }
293 291
292 static void docklet_remove_callbacks() {
293 debug_printf("Tray Icon: removing callbacks");
294
295 while (g_source_remove_by_user_data(&docklet)) {
296 debug_printf(".");
297 }
298
299 debug_printf("\n");
300 }
301
294 static void docklet_destroyed(GtkWidget *widget, void *data) { 302 static void docklet_destroyed(GtkWidget *widget, void *data) {
295 debug_printf("Tray Icon: destroyed\n"); 303 debug_printf("Tray Icon: destroyed\n");
296 304
297 docklet_remove(); 305 docklet_remove();
298 306
299 docklet_flush_queue(); 307 docklet_flush_queue();
300 308
301 if (blinker) { 309 docklet_remove_callbacks();
302 g_source_remove(blinker);
303 blinker = 0;
304 }
305 310
306 g_object_unref(G_OBJECT(docklet)); 311 g_object_unref(G_OBJECT(docklet));
307 docklet = NULL; 312 docklet = NULL;
308 313
309 g_idle_add(docklet_create, NULL); 314 g_idle_add(docklet_create, &docklet);
310 } 315 }
311 316
312 static gboolean docklet_create(void *data) { 317 static gboolean docklet_create() {
313 GtkWidget *box; 318 GtkWidget *box;
314 319
315 if (docklet) { 320 if (docklet) {
316 /* if this is being called when a tray icon exists, it's because 321 /* if this is being called when a tray icon exists, it's because
317 something messed up. try destroying it before we proceed, 322 something messed up. try destroying it before we proceed,
348 353
349 static void gaim_signoff(struct gaim_connection *gc, void *data) { 354 static void gaim_signoff(struct gaim_connection *gc, void *data) {
350 /* do this when idle so that if the prpl was connecting 355 /* do this when idle so that if the prpl was connecting
351 and was cancelled, we register that connecting_count 356 and was cancelled, we register that connecting_count
352 has returned to 0 */ 357 has returned to 0 */
353 g_idle_add(docklet_update_status, NULL); 358 g_idle_add(docklet_update_status, &docklet);
354 } 359 }
355 360
356 static void gaim_connecting(struct aim_user *user, void *data) { 361 static void gaim_connecting(struct aim_user *user, void *data) {
357 docklet_update_status(); 362 docklet_update_status();
358 } 363 }
360 static void gaim_away(struct gaim_connection *gc, char *state, char *message, void *data) { 365 static void gaim_away(struct gaim_connection *gc, char *state, char *message, void *data) {
361 /* we only support global away. this is the way it is, ok? */ 366 /* we only support global away. this is the way it is, ok? */
362 docklet_update_status(); 367 docklet_update_status();
363 } 368 }
364 369
365 static void gaim_im_displayed_recv(struct gaim_connection *gc, char **who, char **what, void *data) { 370 static void gaim_im_recv(struct gaim_connection *gc, char **who, char **what, void *data) {
366 /* if message queuing while away is enabled, this event could be the first 371 /* if message queuing while away is enabled, this event could be the first
367 message so we need to see if the status (and hence icon) needs changing */ 372 message so we need to see if the status (and hence icon) needs changing.
368 docklet_update_status(); 373 do this when idle so that all message processing is completed, queuing
374 etc, before we run. */
375 g_idle_add(docklet_update_status, &docklet);
369 } 376 }
370 377
371 /* static void gaim_buddy_signon(struct gaim_connection *gc, char *who, void *data) { 378 /* static void gaim_buddy_signon(struct gaim_connection *gc, char *who, void *data) {
372 } 379 }
373 380
416 423
417 gaim_signal_connect(handle, event_signon, gaim_signon, NULL); 424 gaim_signal_connect(handle, event_signon, gaim_signon, NULL);
418 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL); 425 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL);
419 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL); 426 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL);
420 gaim_signal_connect(handle, event_away, gaim_away, NULL); 427 gaim_signal_connect(handle, event_away, gaim_away, NULL);
421 gaim_signal_connect(handle, event_im_displayed_rcvd, gaim_im_displayed_recv, NULL); 428 gaim_signal_connect(handle, event_im_recv, gaim_im_recv, NULL);
422 /* gaim_signal_connect(handle, event_buddy_signon, gaim_buddy_signon, NULL); 429 /* gaim_signal_connect(handle, event_buddy_signon, gaim_buddy_signon, NULL);
423 gaim_signal_connect(handle, event_buddy_signoff, gaim_buddy_signoff, NULL); 430 gaim_signal_connect(handle, event_buddy_signoff, gaim_buddy_signoff, NULL);
424 gaim_signal_connect(handle, event_buddy_away, gaim_buddy_away, NULL); 431 gaim_signal_connect(handle, event_buddy_away, gaim_buddy_away, NULL);
425 gaim_signal_connect(handle, event_buddy_back, gaim_buddy_back, NULL); 432 gaim_signal_connect(handle, event_buddy_back, gaim_buddy_back, NULL);
426 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL); */ 433 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL); */
433 docklet_remove(); 440 docklet_remove();
434 } 441 }
435 442
436 docklet_flush_queue(); 443 docklet_flush_queue();
437 444
438 if (blinker) { 445 docklet_remove_callbacks();
439 g_source_remove(blinker);
440 blinker = 0;
441 }
442 446
443 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); 447 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL);
444 gtk_widget_destroy(GTK_WIDGET(docklet)); 448 gtk_widget_destroy(GTK_WIDGET(docklet));
445 449
446 g_object_unref(G_OBJECT(docklet)); 450 g_object_unref(G_OBJECT(docklet));