gui: Set up each tab page vbox from a single place
This is better than having the same code in 4 places. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
c9ca2604ee
commit
682dca2339
|
@ -12,7 +12,6 @@
|
|||
class CollectionTab : public Tab {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> builder;
|
||||
Gtk::VBox collection_vbox;
|
||||
|
||||
CollectionLabel *collection_label;
|
||||
QueueToolbar *collection_toolbar;
|
||||
|
@ -33,22 +32,17 @@ public:
|
|||
collection_toolbar->init(tab_pq, collection_label, collection_window, T_RANDOM);
|
||||
collection_window->init(tab_pq);
|
||||
|
||||
collection_vbox.set_margin_left(1);
|
||||
collection_vbox.set_margin_right(1);
|
||||
collection_vbox.set_homogeneous(false);
|
||||
collection_vbox.pack_start(*collection_toolbar, false, true, 2);
|
||||
collection_vbox.pack_start(*collection_window, true, true);
|
||||
collection_vbox.show();
|
||||
tab_vbox.pack_start(*collection_toolbar, false, true, 2);
|
||||
tab_vbox.pack_start(*collection_window, true, true);
|
||||
|
||||
tab_model = collection_window->q_model;
|
||||
tab_filter = collection_window->q_filter;
|
||||
tab_search = collection_toolbar->q_search;
|
||||
tab_size = collection_label->collection_size;
|
||||
tab_treeview = collection_window->q_treeview;
|
||||
tab_widget = &collection_vbox;
|
||||
tab_finish_init();
|
||||
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(collection_vbox, *collection_label, 0);
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *collection_label, 0);
|
||||
}
|
||||
|
||||
~CollectionTab()
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
class HistoryTab : public Tab {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> builder;
|
||||
Gtk::VBox history_vbox;
|
||||
|
||||
HistoryLabel *history_label;
|
||||
QueueToolbar *history_toolbar;
|
||||
|
@ -32,22 +31,17 @@ public:
|
|||
history_toolbar->init(tab_pq, history_label, history_window, 0);
|
||||
history_window->init(tab_pq);
|
||||
|
||||
history_vbox.set_margin_left(1);
|
||||
history_vbox.set_margin_right(1);
|
||||
history_vbox.set_homogeneous(false);
|
||||
history_vbox.pack_start(*history_toolbar, false, true, 2);
|
||||
history_vbox.pack_start(*history_window, true, true);
|
||||
history_vbox.show();
|
||||
tab_vbox.pack_start(*history_toolbar, false, true, 2);
|
||||
tab_vbox.pack_start(*history_window, true, true);
|
||||
|
||||
tab_model = history_window->q_model;
|
||||
tab_filter = history_window->q_filter;
|
||||
tab_search = history_toolbar->q_search;
|
||||
tab_size = history_label->history_size;
|
||||
tab_treeview = history_window->q_treeview;
|
||||
tab_widget = &history_vbox;
|
||||
tab_finish_init();
|
||||
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(history_vbox, *history_label, 0);
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *history_label, 0);
|
||||
}
|
||||
|
||||
~HistoryTab()
|
||||
|
|
|
@ -72,7 +72,6 @@ public:
|
|||
static class PlaylistTab : public Tab {
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Builder> builder;
|
||||
Gtk::VBox playlist_vbox;
|
||||
Gtk::HBox playlist_hbox;
|
||||
|
||||
PlaylistLabel *playlist_label;
|
||||
|
@ -101,21 +100,16 @@ public:
|
|||
playlist_hbox.pack_start(*playlist_tracks, true, true);
|
||||
playlist_hbox.show();
|
||||
|
||||
playlist_vbox.set_margin_left(1);
|
||||
playlist_vbox.set_margin_right(1);
|
||||
playlist_vbox.set_homogeneous(false);
|
||||
playlist_vbox.pack_start(*playlist_toolbar, false, true, 2);
|
||||
playlist_vbox.pack_start(playlist_hbox, true, true);
|
||||
playlist_vbox.show();
|
||||
tab_vbox.pack_start(*playlist_toolbar, false, true, 2);
|
||||
tab_vbox.pack_start(playlist_hbox, true, true);
|
||||
|
||||
tab_model = playlist_tracks->q_model;
|
||||
tab_filter = playlist_tracks->q_filter;
|
||||
tab_search = playlist_toolbar->q_search;
|
||||
tab_treeview = playlist_tracks->q_treeview;
|
||||
tab_widget = &playlist_vbox;
|
||||
tab_finish_init();
|
||||
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(playlist_vbox, *playlist_label, 0);
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *playlist_label, 0);
|
||||
}
|
||||
|
||||
~PlaylistTab()
|
||||
|
|
|
@ -42,11 +42,6 @@ private:
|
|||
*/
|
||||
TempLabel *q_label;
|
||||
|
||||
/**
|
||||
* Queue page widgets
|
||||
*/
|
||||
Gtk::VBox q_vbox;
|
||||
|
||||
/**
|
||||
* Toolbar widgets
|
||||
*/
|
||||
|
@ -118,12 +113,8 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
* Fill in the page!
|
||||
*/
|
||||
|
||||
q_vbox.set_margin_left(1);
|
||||
q_vbox.set_margin_right(1);
|
||||
q_vbox.set_homogeneous(false);
|
||||
q_vbox.pack_start(*q_toolbar, false, true, 2);
|
||||
q_vbox.pack_start(*q_window, true, true);
|
||||
q_vbox.show();
|
||||
tab_vbox.pack_start(*q_toolbar, false, true, 2);
|
||||
tab_vbox.pack_start(*q_window, true, true);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -135,20 +126,19 @@ QueueTab :: QueueTab(Queue *pq, unsigned int num)
|
|||
tab_search = q_toolbar->q_search;
|
||||
tab_size = q_label->temp_size;
|
||||
tab_treeview = q_window->q_treeview;
|
||||
tab_widget = &q_vbox;
|
||||
|
||||
tab_finish_init();
|
||||
queue_mapping[tab_widget] = this;
|
||||
queue_mapping[&tab_vbox] = this;
|
||||
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(q_vbox, *q_label, num);
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->set_tab_reorderable(q_vbox);
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->insert_page(tab_vbox, *q_label, num);
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->set_tab_reorderable(tab_vbox);
|
||||
}
|
||||
|
||||
QueueTab :: ~QueueTab()
|
||||
{
|
||||
queue_mapping.erase(tab_widget);
|
||||
queue_mapping.erase(&tab_vbox);
|
||||
tab_unmap();
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->remove_page(q_vbox);
|
||||
gui :: get_widget<Gtk::Notebook>("o_notebook")->remove_page(tab_vbox);
|
||||
renumber_queues();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,11 @@ Tab :: Tab(Queue *pq)
|
|||
{
|
||||
pq->set_notifier(this);
|
||||
queue_mapping[tab_pq] = this;
|
||||
|
||||
tab_vbox.set_margin_start(1);
|
||||
tab_vbox.set_margin_end(1);
|
||||
tab_vbox.set_homogeneous(false);
|
||||
tab_vbox.show();
|
||||
}
|
||||
|
||||
Tab :: ~Tab() {}
|
||||
|
@ -89,13 +94,13 @@ void Tab :: on_track_updated(unsigned int row)
|
|||
int Tab :: tab_page_num()
|
||||
{
|
||||
Gtk::Notebook *notebook = gui :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
return notebook->page_num(*tab_widget);
|
||||
return notebook->page_num(tab_vbox);
|
||||
}
|
||||
|
||||
bool Tab :: tab_is_cur()
|
||||
{
|
||||
Gtk::Notebook *notebook = gui :: get_widget<Gtk::Notebook>("o_notebook");
|
||||
return notebook->page_num(*tab_widget) == notebook->get_current_page();
|
||||
return notebook->page_num(tab_vbox) == notebook->get_current_page();
|
||||
}
|
||||
|
||||
void Tab :: tab_runtime_changed()
|
||||
|
|
|
@ -15,6 +15,7 @@ private:
|
|||
|
||||
protected:
|
||||
Queue *tab_pq;
|
||||
Gtk::VBox tab_vbox;
|
||||
|
||||
/**
|
||||
* Widgets that MUST be set by a child class
|
||||
|
@ -24,7 +25,6 @@ protected:
|
|||
|
||||
Gtk::SearchEntry *tab_search;
|
||||
Gtk::TreeView *tab_treeview;
|
||||
Gtk::Widget *tab_widget;
|
||||
|
||||
/**
|
||||
* Optional widgets that MAY be set
|
||||
|
|
Loading…
Reference in New Issue