Mercurial > pidgin.yaz
comparison plugins/docklet/docklet.c @ 4093:987624dcece4
[gaim-migrate @ 4308]
(12:50:47) Robot101: LSchiere: want to merge a docklet maintainance patch?
(12:50:54) Robot101: it shouldn't break anything, it's just better (tm)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 17 Dec 2002 22:35:31 +0000 |
parents | 49d42b275a68 |
children | 274cb26ba8dc |
comparison
equal
deleted
inserted
replaced
4092:7edd02612086 | 4093:987624dcece4 |
---|---|
1 /* System tray docklet plugin for Gaim | 1 /* System tray icon (aka docklet) plugin for Gaim |
2 * Copyright (C) 2002 Robert McQueen <robot101@debian.org> | 2 * Copyright (C) 2002 Robert McQueen <robot101@debian.org> |
3 * Inspired by a similar plugin by: | 3 * Inspired by a similar plugin by: |
4 * John (J5) Palmieri <johnp@martianrock.com> | 4 * John (J5) Palmieri <johnp@martianrock.com> |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or | 6 * This program is free software; you can redistribute it and/or |
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
19 * 02111-1307, USA. | 19 * 02111-1307, USA. |
20 */ | 20 */ |
21 | 21 |
22 /* todo (in order of importance): | 22 /* todo (in order of importance): |
23 - don't crash when the plugin gets unloaded (it seems to crash after | 23 - don't crash when the plugin gets unloaded (may be a libegg bug, |
24 the plugin has gone, when gtk updates the button in the plugins | 24 see #101467 in gnome bugzilla) |
25 dialog. backtrace is always useless. weird) | 25 - handle and update tooltips to show your current accounts ? |
26 - handle and update tooltips to show your current accounts | |
27 - dernyi's account status menu in the right click | 26 - dernyi's account status menu in the right click |
28 - store icons in gtk2 stock icon thing (needs doing for the whole prog) | 27 - store icons in gtk2 stock icon thing (needs doing for the whole prog) |
29 - optional pop up notices when GNOME2's system-tray-applet supports it | 28 - optional pop up notices when GNOME2's system-tray-applet supports it |
30 - support blinking the icon when messages are pending */ | 29 - support blinking the icon when messages are pending */ |
31 | 30 |
47 connecting, | 46 connecting, |
48 offline | 47 offline |
49 }; | 48 }; |
50 | 49 |
51 /* functions */ | 50 /* functions */ |
52 static void docklet_create(); | 51 static gboolean docklet_create(); |
53 static void docklet_update_status(); | 52 static void docklet_update_status(); |
53 void gaim_plugin_remove(); | |
54 | 54 |
55 /* globals */ | 55 /* globals */ |
56 static EggTrayIcon *docklet = NULL; | 56 static EggTrayIcon *docklet = NULL; |
57 static GtkWidget *icon; | 57 static GtkWidget *icon; |
58 static enum docklet_status status; | 58 static enum docklet_status status; |
216 scaled = gdk_pixbuf_scale_simple(unscaled, 24, 24, GDK_INTERP_BILINEAR); | 216 scaled = gdk_pixbuf_scale_simple(unscaled, 24, 24, GDK_INTERP_BILINEAR); |
217 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), scaled); | 217 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), scaled); |
218 g_object_unref(unscaled); | 218 g_object_unref(unscaled); |
219 g_object_unref(scaled); | 219 g_object_unref(scaled); |
220 | 220 |
221 debug_printf("Docklet: updated icon to %s\n",filename); | 221 debug_printf("Tray Icon: updated icon to %s\n",filename); |
222 } else { | 222 } else { |
223 debug_printf("Docklet: failed to load icon from %s\n",filename); | 223 debug_printf("Tray Icon: failed to load icon from %s\n",filename); |
224 } | 224 } |
225 | 225 |
226 g_free(filename); | 226 g_free(filename); |
227 } | 227 } |
228 | 228 |
257 docklet_update_icon(); | 257 docklet_update_icon(); |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 static void docklet_embedded(GtkWidget *widget, void *data) { | 261 static void docklet_embedded(GtkWidget *widget, void *data) { |
262 debug_printf("Docklet: embedded\n"); | 262 debug_printf("Tray Icon: embedded\n"); |
263 docklet_add(); | 263 docklet_add(); |
264 } | 264 } |
265 | 265 |
266 static void docklet_destroyed(GtkWidget *widget, void *data) { | 266 static void docklet_destroyed(GtkWidget *widget, void *data) { |
267 debug_printf("Docklet: destroyed\n"); | 267 debug_printf("Tray Icon: destroyed\n"); |
268 | |
269 docklet_remove(); | |
270 | |
268 docklet_flush_queue(); | 271 docklet_flush_queue(); |
269 docklet_remove(); | 272 |
270 docklet_create(); | 273 g_object_unref(G_OBJECT(docklet)); |
271 } | 274 docklet = NULL; |
272 | 275 |
273 static void docklet_create() { | 276 g_idle_add(docklet_create, NULL); |
277 } | |
278 | |
279 static gboolean docklet_create(void *data) { | |
274 GtkWidget *box; | 280 GtkWidget *box; |
275 | 281 |
276 if (docklet) { | 282 if (docklet) { |
277 /* if this is being called when a docklet exists, it's because that | 283 /* if this is being called when a tray icon exists, it's because |
278 docklet is in the process of being destroyed. all we need to do | 284 something messed up. try destroying it before we proceed, |
279 is tell gobject we're not interested in it any more, and throw | 285 although docklet_refcount may be all hosed. hopefully won't happen. */ |
280 the pointer away. */ | 286 debug_printf("Tray Icon: trying to create icon but it already exists?\n"); |
281 g_object_unref(G_OBJECT(docklet)); | 287 gaim_plugin_remove(); |
282 docklet = NULL; | |
283 } | 288 } |
284 | 289 |
285 docklet = egg_tray_icon_new("Gaim"); | 290 docklet = egg_tray_icon_new("Gaim"); |
286 box = gtk_event_box_new(); | 291 box = gtk_event_box_new(); |
287 icon = gtk_image_new(); | 292 icon = gtk_image_new(); |
297 /* ref the docklet before we bandy it about the place */ | 302 /* ref the docklet before we bandy it about the place */ |
298 g_object_ref(G_OBJECT(docklet)); | 303 g_object_ref(G_OBJECT(docklet)); |
299 docklet_update_status(); | 304 docklet_update_status(); |
300 docklet_update_icon(); | 305 docklet_update_icon(); |
301 | 306 |
302 debug_printf("Docklet: created\n"); | 307 debug_printf("Tray Icon: created\n"); |
308 | |
309 return FALSE; /* for when we're called by the glib idle handler */ | |
303 } | 310 } |
304 | 311 |
305 static void gaim_signon(struct gaim_connection *gc, void *data) { | 312 static void gaim_signon(struct gaim_connection *gc, void *data) { |
306 docklet_update_status(); | 313 docklet_update_status(); |
307 } | 314 } |
339 | 346 |
340 static void gaim_new_conversation(char *who, void *data) { | 347 static void gaim_new_conversation(char *who, void *data) { |
341 } */ | 348 } */ |
342 | 349 |
343 char *gaim_plugin_init(GModule *handle) { | 350 char *gaim_plugin_init(GModule *handle) { |
344 docklet_create(); | 351 docklet_create(NULL); |
345 | 352 |
346 gaim_signal_connect(handle, event_signon, gaim_signon, NULL); | 353 gaim_signal_connect(handle, event_signon, gaim_signon, NULL); |
347 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL); | 354 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL); |
348 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL); | 355 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL); |
349 gaim_signal_connect(handle, event_away, gaim_away, NULL); | 356 gaim_signal_connect(handle, event_away, gaim_away, NULL); |
362 docklet_remove(); | 369 docklet_remove(); |
363 } | 370 } |
364 | 371 |
365 docklet_flush_queue(); | 372 docklet_flush_queue(); |
366 | 373 |
367 g_object_unref(G_OBJECT(docklet)); | |
368 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); | 374 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); |
369 gtk_widget_destroy(GTK_WIDGET(docklet)); | 375 gtk_widget_destroy(GTK_WIDGET(docklet)); |
370 | 376 |
371 debug_printf("Docklet: removed\n"); | 377 g_object_unref(G_OBJECT(docklet)); |
378 docklet = NULL; | |
379 | |
380 debug_printf("Tray Icon: removed\n"); | |
372 } | 381 } |
373 | 382 |
374 GtkWidget *gaim_plugin_config_gtk() { | 383 GtkWidget *gaim_plugin_config_gtk() { |
375 GtkWidget *frame; | 384 GtkWidget *frame; |
376 GtkWidget *vbox, *hbox; | 385 GtkWidget *vbox, *hbox; |
377 GtkWidget *toggle; | 386 GtkWidget *toggle; |
378 | 387 |
379 frame = gtk_vbox_new(FALSE, 18); | 388 frame = gtk_vbox_new(FALSE, 18); |
380 gtk_container_set_border_width(GTK_CONTAINER(frame), 12); | 389 gtk_container_set_border_width(GTK_CONTAINER(frame), 12); |
381 | 390 |
382 vbox = make_frame(frame, _("Docklet Configuration")); | 391 vbox = make_frame(frame, _("Tray Icon Configuration")); |
383 hbox = gtk_hbox_new(FALSE, 18); | 392 hbox = gtk_hbox_new(FALSE, 18); |
384 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | 393 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
385 | 394 |
386 /* toggle = gtk_check_button_new_with_mnemonic(_("_Automatically show buddy list on sign on")); | 395 /* toggle = gtk_check_button_new_with_mnemonic(_("_Automatically show buddy list on sign on")); |
387 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), blist_options & OPT_BLIST_APP_BUDDY_SHOW); | 396 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), blist_options & OPT_BLIST_APP_BUDDY_SHOW); |
388 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_blist_show), NULL); | 397 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_blist_show), NULL); |
389 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); */ | 398 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); */ |
390 | 399 |
391 toggle = gtk_check_button_new_with_mnemonic(_("_Hide new messages until docklet is clicked")); | 400 toggle = gtk_check_button_new_with_mnemonic(_("_Hide new messages until tray icon is clicked")); |
392 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), away_options & OPT_AWAY_QUEUE_UNREAD); | 401 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), away_options & OPT_AWAY_QUEUE_UNREAD); |
393 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_queue), NULL); | 402 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_queue), NULL); |
394 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | 403 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
395 | 404 |
396 gtk_widget_show_all(frame); | 405 gtk_widget_show_all(frame); |
407 desc.url = g_strdup(WEBSITE); | 416 desc.url = g_strdup(WEBSITE); |
408 return &desc; | 417 return &desc; |
409 } | 418 } |
410 | 419 |
411 char *name() { | 420 char *name() { |
412 return _("System Tray Docklet"); | 421 return _("System Tray Icon"); |
413 } | 422 } |
414 | 423 |
415 char *description() { | 424 char *description() { |
416 return _("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window."); | 425 return _("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window. Also allows messages to be queued until the icon is clicked, similar to ICQ (although the icon doesn't flash yet =)."); |
417 } | 426 } |