changeset 27034:b58672890b3f

merge of '051b51aa2424e978f16c10511f7a4e0f45c7c5d3' and '69b3b10f3cd5853b74cace5f7247f384555cbbff'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 05 Jun 2009 04:27:53 +0000
parents 2ab648c328cc (current diff) 005d20d58ac7 (diff)
children 9c36a340fcaf c3fcdd59ab76
files
diffstat 2 files changed, 63 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jun 05 02:30:31 2009 +0000
+++ b/ChangeLog	Fri Jun 05 04:27:53 2009 +0000
@@ -85,6 +85,8 @@
 	* Always set unseen-count and unseen-state on conversations.
 	  (Joshua Stein)
 	* Fix a bug in 'Conversation Colors' plugin for RTL messages.
+	* Pressing the Left and Right arrow keys in the buddy list will expand and
+	  collapse buddy groups or contacts. (Peter Ruibal)
 
 	Finch:
 	* The hardware cursor is updated correctly. This will be useful
--- a/pidgin/gtkblist.c	Fri Jun 05 02:30:31 2009 +0000
+++ b/pidgin/gtkblist.c	Fri Jun 05 04:27:53 2009 +0000
@@ -1611,8 +1611,9 @@
 {
 	PurpleBlistNode *node;
 	GValue val;
-	GtkTreeIter iter;
+	GtkTreeIter iter, parent;
 	GtkTreeSelection *sel;
+	GtkTreePath *path;
 
 	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
 	if(!gtk_tree_selection_get_selected(sel, NULL, &iter))
@@ -1636,8 +1637,62 @@
 		}
 		if(buddy)
 			pidgin_retrieve_user_info(buddy->account->gc, buddy->name);
-	} else if (event->keyval == GDK_F2) {
-		gtk_blist_menu_alias_cb(tv, node);
+	} else {
+		switch (event->keyval) {
+			case GDK_F2:
+				gtk_blist_menu_alias_cb(tv, node);
+				break;
+
+			case GDK_Left:
+				path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
+				if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(tv), path)) {
+					/* Collapse the Group */
+					gtk_tree_view_collapse_row(GTK_TREE_VIEW(tv), path);
+					gtk_tree_path_free(path);
+					return TRUE;
+				} else {
+					/* Select the Parent */
+					if (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path)) {
+						if (gtk_tree_model_iter_parent(GTK_TREE_MODEL(gtkblist->treemodel), &parent, &iter)) {
+							gtk_tree_path_free(path);
+							path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &parent);
+							gtk_tree_view_set_cursor(GTK_TREE_VIEW(tv), path, NULL, FALSE);
+							gtk_tree_path_free(path);
+							return TRUE;
+						}
+					}
+				}
+				gtk_tree_path_free(path);
+				break;
+
+			case GDK_Right:
+				path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
+				if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(tv), path)) {
+					/* Expand the Group */
+					if (PURPLE_BLIST_NODE_IS_CONTACT(node)) {
+						pidgin_blist_expand_contact_cb(NULL, node);
+						gtk_tree_path_free(path);
+						return TRUE;
+					} else if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) {
+						gtk_tree_view_expand_row(GTK_TREE_VIEW(tv), path, FALSE);
+						gtk_tree_path_free(path);
+						return TRUE;
+					}
+				} else {
+					/* Select the First Child */
+					if (gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &parent, path)) {
+						if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(gtkblist->treemodel), &iter, &parent, 0)) {
+							gtk_tree_path_free(path);
+							path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter);
+							gtk_tree_view_set_cursor(GTK_TREE_VIEW(tv), path, NULL, FALSE);
+							gtk_tree_path_free(path);
+							return TRUE;
+						}
+					}
+				}
+				gtk_tree_path_free(path);
+				break;
+		}
 	}
 
 	return FALSE;
@@ -6167,10 +6222,9 @@
 
 	if (count > 0 || purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_empty_groups"))
 		show = TRUE;
-	else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) { /* Or chat? */
-		if (buddy_is_displayable((PurpleBuddy*)node))
-			show = TRUE;
-	} else if (!show_offline && PURPLE_BLIST_NODE_IS_GROUP(node)) {
+	else if (PURPLE_BLIST_NODE_IS_BUDDY(node) && buddy_is_displayable((PurpleBuddy*)node)) { /* Or chat? */
+		show = TRUE;
+	} else if (!show_offline) {
 		show = pidgin_blist_group_has_show_offline_buddy(group);
 	}