gui: Use number keys to add tracks to a queue

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-02-28 16:31:36 -05:00 committed by Anna Schumaker
parent 196088dcfa
commit f0006873b6
2 changed files with 26 additions and 32 deletions

View File

@ -123,7 +123,28 @@ bool Tab :: tab_queue_selected(bool random)
Playqueue *pq = deck :: create(random);
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
for (unsigned int i = 0; i != rows.size(); i++) {
for (unsigned int i = 0; i < rows.size(); i++) {
Gtk::TreeModel::Path path = tab_filter->convert_path_to_child_path(rows[i]);
unsigned int track_id = tab_model->path_to_id(path);
pq->add(track_id);
}
sel->unselect_all();
return true;
}
bool Tab :: tab_add_to_queue(unsigned int n)
{
Glib::RefPtr<Gtk::TreeSelection> sel = tab_treeview->get_selection();
if (sel->count_selected_rows() == 0)
return false;
if (n >= deck :: size())
return false;
Playqueue *pq = deck :: get(n);
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
for (unsigned int i = 0; i < rows.size(); i++) {
Gtk::TreeModel::Path path = tab_filter->convert_path_to_child_path(rows[i]);
unsigned int track_id = tab_model->path_to_id(path);
pq->add(track_id);
@ -165,7 +186,9 @@ void Tab :: on_track_changed(unsigned int row)
bool Tab :: on_key_press_event(const std::string &key)
{
if (key == "q" || key == "r")
if (key >= "0" && key <= "9")
return tab_add_to_queue(atoi(key.c_str()));
else if (key == "q" || key == "r")
return tab_queue_selected(key == "r");
else
return false;
@ -520,25 +543,6 @@ void OcarinaPage::on_column_clicked(unsigned int col_index)
sigc::ptr_fun(dec_sort_timeout), 2);
}
bool OcarinaPage::on_add_to_pq(unsigned int n)
{
if (n >= deck :: size())
return true;
Glib::RefPtr<Gtk::TreeSelection> sel = page_view.get_selection();
if (sel->count_selected_rows() == 0)
return true;
Playqueue *pq = deck :: get(n);
std::vector<Gtk::TreeModel::Path>::iterator it;
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
for (it = rows.begin(); it != rows.end(); it++) {
unsigned int track_id = model->path_to_id(filter->convert_path_to_child_path(*it));
pq->add(track_id);
}
return true;
}
bool OcarinaPage::on_delete_selected()
{
Glib::RefPtr<Gtk::TreeSelection> sel = page_view.get_selection();
@ -610,17 +614,6 @@ bool OcarinaPage::on_view_button_pressed(GdkEventButton *button)
* Do stuff with tabs
*/
/*
static void on_add_to_queue(unsigned int num)
{
std::map<Playqueue *, OcarinaPage *>::iterator it;
for (it = tab_map.begin(); it != tab_map.end(); it++) {
if (it->second->is_current_tab()) {
it->second->on_add_to_pq(num);
return;
}
}
}
static void init_menu_item(const std::string &name, unsigned int num)
{
Glib::RefPtr<Gtk::MenuItem>menu = Glib::RefPtr<Gtk::MenuItem>::cast_static(get_builder()->get_object(name));

View File

@ -55,6 +55,7 @@ public:
void tab_runtime_changed();
void tab_focus_search();
bool tab_queue_selected(bool);
bool tab_add_to_queue(unsigned int);
/**
* internal callback functions that can be overridden if necessary