gui: Teach playqueues about the delete key
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
7d7c83c222
commit
b161048f7f
22
gui/tabs.cpp
22
gui/tabs.cpp
|
@ -329,6 +329,7 @@ public:
|
|||
bool on_filter_visible(const Gtk::TreeIter &);
|
||||
void on_page_renumbered();
|
||||
bool on_add_to_pq(unsigned int);
|
||||
bool on_delete_selected();
|
||||
bool on_view_key_pressed(GdkEventKey *);
|
||||
void on_sidebar_cursor_changed();
|
||||
bool on_sidebar_clicked(GdkEventButton *);
|
||||
|
@ -667,6 +668,24 @@ bool OcarinaPage::on_add_to_pq(unsigned int n)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool OcarinaPage::on_delete_selected()
|
||||
{
|
||||
Glib::RefPtr<Gtk::TreeSelection> sel = page_view.get_selection();
|
||||
if (sel->count_selected_rows() == 0)
|
||||
return true;
|
||||
|
||||
if ((unsigned int)notebook->page_num(*this) >= deck :: size())
|
||||
return true;
|
||||
|
||||
std::vector<Gtk::TreeModel::Path>::reverse_iterator it;
|
||||
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
|
||||
for (it = rows.rbegin(); it != rows.rend(); it++) {
|
||||
unsigned int id = filter->convert_path_to_child_path(*it)[0];
|
||||
model->queue->del(id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OcarinaPage::on_view_key_pressed(GdkEventKey *event)
|
||||
{
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
|
@ -679,7 +698,8 @@ bool OcarinaPage::on_view_key_pressed(GdkEventKey *event)
|
|||
if (key >= "0" && key <= "9") {
|
||||
unsigned int n = atoi(key.c_str());
|
||||
return on_add_to_pq(n);
|
||||
}
|
||||
} else if (key == "Delete")
|
||||
return on_delete_selected();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue