changeset 16105:1983ecd15174

Remember the collapsed state of groups in the blist
author Richard Nelson <wabz@pidgin.im>
date Sat, 14 Apr 2007 12:39:33 +0000
parents f0f9d94928ee
children b73761ac005e
files finch/gntblist.c finch/libgnt/genmarshal finch/libgnt/gnttree.c
diffstat 3 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/finch/gntblist.c	Sat Apr 14 12:38:31 2007 +0000
+++ b/finch/gntblist.c	Sat Apr 14 12:39:33 2007 +0000
@@ -446,6 +446,8 @@
 		return;
 	node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group,
 			gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), NULL, NULL);
+	gnt_tree_set_expanded(GNT_TREE(ggblist->tree), node,
+		!purple_blist_node_get_bool(node, "collapsed"));
 }
 
 static const char *
@@ -2105,6 +2107,12 @@
 }
 
 static void
+group_collapsed(GntWidget *widget, PurpleBlistNode *node, gboolean collapsed, gpointer null)
+{
+	purple_blist_node_set_bool(node, "collapsed", collapsed);
+}
+
+static void
 blist_show(PurpleBuddyList *list)
 {
 	if (ggblist == NULL)
@@ -2171,6 +2179,7 @@
 	g_signal_connect(G_OBJECT(ggblist->tree), "selection_changed", G_CALLBACK(selection_changed), ggblist);
 	g_signal_connect(G_OBJECT(ggblist->tree), "key_pressed", G_CALLBACK(key_pressed), ggblist);
 	g_signal_connect(G_OBJECT(ggblist->tree), "context-menu", G_CALLBACK(context_menu), ggblist);
+	g_signal_connect(G_OBJECT(ggblist->tree), "collapse-toggled", G_CALLBACK(group_collapsed), NULL);
 	g_signal_connect_after(G_OBJECT(ggblist->tree), "clicked", G_CALLBACK(blist_clicked), ggblist);
 	g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist);
 	g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip),
--- a/finch/libgnt/genmarshal	Sat Apr 14 12:38:31 2007 +0000
+++ b/finch/libgnt/genmarshal	Sat Apr 14 12:39:33 2007 +0000
@@ -8,3 +8,4 @@
 BOOLEAN:POINTER,POINTER,POINTER
 BOOLEAN:INT,INT,INT,POINTER
 VOID:STRING,STRING
+VOID:POINTER,BOOLEAN
--- a/finch/libgnt/gnttree.c	Sat Apr 14 12:38:31 2007 +0000
+++ b/finch/libgnt/gnttree.c	Sat Apr 14 12:39:33 2007 +0000
@@ -13,6 +13,7 @@
 	SIG_SELECTION_CHANGED,
 	SIG_SCROLLED,
 	SIG_TOGGLED,
+	SIG_COLLAPSED,
 	SIGS,
 };
 
@@ -702,6 +703,7 @@
 		{
 			row->collapsed = !row->collapsed;
 			redraw_tree(tree);
+			g_signal_emit(tree, signals[SIG_COLLAPSED], 0, row->key, row->collapsed);
 		}
 		else if (row && row->choice)
 		{
@@ -855,6 +857,14 @@
 					 NULL, NULL,
 					 g_cclosure_marshal_VOID__POINTER,
 					 G_TYPE_NONE, 1, G_TYPE_POINTER);
+	signals[SIG_COLLAPSED] = 
+		g_signal_new("collapse-toggled",
+					 G_TYPE_FROM_CLASS(klass),
+					 G_SIGNAL_RUN_LAST,
+					 0,
+					 NULL, NULL,
+					 gnt_closure_marshal_VOID__POINTER_BOOLEAN,
+					 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_BOOLEAN);
 
 	gnt_bindable_class_register_action(bindable, "move-up", action_up,
 				GNT_KEY_UP, NULL);