gui: Create new playqueue tabs
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
32841901db
commit
7ce3c4268f
80
gui/tabs.cpp
80
gui/tabs.cpp
|
@ -64,6 +64,7 @@ public:
|
|||
Gtk::Image tab_icon;
|
||||
Gtk::HBox box;
|
||||
Gtk::VBox inner_box;
|
||||
bool big_size;
|
||||
|
||||
OcarinaTab(const std::string &, const std::string &);
|
||||
~OcarinaTab();
|
||||
|
@ -72,8 +73,9 @@ public:
|
|||
|
||||
OcarinaTab::OcarinaTab(const std::string &name, const std::string &icon)
|
||||
: name_label("<big>" + name + "</big>", 0.5, 0.5),
|
||||
size_label("0", 0.5, 0.5)
|
||||
size_label("0", 0.5, 0.5), big_size(false)
|
||||
{
|
||||
|
||||
tab_icon.set_from_icon_name(icon, Gtk::ICON_SIZE_MENU);
|
||||
tab_icon.set_alignment(0, 0.5);
|
||||
name_label.set_use_markup();
|
||||
|
@ -86,6 +88,12 @@ OcarinaTab::OcarinaTab(const std::string &name, const std::string &icon)
|
|||
box.pack_start(tab_icon);
|
||||
box.pack_start(inner_box);
|
||||
box.show_all();
|
||||
|
||||
if (name == "" && icon == "") {
|
||||
name_label.hide();
|
||||
tab_icon.hide();
|
||||
big_size = true;
|
||||
}
|
||||
}
|
||||
|
||||
OcarinaTab::~OcarinaTab() {}
|
||||
|
@ -93,8 +101,13 @@ OcarinaTab::~OcarinaTab() {}
|
|||
void OcarinaTab::set_size(unsigned int size)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << size;
|
||||
size_label.set_text(ss.str());
|
||||
if (big_size == true) {
|
||||
ss << "<span size='x-large'>" << size << "</span>";
|
||||
size_label.set_markup(ss.str());
|
||||
} else {
|
||||
ss << size;
|
||||
size_label.set_text(ss.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,10 +137,11 @@ public:
|
|||
Gtk::ToggleButton page_random;
|
||||
|
||||
OcarinaPage(const std::string &, const std::string &,
|
||||
Playqueue *, unsigned int);
|
||||
Playqueue *, unsigned int, unsigned int);
|
||||
~OcarinaPage();
|
||||
bool is_current_tab();
|
||||
void check_pq_flags();
|
||||
void queue_selected();
|
||||
|
||||
void on_row_inserted(unsigned int);
|
||||
void on_row_deleted(unsigned int);
|
||||
|
@ -140,7 +154,7 @@ public:
|
|||
|
||||
|
||||
OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
||||
Playqueue *pq, unsigned int flags)
|
||||
Playqueue *pq, unsigned int flags, unsigned int pg)
|
||||
: init_flags(flags), tab(name, icon)
|
||||
{
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
|
@ -177,6 +191,9 @@ OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
|||
&OcarinaPage::on_row_activated));
|
||||
page_view.set_model(model);
|
||||
page_view.set_rules_hint();
|
||||
page_view.set_enable_search(false);
|
||||
page_view.get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
|
||||
page_view.set_rubber_banding();
|
||||
page_scroll.add(page_view);
|
||||
setup_columns();
|
||||
|
||||
|
@ -187,8 +204,9 @@ OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
|||
|
||||
|
||||
/* Add to notebook */
|
||||
notebook->prepend_page(*this, tab.box);
|
||||
notebook->insert_page(*this, tab.box, pg);
|
||||
tab_map[pq] = this;
|
||||
set_tab_size();
|
||||
};
|
||||
|
||||
OcarinaPage::~OcarinaPage()
|
||||
|
@ -230,6 +248,25 @@ void OcarinaPage::set_tab_size()
|
|||
tab.set_size(model->queue->size());
|
||||
}
|
||||
|
||||
void OcarinaPage::queue_selected()
|
||||
{
|
||||
Playqueue *pq;
|
||||
unsigned int track_id;
|
||||
std::vector<Gtk::TreeModel::Path>::iterator it;
|
||||
Glib::RefPtr<Gtk::TreeSelection> sel = page_view.get_selection();
|
||||
|
||||
if (sel->count_selected_rows() == 0)
|
||||
return;
|
||||
|
||||
pq = deck::create();
|
||||
std::vector<Gtk::TreeModel::Path> rows = sel->get_selected_rows();
|
||||
for (it = rows.begin(); it != rows.end(); it++) {
|
||||
track_id = (*model->queue)[(*it)[0]];
|
||||
pq->add(track_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void OcarinaPage::on_row_inserted(unsigned int row)
|
||||
{
|
||||
model->on_row_inserted(row);
|
||||
|
@ -337,13 +374,40 @@ static void on_switch_page(Gtk::Widget *page, int num)
|
|||
sort_timeout_count = 0;
|
||||
}
|
||||
|
||||
static void on_pq_created(Playqueue *pq, unsigned int num)
|
||||
{
|
||||
OcarinaPage *page = new OcarinaPage("", "", pq, PQ_RANDOM, num);
|
||||
page->check_pq_flags();
|
||||
}
|
||||
|
||||
static void on_pq_removed(Playqueue *pq)
|
||||
{
|
||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||
it = tab_map.find(pq);
|
||||
if (it != tab_map.end())
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
void queue_selected()
|
||||
{
|
||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||
for (it = tab_map.begin(); it != tab_map.end(); it++) {
|
||||
if (it->second->is_current_tab()) {
|
||||
it->second->queue_selected();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void init_tabs()
|
||||
{
|
||||
Gtk::Notebook *notebook;
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
|
||||
new OcarinaPage("History", "document-open-recent", audio::get_recent_pq(), 0);
|
||||
new OcarinaPage("Collection", "media-optical", deck::get_library_pq(), PQ_RANDOM);
|
||||
new OcarinaPage("History", "document-open-recent", audio::get_recent_pq(), 0, 0);
|
||||
new OcarinaPage("Collection", "media-optical", deck::get_library_pq(), PQ_RANDOM, 0);
|
||||
get_callbacks()->on_pq_created = on_pq_created;
|
||||
get_callbacks()->on_pq_removed = on_pq_removed;
|
||||
get_callbacks()->on_queue_track_add = on_track_added;
|
||||
get_callbacks()->on_queue_track_del = on_track_deleted;
|
||||
get_callbacks()->on_queue_track_changed = on_track_changed;
|
||||
|
|
|
@ -111,6 +111,8 @@ static bool on_window_key_pressed(GdkEventKey *event)
|
|||
on_next();
|
||||
else if (key == "N")
|
||||
audio :: previous();
|
||||
else if (key == "q")
|
||||
queue_selected();
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
};
|
||||
|
||||
/* tabs.cpp */
|
||||
void queue_selected();
|
||||
void init_tabs();
|
||||
void init_tabs2();
|
||||
void cleanup_tabs();
|
||||
|
|
Loading…
Reference in New Issue