gui: Ban tracks with the "delete" key
Press the delete key on the collection tab to ban all selected tracks. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
cb59febd1c
commit
6c8ef37b2a
|
@ -2,6 +2,7 @@
|
|||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <deck.h>
|
||||
#include <playlist.h>
|
||||
#include <tabs.h>
|
||||
|
||||
|
||||
|
@ -10,6 +11,7 @@ public:
|
|||
CollectionTab();
|
||||
~CollectionTab();
|
||||
void on_post_init();
|
||||
bool on_key_press_event(const std::string &);
|
||||
};
|
||||
|
||||
|
||||
|
@ -35,6 +37,20 @@ void CollectionTab :: on_post_init()
|
|||
tab_init_random();
|
||||
}
|
||||
|
||||
bool CollectionTab :: 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 :: add("Banned", ids[i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static CollectionTab *collection_tab;
|
||||
|
|
25
gui/tabs.cpp
25
gui/tabs.cpp
|
@ -139,25 +139,29 @@ void Tab :: tab_focus_search()
|
|||
tab_search->grab_focus();
|
||||
}
|
||||
|
||||
void Tab :: tab_queue_add(Playqueue *pq)
|
||||
void Tab :: tab_selected_ids(std::vector<unsigned int> &ids)
|
||||
{
|
||||
Glib::RefPtr<Gtk::TreeSelection> sel = tab_treeview->get_selection();
|
||||
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
|
||||
Gtk::TreeModel::Path path;
|
||||
|
||||
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);
|
||||
path = tab_filter->convert_path_to_child_path(rows[i]);
|
||||
ids.push_back(tab_model->path_to_id(path));
|
||||
}
|
||||
}
|
||||
|
||||
sel->unselect_all();
|
||||
void Tab :: tab_queue_add(Playqueue *pq)
|
||||
{
|
||||
std::vector<unsigned int> ids;
|
||||
|
||||
tab_selected_ids(ids);
|
||||
for (unsigned int i = 0; i < ids.size(); i++)
|
||||
pq->add(ids[i]);
|
||||
}
|
||||
|
||||
bool Tab :: tab_queue_selected(bool random)
|
||||
{
|
||||
if (tab_treeview->get_selection()->count_selected_rows() == 0)
|
||||
return false;
|
||||
|
||||
if (deck :: size() >= 10)
|
||||
return true;
|
||||
|
||||
|
@ -168,11 +172,8 @@ bool Tab :: tab_queue_selected(bool random)
|
|||
|
||||
bool Tab :: tab_add_to_queue(unsigned int n)
|
||||
{
|
||||
if (tab_treeview->get_selection()->count_selected_rows() == 0)
|
||||
return false;
|
||||
|
||||
if (n >= deck :: size())
|
||||
return false;
|
||||
return true;
|
||||
|
||||
Playqueue *pq = deck :: get(n);
|
||||
tab_queue_add(pq);
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
void tab_runtime_changed();
|
||||
void tab_display_sorting();
|
||||
void tab_focus_search();
|
||||
void tab_selected_ids(std::vector<unsigned int> &);
|
||||
void tab_queue_add(Playqueue *);
|
||||
bool tab_queue_selected(bool);
|
||||
bool tab_add_to_queue(unsigned int);
|
||||
|
|
Loading…
Reference in New Issue