gui: Add tracks to playqueue
I added tab numbers to make it easier to specify what playqueue to add tracks to. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
0929418fb7
commit
82243cfdd1
|
@ -57,7 +57,7 @@ void PlayqueueModel::on_row_changed(unsigned int row)
|
||||||
|
|
||||||
void PlayqueueModel::on_path_selected(const Gtk::TreePath &path)
|
void PlayqueueModel::on_path_selected(const Gtk::TreePath &path)
|
||||||
{
|
{
|
||||||
audio :: load_trackid(queue->operator[](path[0]));
|
audio :: load_trackid(path_to_id(path));
|
||||||
queue->set_cur(path[0]);
|
queue->set_cur(path[0]);
|
||||||
audio :: play();
|
audio :: play();
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,11 @@ unsigned int PlayqueueModel :: iter_to_id(const Gtk::TreeIter &iter)
|
||||||
return GPOINTER_TO_UINT(iter.gobj()->user_data);
|
return GPOINTER_TO_UINT(iter.gobj()->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int PlayqueueModel::path_to_id(const Gtk::TreePath &path)
|
||||||
|
{
|
||||||
|
return queue->operator[](path[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
73
gui/tabs.cpp
73
gui/tabs.cpp
|
@ -64,6 +64,7 @@ public:
|
||||||
OcarinaTab();
|
OcarinaTab();
|
||||||
~OcarinaTab();
|
~OcarinaTab();
|
||||||
virtual void set_size(unsigned int) = 0;
|
virtual void set_size(unsigned int) = 0;
|
||||||
|
virtual void set_number(unsigned int) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
OcarinaTab::OcarinaTab() {}
|
OcarinaTab::OcarinaTab() {}
|
||||||
|
@ -81,6 +82,7 @@ public:
|
||||||
PresetTab(const std::string &, const std::string &);
|
PresetTab(const std::string &, const std::string &);
|
||||||
~PresetTab();
|
~PresetTab();
|
||||||
void set_size(unsigned int);
|
void set_size(unsigned int);
|
||||||
|
void set_number(unsigned int);
|
||||||
};
|
};
|
||||||
|
|
||||||
PresetTab::PresetTab(const std::string &name, const std::string &icon)
|
PresetTab::PresetTab(const std::string &name, const std::string &icon)
|
||||||
|
@ -102,6 +104,7 @@ PresetTab::PresetTab(const std::string &name, const std::string &icon)
|
||||||
}
|
}
|
||||||
|
|
||||||
PresetTab::~PresetTab() {}
|
PresetTab::~PresetTab() {}
|
||||||
|
void PresetTab::set_number(unsigned int num) {}
|
||||||
|
|
||||||
void PresetTab::set_size(unsigned int size)
|
void PresetTab::set_size(unsigned int size)
|
||||||
{
|
{
|
||||||
|
@ -114,20 +117,23 @@ void PresetTab::set_size(unsigned int size)
|
||||||
|
|
||||||
class PQTab : public OcarinaTab {
|
class PQTab : public OcarinaTab {
|
||||||
public:
|
public:
|
||||||
|
Gtk::Label number_label;
|
||||||
Gtk::Label size_label;
|
Gtk::Label size_label;
|
||||||
Gtk::Image close_icon;
|
Gtk::Image close_icon;
|
||||||
Gtk::Button close_button;
|
Gtk::Button close_button;
|
||||||
PQTab();
|
PQTab();
|
||||||
~PQTab();
|
~PQTab();
|
||||||
void set_size(unsigned int);
|
void set_size(unsigned int);
|
||||||
|
void set_number(unsigned int);
|
||||||
};
|
};
|
||||||
|
|
||||||
PQTab::PQTab() : size_label("0", 0.5, 0.5)
|
PQTab::PQTab() : number_label("0", 0, 0.5), size_label("0", 0.5, 0.5)
|
||||||
{
|
{
|
||||||
close_icon.set_from_icon_name("window-close", Gtk::ICON_SIZE_MENU);
|
close_icon.set_from_icon_name("window-close", Gtk::ICON_SIZE_MENU);
|
||||||
close_button.set_image(close_icon);
|
close_button.set_image(close_icon);
|
||||||
close_button.set_relief(Gtk::RELIEF_NONE);
|
close_button.set_relief(Gtk::RELIEF_NONE);
|
||||||
|
|
||||||
|
pack_start(number_label, false, false);
|
||||||
pack_start(size_label, true, true);
|
pack_start(size_label, true, true);
|
||||||
pack_start(close_button, false, false);
|
pack_start(close_button, false, false);
|
||||||
show_all();
|
show_all();
|
||||||
|
@ -142,6 +148,13 @@ void PQTab::set_size(unsigned int size)
|
||||||
size_label.set_markup(ss.str());
|
size_label.set_markup(ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PQTab::set_number(unsigned int num)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "<span size='x-large'>" << num << ". </span>";
|
||||||
|
number_label.set_markup(ss.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,6 +210,8 @@ public:
|
||||||
void on_entry_changed();
|
void on_entry_changed();
|
||||||
bool on_entry_key_released(GdkEventKey *);
|
bool on_entry_key_released(GdkEventKey *);
|
||||||
bool on_filter_visible(const Gtk::TreeIter &);
|
bool on_filter_visible(const Gtk::TreeIter &);
|
||||||
|
void on_page_renumbered();
|
||||||
|
bool on_view_key_pressed(GdkEventKey *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -292,6 +307,9 @@ void OcarinaPage::setup_treeview()
|
||||||
|
|
||||||
page_view.signal_row_activated().connect(sigc::mem_fun(*this,
|
page_view.signal_row_activated().connect(sigc::mem_fun(*this,
|
||||||
&OcarinaPage::on_row_activated));
|
&OcarinaPage::on_row_activated));
|
||||||
|
page_view.signal_key_press_event().connect(sigc::mem_fun(*this,
|
||||||
|
&OcarinaPage::on_view_key_pressed));
|
||||||
|
|
||||||
page_view.set_model(filter);
|
page_view.set_model(filter);
|
||||||
page_view.set_rules_hint();
|
page_view.set_rules_hint();
|
||||||
page_view.set_enable_search(false);
|
page_view.set_enable_search(false);
|
||||||
|
@ -354,7 +372,7 @@ void OcarinaPage::queue_selected(bool random)
|
||||||
pq = deck::create(random);
|
pq = deck::create(random);
|
||||||
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
|
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
|
||||||
for (it = rows.begin(); it != rows.end(); it++) {
|
for (it = rows.begin(); it != rows.end(); it++) {
|
||||||
track_id = (*model->queue)[(*it)[0]];
|
track_id = model->path_to_id(filter->convert_path_to_child_path(*it));
|
||||||
pq->add(track_id);
|
pq->add(track_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,6 +474,41 @@ bool OcarinaPage::on_filter_visible(const Gtk::TreeIter &iter)
|
||||||
return visible_ids.find(model->queue->operator[](pq_id)) != visible_ids.end();
|
return visible_ids.find(model->queue->operator[](pq_id)) != visible_ids.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OcarinaPage::on_page_renumbered()
|
||||||
|
{
|
||||||
|
tab->set_number(notebook->page_num(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OcarinaPage::on_view_key_pressed(GdkEventKey *event)
|
||||||
|
{
|
||||||
|
std::string key = gdk_keyval_name(event->keyval);
|
||||||
|
|
||||||
|
if (key.size() >= 3) {
|
||||||
|
if (key.substr(0, 3) == "KP_")
|
||||||
|
key = key.substr(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (key >= "0" && key <= "9") {
|
||||||
|
unsigned int n = atoi(key.c_str());
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -504,6 +557,13 @@ static void on_switch_page(Gtk::Widget *page, int num)
|
||||||
sort_timeout_count = 0;
|
sort_timeout_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void renumber_pqs()
|
||||||
|
{
|
||||||
|
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||||
|
for (it = tab_map.begin(); it != tab_map.end(); it++)
|
||||||
|
it->second->on_page_renumbered();
|
||||||
|
}
|
||||||
|
|
||||||
static void on_page_reordered(Gtk::Widget *page, int num)
|
static void on_page_reordered(Gtk::Widget *page, int num)
|
||||||
{
|
{
|
||||||
Gtk::Notebook *notebook;
|
Gtk::Notebook *notebook;
|
||||||
|
@ -513,14 +573,17 @@ static void on_page_reordered(Gtk::Widget *page, int num)
|
||||||
|
|
||||||
if ((unsigned int)num >= deck :: size())
|
if ((unsigned int)num >= deck :: size())
|
||||||
notebook->reorder_child(*page, deck::size() - 1);
|
notebook->reorder_child(*page, deck::size() - 1);
|
||||||
else
|
else {
|
||||||
deck :: move(tab->model->queue, num);
|
deck :: move(tab->model->queue, num);
|
||||||
|
renumber_pqs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_pq_created(Playqueue *pq, unsigned int num)
|
static void on_pq_created(Playqueue *pq, unsigned int num)
|
||||||
{
|
{
|
||||||
OcarinaPage *page = new OcarinaPage(pq, PQ_RANDOM | PQ_REPEAT, num);
|
OcarinaPage *page = new OcarinaPage(pq, PQ_RANDOM | PQ_REPEAT, num);
|
||||||
page->check_pq_flags();
|
page->check_pq_flags();
|
||||||
|
renumber_pqs();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_pq_removed(Playqueue *pq)
|
static void on_pq_removed(Playqueue *pq)
|
||||||
|
@ -529,11 +592,15 @@ static void on_pq_removed(Playqueue *pq)
|
||||||
it = tab_map.find(pq);
|
it = tab_map.find(pq);
|
||||||
if (it != tab_map.end())
|
if (it != tab_map.end())
|
||||||
delete it->second;
|
delete it->second;
|
||||||
|
renumber_pqs();
|
||||||
}
|
}
|
||||||
|
|
||||||
void queue_selected(bool random)
|
void queue_selected(bool random)
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||||
|
if (deck :: size() >= 10)
|
||||||
|
return;
|
||||||
|
|
||||||
for (it = tab_map.begin(); it != tab_map.end(); it++) {
|
for (it = tab_map.begin(); it != tab_map.end(); it++) {
|
||||||
if (it->second->is_current_tab()) {
|
if (it->second->is_current_tab()) {
|
||||||
it->second->queue_selected(random);
|
it->second->queue_selected(random);
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
void on_row_changed(unsigned int);
|
void on_row_changed(unsigned int);
|
||||||
void on_path_selected(const Gtk::TreePath &);
|
void on_path_selected(const Gtk::TreePath &);
|
||||||
unsigned int iter_to_id(const Gtk::TreeIter &);
|
unsigned int iter_to_id(const Gtk::TreeIter &);
|
||||||
|
unsigned int path_to_id(const Gtk::TreePath &);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* tabs.cpp */
|
/* tabs.cpp */
|
||||||
|
|
Loading…
Reference in New Issue