changeset 27085:61d817c4c935

Remove the pseudo-row child of expandable services if there are no children. Patch from nops. Refs #556.
author Paul Aurich <paul@darkrain42.org>
date Wed, 03 Jun 2009 04:55:06 +0000
parents b709ab0cb4bc
children 60cb86295f08
files pidgin/plugins/disco/gtkdisco.c pidgin/plugins/disco/xmppdisco.c
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/plugins/disco/gtkdisco.c	Wed Jun 03 04:32:19 2009 +0000
+++ b/pidgin/plugins/disco/gtkdisco.c	Wed Jun 03 04:55:06 2009 +0000
@@ -512,7 +512,10 @@
 	dialog = pdl->dialog;
 	g_return_if_fail(dialog != NULL);
 
-	purple_debug_info("xmppdisco", "Adding service \"%s\"\n", service->name);
+	if (service != NULL)
+		purple_debug_info("xmppdisco", "Adding service \"%s\"\n", service->name);
+	else
+		purple_debug_info("xmppdisco", "Service \"%s\" has no childrens\n", parent->name);
 
 	gtk_progress_bar_pulse(GTK_PROGRESS_BAR(dialog->progress));
 
@@ -537,6 +540,12 @@
 		}
 	}
 
+	if (service == NULL) {
+		if (parent != NULL && !append)
+			gtk_tree_store_remove(pdl->model, &child);
+		return;
+	}
+
 	if (append)
 		gtk_tree_store_append(pdl->model, &iter, (parent ? &parent_iter : NULL));
 	else
--- a/pidgin/plugins/disco/xmppdisco.c	Wed Jun 03 04:32:19 2009 +0000
+++ b/pidgin/plugins/disco/xmppdisco.c	Wed Jun 03 04:55:06 2009 +0000
@@ -348,6 +348,7 @@
 	struct item_data *item_data = data;
 	PidginDiscoList *list = item_data->list;
 	xmlnode *query;
+	gboolean has_items = FALSE;
 
 	--list->fetch_count;
 
@@ -364,6 +365,8 @@
 			const char *name = xmlnode_get_attrib(item, "name");
 			const char *node = xmlnode_get_attrib(item, "node");
 
+			has_items = TRUE;
+
 			if (item_data->parent->type == XMPP_DISCO_SERVICE_TYPE_CHAT) {
 				/* This is a hacky first-order approximation. Any MUC
 				 * component that has a >1 level hierarchy (a Yahoo MUC
@@ -397,6 +400,9 @@
 		}
 	}
 
+	if (!has_items)
+		pidgin_disco_add_service(list, NULL, item_data->parent);
+
 out:
 	if (list->fetch_count == 0)
 		pidgin_disco_list_set_in_progress(list, FALSE);