changeset 15972:5eb0621e0760

Backspace to jump to parent.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 01 Apr 2007 03:46:58 +0000
parents 05d347516fcd
children 499ed587543a
files finch/libgnt/gnttree.c
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gnttree.c	Fri Mar 30 06:47:54 2007 +0000
+++ b/finch/libgnt/gnttree.c	Sun Apr 01 03:46:58 2007 +0000
@@ -567,6 +567,23 @@
 }
 
 static gboolean
+action_move_parent(GntBindable *bind, GList *null)
+{
+	GntTree *tree = GNT_TREE(bind);
+	GntTreeRow *row = tree->current;
+	if (row->parent) {
+		int dist;
+		tree->current = row->parent;
+		if ((dist = get_distance(tree->current, tree->top)) > 0)
+			gnt_tree_scroll(tree, -dist);
+		else
+			redraw_tree(tree);
+		tree_selection_changed(tree, row, tree->current);
+	}
+	return TRUE;
+}
+
+static gboolean
 action_up(GntBindable *bind, GList *list)
 {
 	int dist;
@@ -845,6 +862,8 @@
 	gnt_bindable_class_register_action(bindable, "move-down", action_down,
 				GNT_KEY_DOWN, NULL);
 	gnt_bindable_register_binding(bindable, "move-down", GNT_KEY_CTRL_N, NULL);
+	gnt_bindable_class_register_action(bindable, "move-parent", action_move_parent,
+				GNT_KEY_BACKSPACE, NULL);
 	gnt_bindable_class_register_action(bindable, "page-up", action_page_up,
 				GNT_KEY_PGUP, NULL);
 	gnt_bindable_class_register_action(bindable, "page-down", action_page_down,
@@ -1506,10 +1525,13 @@
 			int w = gnt_util_onscreen_width(col->text, NULL);
 			if (i == 0 && row->choice)
 				w += 4;
+			if (i == 0) {
+				w += find_depth(row) * TAB_SIZE;
+			}
 			if (widths[i] < w)
 				widths[i] = w;
 		}
-		row = row->next;
+		row = get_next(row);
 	}
 
 	twidth = 1 + 2 * (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER));