ocarina: Use j and k for treeview navigation
This makes me even more vim-like! Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
9b996a7bb1
commit
ab2ba772fe
|
@ -133,6 +133,18 @@ static void track_selected(GtkWidget *treeview, GtkTreePath *path,
|
|||
track->load(true);
|
||||
}
|
||||
|
||||
static void goto_next_row(GtkTreeView *treeview, bool next)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gtk_tree_view_get_cursor(treeview, &path, NULL);
|
||||
if (next)
|
||||
gtk_tree_path_next(path);
|
||||
else
|
||||
gtk_tree_path_prev(path);
|
||||
gtk_tree_view_set_cursor(treeview, path, NULL, FALSE);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
static void selected_foreach_list(GtkTreeModel *model, GtkTreePath *path,
|
||||
GtkTreeIter *iter, gpointer data)
|
||||
{
|
||||
|
@ -189,6 +201,8 @@ static gboolean key_pressed(GtkTreeView *treeview, GdkEvent *event, gpointer dat
|
|||
if (key.substr(0, 3) == "KP_")
|
||||
key = key.substr(3);
|
||||
|
||||
if (key == "j" || key == "k")
|
||||
goto_next_row(treeview, key == "j");
|
||||
if (key == "s" || key == "q")
|
||||
new_playlist(key, treeview, false);
|
||||
else if (key == "S" || key == "Q")
|
||||
|
|
|
@ -114,7 +114,13 @@ bool playlist_treeview_focused()
|
|||
|
||||
void playlist_focus_treeview()
|
||||
{
|
||||
gtk_widget_grab_focus(GTK_WIDGET(current_widgets()->treeview));
|
||||
GtkTreePath *path;
|
||||
GtkTreeView *treeview = current_widgets()->treeview;
|
||||
|
||||
gtk_widget_grab_focus(GTK_WIDGET(treeview));
|
||||
gtk_tree_view_get_cursor(treeview, &path, NULL);
|
||||
gtk_tree_view_set_cursor(treeview, path, NULL, FALSE);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
static void on_switch_page(GtkNotebook *tabs, gpointer page,
|
||||
|
|
|
@ -63,8 +63,7 @@ static gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
key = key.substr(3);
|
||||
|
||||
/*
|
||||
* TODO: 'j' and 'k' for treeview navigation,
|
||||
* something for banning / unbanning songs
|
||||
* TODO: something for banning / unbanning songs
|
||||
* something for incrementing / decrementing the pause after N count
|
||||
*/
|
||||
if (key == "b" || key == "l" || key == "r")
|
||||
|
|
Loading…
Reference in New Issue