ocarina: Respond to "Return" as a shortcut
I think it'll be useful to change focus to the current treeview through a shortcut. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
694bcb83d7
commit
e6c44bf1a9
|
@ -31,6 +31,7 @@ void init_window();
|
|||
/* playlist.cpp */
|
||||
bool playlist_entry_focused();
|
||||
void playlist_focus_entry();
|
||||
void playlist_focus_treeview();
|
||||
void playlist_switch_to(string &);
|
||||
void update_playlist(notify_t, libsaria::PlaylistNotification *);
|
||||
void init_playlist();
|
||||
|
|
|
@ -15,6 +15,7 @@ using namespace std;
|
|||
struct PlaylistWidgets {
|
||||
libsaria::Playlist *playlist;
|
||||
GtkListStore *liststore;
|
||||
GtkTreeView *treeview;
|
||||
GtkTreeModel *filter;
|
||||
GtkLabel *label;
|
||||
GtkEntry *entry;
|
||||
|
@ -133,6 +134,11 @@ void playlist_focus_entry()
|
|||
gtk_widget_grab_focus(GTK_WIDGET(current_widgets()->entry));
|
||||
}
|
||||
|
||||
void playlist_focus_treeview()
|
||||
{
|
||||
gtk_widget_grab_focus(GTK_WIDGET(current_widgets()->treeview));
|
||||
}
|
||||
|
||||
static void track_selected(GtkWidget *treeview, GtkTreePath *path,
|
||||
GtkTreeViewColumn *col, gpointer data)
|
||||
{
|
||||
|
@ -249,13 +255,13 @@ static void init_playlist_tab(struct PlaylistWidgets *widgets,
|
|||
{
|
||||
widgets->playlist = playlist;
|
||||
widgets->liststore = GTK_LIST_STORE(get_object(list_name));
|
||||
widgets->treeview = GTK_TREE_VIEW(get_widget(view_name));
|
||||
widgets->filter = gtk_tree_model_filter_new(
|
||||
GTK_TREE_MODEL(widgets->liststore), NULL);
|
||||
widgets->label = GTK_LABEL(get_widget(label_name));
|
||||
widgets->entry = GTK_ENTRY(get_widget(entry_name));
|
||||
|
||||
gtk_tree_view_set_model(GTK_TREE_VIEW(get_widget(view_name)),
|
||||
GTK_TREE_MODEL(widgets->filter));
|
||||
gtk_tree_view_set_model(widgets->treeview, widgets->filter);
|
||||
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(widgets->filter),
|
||||
is_visible, playlist, NULL);
|
||||
|
||||
|
|
|
@ -57,6 +57,11 @@ static gboolean key_pressed(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
if (playlist_entry_focused())
|
||||
return FALSE;
|
||||
|
||||
/*
|
||||
* TODO: 'j' and 'k' for treeview navigation,
|
||||
* something for banning / unbanning songs
|
||||
* something for incrementing / decrementing the pause after N count
|
||||
*/
|
||||
if (key == "b" || key == "l" || key == "r")
|
||||
playlist_switch_to(key);
|
||||
else if (key == "n")
|
||||
|
@ -67,6 +72,8 @@ 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")
|
||||
playlist_focus_treeview();
|
||||
else {
|
||||
println("Unhandled key: " + key);
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in New Issue