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 <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2016-01-06 10:27:28 -05:00
parent 7e306de007
commit 8e02001373
2 changed files with 11 additions and 0 deletions

View File

@ -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)
{

View File

@ -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 *);
};