gui: Teach playlists about the f key

This key is used to add songs to the "favorites" playlist.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-02-07 20:57:15 -05:00 committed by Anna Schumaker
parent b161048f7f
commit 2957ea01d4
1 changed files with 19 additions and 1 deletions

View File

@ -330,6 +330,7 @@ public:
void on_page_renumbered();
bool on_add_to_pq(unsigned int);
bool on_delete_selected();
bool on_favorite_selected();
bool on_view_key_pressed(GdkEventKey *);
void on_sidebar_cursor_changed();
bool on_sidebar_clicked(GdkEventButton *);
@ -686,6 +687,21 @@ bool OcarinaPage::on_delete_selected()
return true;
}
bool OcarinaPage::on_favorite_selected()
{
Glib::RefPtr<Gtk::TreeSelection> sel = page_view.get_selection();
if (sel->count_selected_rows() == 0)
return true;
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 id = model->path_to_id(filter->convert_path_to_child_path(*it));
playlist :: add("Favorites", id);
}
return true;
}
bool OcarinaPage::on_view_key_pressed(GdkEventKey *event)
{
std::string key = gdk_keyval_name(event->keyval);
@ -698,7 +714,9 @@ 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")
} else if (key == "f")
return on_favorite_selected();
else if (key == "Delete")
return on_delete_selected();
return false;
}