gui: Add a second-stage init function for tabs
This gives them a chance to check playqueue flags after the queues are loaded. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
018c4747a2
commit
97be413bcf
|
@ -7,10 +7,13 @@
|
||||||
|
|
||||||
Gtk::Window *ocarina_init(int *argc, char ***argv)
|
Gtk::Window *ocarina_init(int *argc, char ***argv)
|
||||||
{
|
{
|
||||||
|
Gtk::Window *window = connect_wires();
|
||||||
audio::init(argc, argv);
|
audio::init(argc, argv);
|
||||||
deck::init();
|
deck::init();
|
||||||
library::init();
|
library::init();
|
||||||
return connect_wires();
|
|
||||||
|
init_tabs2();
|
||||||
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_TEST
|
#ifndef CONFIG_TEST
|
||||||
|
|
22
gui/tabs.cpp
22
gui/tabs.cpp
|
@ -85,6 +85,7 @@ void OcarinaTab::set_size(unsigned int size)
|
||||||
*/
|
*/
|
||||||
class OcarinaPage : public Gtk::VBox {
|
class OcarinaPage : public Gtk::VBox {
|
||||||
private:
|
private:
|
||||||
|
unsigned int init_flags;
|
||||||
Glib::RefPtr<PlayqueueModel> model;
|
Glib::RefPtr<PlayqueueModel> model;
|
||||||
Gtk::Notebook *notebook;
|
Gtk::Notebook *notebook;
|
||||||
|
|
||||||
|
@ -107,6 +108,7 @@ public:
|
||||||
Playqueue *, unsigned int);
|
Playqueue *, unsigned int);
|
||||||
~OcarinaPage();
|
~OcarinaPage();
|
||||||
bool is_current_tab();
|
bool is_current_tab();
|
||||||
|
void check_pq_flags();
|
||||||
|
|
||||||
void on_row_inserted(unsigned int);
|
void on_row_inserted(unsigned int);
|
||||||
void on_row_deleted(unsigned int);
|
void on_row_deleted(unsigned int);
|
||||||
|
@ -117,7 +119,7 @@ public:
|
||||||
|
|
||||||
OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
||||||
Playqueue *pq, unsigned int flags)
|
Playqueue *pq, unsigned int flags)
|
||||||
: tab(name, icon)
|
: init_flags(flags), tab(name, icon)
|
||||||
{
|
{
|
||||||
get_builder()->get_widget("o_notebook", notebook);
|
get_builder()->get_widget("o_notebook", notebook);
|
||||||
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(pq));
|
model = Glib::RefPtr<PlayqueueModel>(new PlayqueueModel(pq));
|
||||||
|
@ -131,9 +133,7 @@ OcarinaPage::OcarinaPage(const std::string &name, const std::string &icon,
|
||||||
/* Make buttons */
|
/* Make buttons */
|
||||||
if (flags & PQ_RANDOM) {
|
if (flags & PQ_RANDOM) {
|
||||||
page_random.set_image_from_icon_name("media-playlist-shuffle");
|
page_random.set_image_from_icon_name("media-playlist-shuffle");
|
||||||
page_random.set_active((pq->get_flags() & PQ_RANDOM) != 0);
|
|
||||||
page_toolbar.pack_start(page_random, false, false);
|
page_toolbar.pack_start(page_random, false, false);
|
||||||
page_random.signal_toggled().connect(sigc::mem_fun(*this, &OcarinaPage::on_random_toggled));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,6 +187,15 @@ bool OcarinaPage::is_current_tab()
|
||||||
return notebook->page_num(*this) == notebook->get_current_page();
|
return notebook->page_num(*this) == notebook->get_current_page();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OcarinaPage::check_pq_flags()
|
||||||
|
{
|
||||||
|
if (init_flags & PQ_RANDOM) {
|
||||||
|
page_random.set_active(model->queue->get_flags() & PQ_RANDOM);
|
||||||
|
page_random.signal_toggled().connect(sigc::mem_fun(*this,
|
||||||
|
&OcarinaPage::on_random_toggled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OcarinaPage::set_tab_size()
|
void OcarinaPage::set_tab_size()
|
||||||
{
|
{
|
||||||
tab.set_size(model->queue->size());
|
tab.set_size(model->queue->size());
|
||||||
|
@ -275,6 +284,13 @@ void init_tabs()
|
||||||
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init_tabs2()
|
||||||
|
{
|
||||||
|
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||||
|
for (it = tab_map.begin(); it != tab_map.end(); it++)
|
||||||
|
it->second->check_pq_flags();
|
||||||
|
}
|
||||||
|
|
||||||
void cleanup_tabs()
|
void cleanup_tabs()
|
||||||
{
|
{
|
||||||
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
std::map<Playqueue *, OcarinaPage *>::iterator it;
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
|
|
||||||
/* tabs.cpp */
|
/* tabs.cpp */
|
||||||
void init_tabs();
|
void init_tabs();
|
||||||
|
void init_tabs2();
|
||||||
void cleanup_tabs();
|
void cleanup_tabs();
|
||||||
|
|
||||||
/* wires.cpp */
|
/* wires.cpp */
|
||||||
|
|
Loading…
Reference in New Issue