gui: Make OcarinaPage inherit from a vbox
Now we are passed the page on the switch_page() signal. This saves time iterating and comparing. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
aa40f1dfd5
commit
a4d680b00e
41
gui/tabs.cpp
41
gui/tabs.cpp
|
@ -83,7 +83,7 @@ void OcarinaTab::set_size(unsigned int size)
|
|||
/*
|
||||
* Ocarina class definition
|
||||
*/
|
||||
class OcarinaPage {
|
||||
class OcarinaPage : Gtk::VBox {
|
||||
private:
|
||||
Glib::RefPtr<PlayqueueModel> model;
|
||||
Gtk::Notebook *notebook;
|
||||
|
@ -91,7 +91,6 @@ private:
|
|||
OcarinaTab tab;
|
||||
|
||||
/* Page widgets */
|
||||
Gtk::VBox page_box;
|
||||
Gtk::HBox page_toolbar;
|
||||
Gtk::SearchEntry page_entry;
|
||||
Gtk::ToggleButton page_random;
|
||||
|
@ -106,7 +105,6 @@ public:
|
|||
OcarinaPage(const std::string &, const std::string &, Playqueue *);
|
||||
~OcarinaPage();
|
||||
bool is_current_tab();
|
||||
bool is_current_tab(unsigned int);
|
||||
|
||||
void on_row_inserted(unsigned int);
|
||||
void on_row_deleted(unsigned int);
|
||||
|
@ -146,19 +144,19 @@ OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
|||
page_toolbar.pack_start(page_entry);
|
||||
page_toolbar.pack_start(page_random, false, false);
|
||||
//page_toolbar.pack_start(page_repeat, false, false);
|
||||
page_box.pack_start(page_toolbar, false, false);
|
||||
page_box.pack_start(page_scroll);
|
||||
page_box.show_all();
|
||||
pack_start(page_toolbar, false, false);
|
||||
pack_start(page_scroll);
|
||||
show_all();
|
||||
|
||||
|
||||
/* Add to notebook */
|
||||
notebook->prepend_page(page_box, tab.box);
|
||||
notebook->prepend_page(*this, tab.box);
|
||||
tab_map[pq] = this;
|
||||
};
|
||||
|
||||
OcarinaPage::~OcarinaPage()
|
||||
{
|
||||
notebook->remove_page(page_box);
|
||||
notebook->remove_page(*this);
|
||||
tab_map.erase(model->queue);
|
||||
}
|
||||
|
||||
|
@ -174,12 +172,7 @@ void OcarinaPage::setup_columns()
|
|||
|
||||
bool OcarinaPage::is_current_tab()
|
||||
{
|
||||
return notebook->page_num(page_box) == notebook->get_current_page();
|
||||
}
|
||||
|
||||
bool OcarinaPage::is_current_tab(unsigned int tab)
|
||||
{
|
||||
return notebook->page_num(page_box) == (int)tab;
|
||||
return notebook->page_num(*this) == notebook->get_current_page();
|
||||
}
|
||||
|
||||
void OcarinaPage::set_tab_size()
|
||||
|
@ -232,21 +225,21 @@ static void on_track_deleted(Playqueue *pq, unsigned int row)
|
|||
it->second->on_row_deleted(row);
|
||||
}
|
||||
|
||||
static void on_switch_page(Gtk::Widget *page, unsigned int num)
|
||||
static void on_switch_page(Gtk::Widget *page, int num)
|
||||
{
|
||||
Gtk::Label *label;
|
||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||
Gtk::Notebook *notebook;
|
||||
OcarinaPage *tab = (OcarinaPage *)page;
|
||||
|
||||
get_builder()->get_widget("o_queue_time", label);
|
||||
get_builder()->get_widget("o_notebook", notebook);
|
||||
|
||||
for (it = tab_map.begin(); it != tab_map.end(); it++) {
|
||||
if (it->second->is_current_tab(num)) {
|
||||
it->second->on_runtime_changed();
|
||||
label->show();
|
||||
return;
|
||||
}
|
||||
if (num >= notebook->get_n_pages() - 1)
|
||||
label->hide();
|
||||
else {
|
||||
tab->on_runtime_changed();
|
||||
label->show();
|
||||
}
|
||||
|
||||
label->hide();
|
||||
}
|
||||
|
||||
void init_tabs()
|
||||
|
|
Loading…
Reference in New Issue