comparison finch/libgnt/gnttree.c @ 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 1983ecd15174
comparison
equal deleted inserted replaced
15971:05d347516fcd 15972:5eb0621e0760
561 gnt_tree_scroll(tree, -dist); 561 gnt_tree_scroll(tree, -dist);
562 else 562 else
563 redraw_tree(tree); 563 redraw_tree(tree);
564 if (old != tree->current) 564 if (old != tree->current)
565 tree_selection_changed(tree, old, tree->current); 565 tree_selection_changed(tree, old, tree->current);
566 return TRUE;
567 }
568
569 static gboolean
570 action_move_parent(GntBindable *bind, GList *null)
571 {
572 GntTree *tree = GNT_TREE(bind);
573 GntTreeRow *row = tree->current;
574 if (row->parent) {
575 int dist;
576 tree->current = row->parent;
577 if ((dist = get_distance(tree->current, tree->top)) > 0)
578 gnt_tree_scroll(tree, -dist);
579 else
580 redraw_tree(tree);
581 tree_selection_changed(tree, row, tree->current);
582 }
566 return TRUE; 583 return TRUE;
567 } 584 }
568 585
569 static gboolean 586 static gboolean
570 action_up(GntBindable *bind, GList *list) 587 action_up(GntBindable *bind, GList *list)
843 GNT_KEY_UP, NULL); 860 GNT_KEY_UP, NULL);
844 gnt_bindable_register_binding(bindable, "move-up", GNT_KEY_CTRL_P, NULL); 861 gnt_bindable_register_binding(bindable, "move-up", GNT_KEY_CTRL_P, NULL);
845 gnt_bindable_class_register_action(bindable, "move-down", action_down, 862 gnt_bindable_class_register_action(bindable, "move-down", action_down,
846 GNT_KEY_DOWN, NULL); 863 GNT_KEY_DOWN, NULL);
847 gnt_bindable_register_binding(bindable, "move-down", GNT_KEY_CTRL_N, NULL); 864 gnt_bindable_register_binding(bindable, "move-down", GNT_KEY_CTRL_N, NULL);
865 gnt_bindable_class_register_action(bindable, "move-parent", action_move_parent,
866 GNT_KEY_BACKSPACE, NULL);
848 gnt_bindable_class_register_action(bindable, "page-up", action_page_up, 867 gnt_bindable_class_register_action(bindable, "page-up", action_page_up,
849 GNT_KEY_PGUP, NULL); 868 GNT_KEY_PGUP, NULL);
850 gnt_bindable_class_register_action(bindable, "page-down", action_page_down, 869 gnt_bindable_class_register_action(bindable, "page-down", action_page_down,
851 GNT_KEY_PGDOWN, NULL); 870 GNT_KEY_PGDOWN, NULL);
852 gnt_bindable_class_register_action(bindable, "start-search", start_search, 871 gnt_bindable_class_register_action(bindable, "start-search", start_search,
1504 for (i = 0, iter = row->columns; iter; iter = iter->next, i++) { 1523 for (i = 0, iter = row->columns; iter; iter = iter->next, i++) {
1505 GntTreeCol *col = iter->data; 1524 GntTreeCol *col = iter->data;
1506 int w = gnt_util_onscreen_width(col->text, NULL); 1525 int w = gnt_util_onscreen_width(col->text, NULL);
1507 if (i == 0 && row->choice) 1526 if (i == 0 && row->choice)
1508 w += 4; 1527 w += 4;
1528 if (i == 0) {
1529 w += find_depth(row) * TAB_SIZE;
1530 }
1509 if (widths[i] < w) 1531 if (widths[i] < w)
1510 widths[i] = w; 1532 widths[i] = w;
1511 } 1533 }
1512 row = row->next; 1534 row = get_next(row);
1513 } 1535 }
1514 1536
1515 twidth = 1 + 2 * (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER)); 1537 twidth = 1 + 2 * (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER));
1516 for (i = 0; i < tree->ncol; i++) { 1538 for (i = 0; i < tree->ncol; i++) {
1517 gnt_tree_set_col_width(tree, i, widths[i]); 1539 gnt_tree_set_col_width(tree, i, widths[i]);