gui: Add a switch to enable / disable queues

I also select the first enabled queue during startup.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-03-01 20:55:37 -05:00 committed by Anna Schumaker
parent 1394aaf37c
commit 2e727ed704
2 changed files with 35 additions and 1 deletions

View File

@ -55,6 +55,7 @@ private:
Gtk::SearchEntry q_search;
Gtk::ToggleButton q_random;
Gtk::ToggleButton q_repeat;
Gtk::Switch q_switch;
/* Treeview widgets */
Gtk::ScrolledWindow q_window;
@ -75,11 +76,13 @@ public:
void queue_set_number(unsigned int);
void on_tab_reordered();
void on_move_queue(int);
void queue_set_sensitive(bool);
/**
* GTK-MM Callbacks
*/
void on_close_clicked();
void on_switch_changed();
};
static std::map<Gtk::Widget *, QueueTab *> queue_mapping;
@ -121,6 +124,7 @@ QueueTab :: QueueTab(Playqueue *pq, unsigned int num)
q_toolbar_box.set_homogeneous(false);
q_toolbar_box.pack_start(q_search, true, true);
q_toolbar_box.pack_start(q_switch, false, true);
q_toolbar_box.pack_start(q_repeat, false, true);
q_toolbar_box.pack_start(q_random, false, true);
@ -213,6 +217,12 @@ void QueueTab :: on_post_init()
{
tab_init_random();
tab_init_repeat();
bool active = (tab_pq->get_flags() & PQ_ENABLED) == PQ_ENABLED;
q_switch.set_active(active);
q_switch.property_active().signal_changed().connect(
sigc::mem_fun(*this, &QueueTab :: on_switch_changed));
queue_set_sensitive(active);
}
bool QueueTab :: on_key_press_event(const std::string &key)
@ -264,6 +274,13 @@ void QueueTab :: on_move_queue(int num)
deck :: move(tab_pq, num);
}
void QueueTab :: queue_set_sensitive(bool sensitive)
{
q_tab_number.set_sensitive(sensitive);
q_tab_size.set_sensitive(sensitive);
q_treeview.set_sensitive(sensitive);
}
/**
@ -277,6 +294,17 @@ void QueueTab :: on_close_clicked()
deck :: remove(tab_page_num());
}
void QueueTab :: on_switch_changed()
{
if (q_switch.get_active()) {
tab_pq->set_flag(PQ_ENABLED);
queue_set_sensitive(true);
} else {
tab_pq->unset_flag(PQ_ENABLED);
queue_set_sensitive(false);
}
}
/**

View File

@ -519,7 +519,13 @@ void post_init_tabs()
std::map<Playqueue *, Tab *>::iterator it;
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++)
it->second->on_post_init();
get_widget<Gtk::Notebook>("o_notebook")->set_current_page(0);
unsigned int tab = 0;
for (tab = 0; tab < deck::size(); tab++) {
if ((deck :: get(tab)->get_flags() & PQ_ENABLED) == PQ_ENABLED)
break;
}
get_widget<Gtk::Notebook>("o_notebook")->set_current_page(tab);
}
void cleanup_tabs()