gui: Playlists respond to the delete key

This key is used to remove tracks from a playlist.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-02-28 20:07:59 -05:00 committed by Anna Schumaker
parent 6c8ef37b2a
commit 463409acdf
1 changed files with 24 additions and 3 deletions

View File

@ -5,6 +5,8 @@
#include <tabs.h>
static const std::string current_playlist();
/**
* Playlist tab stuff
*/
@ -13,6 +15,7 @@ class PlaylistTab : public Tab {
public:
PlaylistTab();
~PlaylistTab();
bool on_key_press_event(const std::string &);
};
@ -31,6 +34,19 @@ PlaylistTab :: ~PlaylistTab()
tab_unmap();
}
bool PlaylistTab :: on_key_press_event(const std::string &key)
{
std::vector<unsigned int> ids;
if (key != "Delete")
return Tab :: on_key_press_event(key);
tab_selected_ids(ids);
for (unsigned int i = 0; i < ids.size(); i++)
playlist :: del(current_playlist(), ids[i]);
return true;
}
/**
@ -48,8 +64,7 @@ public:
static Glib::RefPtr<Gtk::ListStore> playlist_ls;
static Gtk::TreeView *playlist_tv;
static void on_playlist_cursor_changed()
static const std::string current_playlist()
{
Gtk::TreePath path;
Gtk::TreeViewColumn *col;
@ -57,7 +72,13 @@ static void on_playlist_cursor_changed()
Gtk::TreeModel::Row row = *(playlist_ls->get_iter(path));
std::string res = row[plist_cols.plist_col_name];
playlist::select(res);
return res;
}
static void on_playlist_cursor_changed()
{
playlist::select(current_playlist());
}
static bool on_playlist_clicked(GdkEventButton *button)