From 8e02001373c5e8217c6a0f501491433459df7075 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 6 Jan 2016 10:27:28 -0500 Subject: [PATCH] gui/queue: Stop space bar from selecting new tracks From Josh: Single-clicking a track in the collection queue and pressing the space bar loads the selected track, but users would expect this to toggle the play / pause state instead. The solution is to watch for the on_key_press signal and tell GTK that we have handled it if we see that the space bar was pressed. Signed-off-by: Anna Schumaker --- gui/queue/window.cpp | 10 ++++++++++ include/gui/queue/window.h | 1 + 2 files changed, 11 insertions(+) diff --git a/gui/queue/window.cpp b/gui/queue/window.cpp index c38e68d7..576316cc 100644 --- a/gui/queue/window.cpp +++ b/gui/queue/window.cpp @@ -27,6 +27,8 @@ void QueueWindow :: init(Queue *queue) q_treeview->signal_row_activated().connect(sigc::mem_fun(*this, &QueueWindow :: on_row_activated)); + q_treeview->signal_key_press_event().connect(sigc::mem_fun(*this, + &QueueWindow :: on_key_press), false); q_treeview->set_model(q_filter); } @@ -49,6 +51,14 @@ bool QueueWindow :: filter_ids(const Gtk::TreeIter &iter) return set_has(&_q_search_res, _queue->operator[](id)->dbe_index); } +bool QueueWindow :: on_key_press(GdkEventKey *event) +{ + std::string key = gdk_keyval_name(event->keyval); + if (key == "space") + return true; + return false; +} + void QueueWindow :: on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) { diff --git a/include/gui/queue/window.h b/include/gui/queue/window.h index 2a255d47..d2f20004 100644 --- a/include/gui/queue/window.h +++ b/include/gui/queue/window.h @@ -30,6 +30,7 @@ public: void filter(std::string &); bool filter_ids(const Gtk::TreeIter &); + bool on_key_press(GdkEventKey *); void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *); };