ocarina: Adjust scroling with j and k

When scrolling I think it's important to show a few rows that are coming
up next so users know they can stop scrolling and not need to reverse.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-11-08 08:11:19 -05:00
parent 5e456ad64c
commit 1205a94aa7
1 changed files with 25 additions and 8 deletions

View File

@ -150,22 +150,39 @@ static void track_selected(GtkWidget *treeview, GtkTreePath *path,
track->load(true);
}
static void move_cursor(GtkTreeView *treeview, const string &key)
static void do_tree_path_prev(GtkTreePath *path)
{
GtkTreePath *path;
gtk_tree_path_prev(path);
}
static void do_move_cursor(GtkTreeView *treeview, void path_next(GtkTreePath *))
{
GtkTreePath *path, *scroll;
gtk_widget_grab_focus(GTK_WIDGET(treeview));
gtk_tree_view_get_cursor(treeview, &path, NULL);
if (path == NULL)
return;
if (key == "j")
gtk_tree_path_next(path);
else
gtk_tree_path_prev(path);
if (path)
gtk_tree_view_set_cursor(treeview, path, NULL, FALSE);
path_next(path);
scroll = gtk_tree_path_copy(path);
for (unsigned int i = 0; i < 2; i++)
path_next(scroll);
gtk_tree_view_scroll_to_cell(treeview, scroll, NULL, FALSE, 0, 0);
gtk_tree_view_set_cursor(treeview, path, NULL, FALSE);
gtk_tree_path_free(path);
gtk_tree_path_free(scroll);
}
static void move_cursor(GtkTreeView *treeview, const string &key)
{
if (key == "j")
do_move_cursor(treeview, gtk_tree_path_next);
else
do_move_cursor(treeview, do_tree_path_prev);
}
static void selected_foreach_list(GtkTreeModel *model, GtkTreePath *path,