diff pidgin/gtkscrollbook.c @ 21583:21cbdaf265f6

This fixes the problem where all accounts are disabled due to connection errors, which leaves you with no enabled accounts, and therefore the buddy list flips into "Welcome to Pidgin!" mode, thereby hiding all the connection error mini dialogs. I'm amazed I haven't heard any noise about this problem. I attempted to fix up PidginScrollBook, and got part way there, but gtk_container_get_children now doesn't return any kids. I suspect this is due to the child widgets we care about already being children of the notebook. I don't know nearly enough gtk to be sure if this is good or not. There are still some buglets in how/when the buddy list notebook page is selected, and I have a feeling some of the gtkblist.c changes could be improved, but I believe this is more usable than before. This took far too much time. References #3989
author Stu Tomlinson <stu@nosnilmot.com>
date Sun, 18 Nov 2007 21:03:29 +0000
parents 6bf32c9e15a7
children fa5d1f426332
line wrap: on
line diff
--- a/pidgin/gtkscrollbook.c	Sun Nov 18 17:34:39 2007 +0000
+++ b/pidgin/gtkscrollbook.c	Sun Nov 18 21:03:29 2007 +0000
@@ -146,21 +146,74 @@
 static void
 pidgin_scroll_book_add(GtkContainer *container, GtkWidget *widget)
 {
+	GList *children;
+	PidginScrollBook *scroll_book;
+
+	g_return_if_fail(GTK_IS_WIDGET (widget));
+	g_return_if_fail (widget->parent == NULL);
+
+	scroll_book = PIDGIN_SCROLL_BOOK(container);
+	children = scroll_book->children;
+	children = g_list_append(children, widget);
 	gtk_widget_show(widget);
 	gtk_notebook_append_page(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), widget, NULL);
 	page_count_change_cb(PIDGIN_SCROLL_BOOK(container));
 }
 
 static void
+pidgin_scroll_book_remove(GtkContainer *container, GtkWidget *widget)
+{
+	int page;
+	GList *children;
+	GtkWidget *child;
+	PidginScrollBook *scroll_book;
+	g_return_if_fail(GTK_IS_WIDGET(widget));
+
+	scroll_book = PIDGIN_SCROLL_BOOK(container);
+	children = scroll_book->children;
+
+	while (children) {
+		child = children->data;
+		if (child == widget) {
+			gtk_widget_unparent (widget);
+			children = g_list_remove_link (scroll_book->children, children);
+			g_list_free(children);
+			break;
+		}
+	}
+
+	page = gtk_notebook_page_num(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), widget);
+	if (page >= 0) {
+		gtk_notebook_remove_page(GTK_NOTEBOOK(PIDGIN_SCROLL_BOOK(container)->notebook), page);
+	}
+}
+
+static void
 pidgin_scroll_book_forall(GtkContainer *container,
 			   gboolean include_internals,
 			   GtkCallback callback,
 			   gpointer callback_data)
 {
-	PidginScrollBook *scroll_book = PIDGIN_SCROLL_BOOK(container);
-	if (include_internals)
+	GList *children;
+	PidginScrollBook *scroll_book;
+
+	g_return_if_fail(GTK_IS_CONTAINER(container));
+
+	scroll_book = PIDGIN_SCROLL_BOOK(container);
+
+	if (include_internals) {
 		(*callback)(scroll_book->hbox, callback_data);
-	(*callback)(scroll_book->notebook, callback_data);
+		(*callback)(scroll_book->notebook, callback_data);
+	}
+
+	children = scroll_book->children;
+
+	while (children) {
+		GtkWidget *child;
+		child = children->data;
+		children = children->next;
+		(*callback)(child, callback_data);
+	}
 }
 
 static void
@@ -169,6 +222,7 @@
 	GtkContainerClass *container_class = (GtkContainerClass*)klass;
 
 	container_class->add = pidgin_scroll_book_add;
+	container_class->remove = pidgin_scroll_book_remove;
 	container_class->forall = pidgin_scroll_book_forall;	
 	
 }