ocarina: Activate treeview rows when pressing enter
I already use "Return" for focusing the treeview from the main window or from the filter entry. If the treeview is already focused, I have it begin playing whatever song is under the cursor. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
50b4198001
commit
88ea380f9c
|
@ -211,6 +211,14 @@ static void on_escape_key(GtkTreeView *treeview)
|
|||
gtk_tree_selection_unselect_all(selection);
|
||||
}
|
||||
|
||||
static void on_return_key(GtkTreeView *treeview)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gtk_tree_view_get_cursor(treeview, &path, NULL);
|
||||
gtk_tree_view_row_activated(treeview, path, NULL);
|
||||
gtk_tree_path_free(path);
|
||||
}
|
||||
|
||||
static gboolean key_pressed(GtkTreeView *treeview, GdkEvent *event, gpointer data)
|
||||
{
|
||||
string key = gdk_keyval_name(event->key.keyval);
|
||||
|
@ -226,6 +234,8 @@ static gboolean key_pressed(GtkTreeView *treeview, GdkEvent *event, gpointer dat
|
|||
new_playlist(key, treeview, true);
|
||||
else if (key >= "0" && key <= "9")
|
||||
add_to_playlist(treeview, atoi(key.c_str()));
|
||||
else if (key == "Return")
|
||||
on_return_key(treeview);
|
||||
else if (key == "Escape")
|
||||
on_escape_key(treeview);
|
||||
else
|
||||
|
|
|
@ -80,9 +80,11 @@ static gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
playlist_focus_entry();
|
||||
else if (key == "space")
|
||||
libsaria::audio::toggle_play();
|
||||
else if (key == "Return")
|
||||
else if (key == "Return") {
|
||||
if (playlist_treeview_focused())
|
||||
return FALSE;
|
||||
playlist_focus_treeview();
|
||||
else {
|
||||
} else {
|
||||
//println("Unhandled key: " + key);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue