[gaim-migrate @ 16180]

Fri, 12 May 2006 03:45:47 +0000

author
Daniel Atallah <datallah@pidgin.im>
date
Fri, 12 May 2006 03:45:47 +0000
changeset 13770
ae2645f9f109
parent 13769
ba5d9c762c1d
child 13771
83a308e6d49f

[gaim-migrate @ 16180]
Fix a docking bug. When gaim exits while the Buddy List is docked, but minimized to the docklet, the next time gaim is started, the sectionof the screen that would be used by the docked Buddy List will be empty - not any more.

plugins/win32/winprefs/winprefs.c file | annotate | diff | comparison | revisions
--- a/plugins/win32/winprefs/winprefs.c	Fri May 12 02:50:23 2006 +0000
+++ b/plugins/win32/winprefs/winprefs.c	Fri May 12 03:45:47 2006 +0000
@@ -59,6 +59,7 @@
 static GaimPlugin *handle = NULL;
 static GtkAppBar *blist_ab = NULL;
 static GtkWidget *blist = NULL;
+static guint blist_visible_cb_id = 0;
 
 /* flash info */
 
@@ -109,11 +110,11 @@
 
 static void blist_dock_cb(gboolean val) {
 	if(val) {
-		gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Docking..\n");
+		gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Docking...\n");
 		if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) != BLIST_TOP_NEVER)
 			blist_set_ontop(TRUE);
 	} else {
-		gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Undocking..\n");
+		gaim_debug_info(WINPREFS_PLUGIN_ID, "Blist Undocking...\n");
 		if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_ALWAYS)
 			blist_set_ontop(TRUE);
 		else
@@ -150,6 +151,34 @@
 	blist_set_dockable(FALSE);
 }
 
+/* Listen for the first time the window stops being withdrawn */
+static void blist_visible_cb(const char *pref, GaimPrefType type,
+		gconstpointer value, gpointer user_data) {
+	if(gaim_prefs_get_bool(pref)) {
+		gtk_appbar_dock(blist_ab,
+			gaim_prefs_get_int(PREF_DBLIST_SIDE));
+
+		if(gaim_prefs_get_int(PREF_BLIST_ON_TOP)
+				== BLIST_TOP_DOCKED)
+			blist_set_ontop(TRUE);
+
+		/* We only need to be notified about this once */
+		gaim_prefs_disconnect_callback(blist_visible_cb_id);
+	}
+}
+
+/* This needs to be delayed otherwise, when the blist is originally created and
+ * hidden, it'll trigger the blist_visible_cb */
+static gboolean listen_for_blist_visible_cb(gpointer data) {
+	if (handle != NULL)
+		blist_visible_cb_id =
+			gaim_prefs_connect_callback(handle,
+				"/gaim/gtk/blist/list_visible",
+				blist_visible_cb, NULL);
+
+	return FALSE;
+}
+
 static void blist_create_cb(GaimBuddyList *gaim_blist, void *data) {
 	gaim_debug_info(WINPREFS_PLUGIN_ID, "buddy list created\n");
 
@@ -159,10 +188,16 @@
 		blist_set_dockable(TRUE);
 		if(gaim_prefs_get_bool(PREF_DBLIST_DOCKED)) {
 			blist_ab->undocked_height = gaim_prefs_get_int(PREF_DBLIST_HEIGHT);
-			gtk_appbar_dock(blist_ab,
-				gaim_prefs_get_int(PREF_DBLIST_SIDE));
-			if(gaim_prefs_get_int(PREF_BLIST_ON_TOP) == BLIST_TOP_DOCKED)
-				blist_set_ontop(TRUE);
+			if(!(gdk_window_get_state(blist->window)
+					& GDK_WINDOW_STATE_WITHDRAWN)) {
+				gtk_appbar_dock(blist_ab,
+					gaim_prefs_get_int(PREF_DBLIST_SIDE));
+				if(gaim_prefs_get_int(PREF_BLIST_ON_TOP)
+						== BLIST_TOP_DOCKED)
+					blist_set_ontop(TRUE);
+			} else {
+				g_idle_add(listen_for_blist_visible_cb, NULL);
+			}
 		}
 	}
 
@@ -374,6 +409,8 @@
 	blist_set_dockable(FALSE);
 	blist_set_ontop(FALSE);
 
+	handle = NULL;
+
 	return TRUE;
 }
 

mercurial