pidgin/gtkdocklet-x11.c

changeset 16621
616dc666cfb8
parent 16422
2a36f5d04f5b
child 16628
8fc264ea344f
equal deleted inserted replaced
16619:3c35ae665581 16621:616dc666cfb8
23 */ 23 */
24 24
25 #include "internal.h" 25 #include "internal.h"
26 #include "pidgin.h" 26 #include "pidgin.h"
27 #include "debug.h" 27 #include "debug.h"
28 #include "prefs.h"
28 #include "pidginstock.h" 29 #include "pidginstock.h"
29 30
30 #include "gtkdialogs.h" 31 #include "gtkdialogs.h"
31 32
32 #include "eggtrayicon.h" 33 #include "eggtrayicon.h"
33 #include "gtkdocklet.h" 34 #include "gtkdocklet.h"
34 35
35 #define EMBED_TIMEOUT 5000 36 #define SHORT_EMBED_TIMEOUT 5000
37 #define LONG_EMBED_TIMEOUT 15000
36 38
37 /* globals */ 39 /* globals */
38 static EggTrayIcon *docklet = NULL; 40 static EggTrayIcon *docklet = NULL;
39 static GtkWidget *image = NULL; 41 static GtkWidget *image = NULL;
40 static GtkTooltips *tooltips = NULL; 42 static GtkTooltips *tooltips = NULL;
42 static int embed_timeout = 0; 44 static int embed_timeout = 0;
43 static DockletStatus icon_status = 0; 45 static DockletStatus icon_status = 0;
44 static int docklet_height = 0; 46 static int docklet_height = 0;
45 47
46 /* protos */ 48 /* protos */
47 static void docklet_x11_create(void); 49 static void docklet_x11_create(gboolean);
48 50
49 static gboolean 51 static gboolean
50 docklet_x11_create_cb() 52 docklet_x11_recreate_cb()
51 { 53 {
52 docklet_x11_create(); 54 docklet_x11_create(TRUE);
53 55
54 return FALSE; /* for when we're called by the glib idle handler */ 56 return FALSE; /* for when we're called by the glib idle handler */
55 } 57 }
56 58
57 static void 59 static void
60 purple_debug(PURPLE_DEBUG_INFO, "docklet", "embedded\n"); 62 purple_debug(PURPLE_DEBUG_INFO, "docklet", "embedded\n");
61 63
62 g_source_remove(embed_timeout); 64 g_source_remove(embed_timeout);
63 embed_timeout = 0; 65 embed_timeout = 0;
64 pidgin_docklet_embedded(); 66 pidgin_docklet_embedded();
67 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
65 } 68 }
66 69
67 static void 70 static void
68 docklet_x11_destroyed_cb(GtkWidget *widget, void *data) 71 docklet_x11_destroyed_cb(GtkWidget *widget, void *data)
69 { 72 {
234 237
235 return FALSE; 238 return FALSE;
236 } 239 }
237 240
238 static void 241 static void
239 docklet_x11_create() 242 docklet_x11_create(gboolean recreate)
240 { 243 {
241 GtkWidget *box; 244 GtkWidget *box;
242 245
243 if (docklet) { 246 if (docklet) {
244 /* if this is being called when a tray icon exists, it's because 247 /* if this is being called when a tray icon exists, it's because
270 /* This is a hack to avoid a race condition between the docklet getting 273 /* This is a hack to avoid a race condition between the docklet getting
271 * embedded in the notification area and the gtkblist restoring its 274 * embedded in the notification area and the gtkblist restoring its
272 * previous visibility state. If the docklet does not get embedded within 275 * previous visibility state. If the docklet does not get embedded within
273 * the timeout, it will be removed as a visibility manager until it does 276 * the timeout, it will be removed as a visibility manager until it does
274 * get embedded. Ideally, we would only call docklet_embedded() when the 277 * get embedded. Ideally, we would only call docklet_embedded() when the
275 * icon was actually embedded. 278 * icon was actually embedded. This only happens when the docklet is first
279 * created, not when being recreated.
280 *
281 * The x11 docklet tracks whether it successfully embedded in a pref and
282 * allows for a longer timeout period if it successfully embedded the last
283 * time it was run. This should hopefully solve problems with the buddy
284 * list not properly starting hidden when gaim is started on login.
276 */ 285 */
277 pidgin_docklet_embedded(); 286 if(!recreate) {
278 embed_timeout = g_timeout_add(EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL); 287 pidgin_docklet_embedded();
288 if(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded")) {
289 embed_timeout = g_timeout_add(LONG_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
290 } else {
291 embed_timeout = g_timeout_add(SHORT_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
292 }
293 }
279 294
280 purple_debug(PURPLE_DEBUG_INFO, "docklet", "created\n"); 295 purple_debug(PURPLE_DEBUG_INFO, "docklet", "created\n");
281 } 296 }
282 297
298 static void
299 docklet_x11_create_ui_op()
300 {
301 docklet_x11_create(FALSE);
302 }
303
283 static struct docklet_ui_ops ui_ops = 304 static struct docklet_ui_ops ui_ops =
284 { 305 {
285 docklet_x11_create, 306 docklet_x11_create_ui_op,
286 docklet_x11_destroy, 307 docklet_x11_destroy,
287 docklet_x11_update_icon, 308 docklet_x11_update_icon,
288 docklet_x11_blank_icon, 309 docklet_x11_blank_icon,
289 docklet_x11_set_tooltip, 310 docklet_x11_set_tooltip,
290 #if GTK_CHECK_VERSION(2,2,0) 311 #if GTK_CHECK_VERSION(2,2,0)
296 317
297 void 318 void
298 docklet_ui_init() 319 docklet_ui_init()
299 { 320 {
300 pidgin_docklet_set_ui_ops(&ui_ops); 321 pidgin_docklet_set_ui_ops(&ui_ops);
301 } 322 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11");
323 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
324 }

mercurial