gui: Add basic keyboard shortcuts
n: play the next song N: play the previous song spacebar: play or pause Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
e8d63a15cf
commit
1e4faeaff0
|
@ -96,6 +96,41 @@ static void on_pause_count_changed(bool enabled, unsigned int count)
|
|||
|
||||
|
||||
|
||||
/*
|
||||
* Keyboard shortcuts
|
||||
*/
|
||||
static bool on_window_key_pressed(GdkEventKey *event)
|
||||
{
|
||||
Gtk::Window *window;
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
builder->get_widget("o_window", window);
|
||||
|
||||
if (key == "Escape")
|
||||
window->set_focus(*window);
|
||||
else if (key == "n")
|
||||
on_next();
|
||||
else if (key == "N")
|
||||
audio :: previous();
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool on_window_key_released(GdkEventKey *event)
|
||||
{
|
||||
Gtk::Window *window;
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
builder->get_widget("o_window", window);
|
||||
|
||||
if (key == "space")
|
||||
audio :: toggle_play();
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Collection manager functions
|
||||
*/
|
||||
|
@ -331,6 +366,12 @@ Gtk::Window *connect_wires()
|
|||
connect_button("o_next", on_next);
|
||||
|
||||
|
||||
/* Keyboard shortcuts */
|
||||
window->signal_key_press_event().connect(sigc::ptr_fun(on_window_key_pressed));
|
||||
window->signal_key_release_event().connect(sigc::ptr_fun(on_window_key_released));
|
||||
window->set_can_focus();
|
||||
|
||||
|
||||
/* Collection manager */
|
||||
cb->on_library_add = on_library_add;
|
||||
cb->on_library_update = on_library_update;
|
||||
|
|
Loading…
Reference in New Issue