changeset 16552:17ac25319a77

Quoth Charkins: This patch has two changes: "This patch has two changes: First is to slightly change the re-creation behavior of the docklet. Sadrul pointed out on gaim-devel that the x11 docklet re-creates itself when it is destroyed and thought this might be causing problems with fluxbox. This patch now distinguishes between initial creation and re-creation. When re-creating, the docklet no longer registers itself as a visibility manager until it successfully embeds. Second is to change the timeout behavior for embedding. Because the notification area API is asynchronous, gaim assumes the docklet gets embeded for a certain timeout period, allowing the buddy list to start hidden before the docklet has been embeded in the notification area. If the timeout occurs, it is removed as a visibility manager and the buddy list will become visible. This timeout has been set at 5 seconds. There have been a few reports that indicate this timeout period is not long enough when starting gaim from a saved session upon login. I have been hesitant to increase the timeout, as it has the potential of delaying the startup of gaim for the timeout period if the buddy list was hidden when gaim last closed and there is not currently a notification area available. This patch makes the x11 docklet track whether it was successfully embedded and uses a longer timeout (15 seconds in this patch) only if it successfully embedded on the previous execution. Otherwise, it uses the shorter 5 second timeout. "
author Luke Schierer <lschiere@pidgin.im>
date Sat, 28 Apr 2007 02:33:40 +0000
parents b8ba44eafaae
children f0d399f91756
files pidgin/gtkdocklet-x11.c
diffstat 1 files changed, 32 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkdocklet-x11.c	Sat Apr 28 01:46:53 2007 +0000
+++ b/pidgin/gtkdocklet-x11.c	Sat Apr 28 02:33:40 2007 +0000
@@ -25,6 +25,7 @@
 #include "internal.h"
 #include "pidgin.h"
 #include "debug.h"
+#include "prefs.h"
 #include "pidginstock.h"
 
 #include "gtkdialogs.h"
@@ -32,7 +33,8 @@
 #include "eggtrayicon.h"
 #include "gtkdocklet.h"
 
-#define EMBED_TIMEOUT 5000
+#define SHORT_EMBED_TIMEOUT 5000
+#define LONG_EMBED_TIMEOUT 15000
 
 /* globals */
 static EggTrayIcon *docklet = NULL;
@@ -44,12 +46,12 @@
 static int docklet_height = 0;
 
 /* protos */
-static void docklet_x11_create(void);
+static void docklet_x11_create(gboolean);
 
 static gboolean
-docklet_x11_create_cb()
+docklet_x11_recreate_cb()
 {
-	docklet_x11_create();
+	docklet_x11_create(TRUE);
 
 	return FALSE; /* for when we're called by the glib idle handler */
 }
@@ -62,6 +64,7 @@
 	g_source_remove(embed_timeout);
 	embed_timeout = 0;
 	pidgin_docklet_embedded();
+	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
 }
 
 static void
@@ -236,7 +239,7 @@
 }
 
 static void
-docklet_x11_create()
+docklet_x11_create(gboolean recreate)
 {
 	GtkWidget *box;
 
@@ -272,17 +275,35 @@
 	 * previous visibility state.  If the docklet does not get embedded within
 	 * the timeout, it will be removed as a visibility manager until it does
 	 * get embedded.  Ideally, we would only call docklet_embedded() when the
-	 * icon was actually embedded.
+	 * icon was actually embedded. This only happens when the docklet is first
+	 * created, not when being recreated.
+	 *
+	 * The x11 docklet tracks whether it successfully embedded in a pref and
+	 * allows for a longer timeout period if it successfully embedded the last
+	 * time it was run. This should hopefully solve problems with the buddy
+	 * list not properly starting hidden when gaim is started on login.
 	 */
-	pidgin_docklet_embedded();
-	embed_timeout = g_timeout_add(EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
+	if(!recreate) {
+		pidgin_docklet_embedded();
+		if(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded")) {
+			embed_timeout = g_timeout_add(LONG_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
+		} else {
+			embed_timeout = g_timeout_add(SHORT_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
+		}
+	}
 
 	purple_debug(PURPLE_DEBUG_INFO, "docklet", "created\n");
 }
 
+static void
+docklet_x11_create_ui_op()
+{
+	docklet_x11_create(FALSE);
+}
+
 static struct docklet_ui_ops ui_ops =
 {
-	docklet_x11_create,
+	docklet_x11_create_ui_op,
 	docklet_x11_destroy,
 	docklet_x11_update_icon,
 	docklet_x11_blank_icon,
@@ -298,4 +319,6 @@
 docklet_ui_init()
 {
 	pidgin_docklet_set_ui_ops(&ui_ops);
+	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11");
+	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
 }