qulogic/libgnt

5e7b8abe05a0
move-start (home) and move-last (end) actions for trees.
  • +43 -0
    gnttree.c
  • --- a/gnttree.c Thu Jan 28 17:44:28 2010 +0000
    +++ b/gnttree.c Wed Feb 03 16:05:28 2010 +0000
    @@ -957,6 +957,45 @@
    return TRUE;
    }
    +static gboolean
    +move_first_action(GntBindable *bind, GList *null)
    +{
    + GntTree *tree = GNT_TREE(bind);
    + GntTreeRow *row = tree->root;
    + GntTreeRow *old = tree->current;
    + if (row && !row_matches_search(row))
    + row = get_next(row);
    + if (row) {
    + tree->current = row;
    + redraw_tree(tree);
    + if (old != tree->current)
    + tree_selection_changed(tree, old, tree->current);
    + }
    +
    + return TRUE;
    +}
    +
    +static gboolean
    +move_last_action(GntBindable *bind, GList *null)
    +{
    + GntTree *tree = GNT_TREE(bind);
    + GntTreeRow *old = tree->current;
    + GntTreeRow *row = tree->bottom;
    + GntTreeRow *next;
    +
    + while ((next = get_next(row)))
    + row = next;
    +
    + if (row) {
    + tree->current = row;
    + redraw_tree(tree);
    + if (old != tree->current)
    + tree_selection_changed(tree, old, tree->current);
    + }
    +
    + return TRUE;
    +}
    +
    static void
    gnt_tree_set_property(GObject *obj, guint prop_id, const GValue *value,
    GParamSpec *spec)
    @@ -1076,6 +1115,10 @@
    "/", NULL);
    gnt_bindable_class_register_action(bindable, "end-search", end_search_action,
    "\033", NULL);
    + gnt_bindable_class_register_action(bindable, "move-first", move_first_action,
    + GNT_KEY_HOME, NULL);
    + gnt_bindable_class_register_action(bindable, "move-last", move_last_action,
    + GNT_KEY_END, NULL);
    gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable);
    GNTDEBUG;