From 73c4de13be57b23c4805bed278aaafa07922068b Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 23 Feb 2014 20:34:52 -0500 Subject: [PATCH] gui: Update the repeat button Signed-off-by: Anna Schumaker --- gui/queue.cpp | 2 ++ gui/tabs.cpp | 32 +++++++++++++++----------------- include/tabs.h | 3 +++ 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/gui/queue.cpp b/gui/queue.cpp index 67123acf..b625b88c 100644 --- a/gui/queue.cpp +++ b/gui/queue.cpp @@ -121,6 +121,7 @@ QueueTab :: QueueTab(Playqueue *pq, unsigned int num) */ tab_random = &q_random; + tab_repeat = &q_repeat; tab_search = &q_search; tab_size = &q_tab_size; tab_treeview = &q_treeview; @@ -152,6 +153,7 @@ QueueTab :: ~QueueTab() void QueueTab :: on_post_init() { tab_init_random(); + tab_init_repeat(); } void QueueTab :: tab_set_size() diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 6f4aa008..1bce66a3 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -60,6 +60,13 @@ void Tab :: tab_init_random() &Tab::on_random_toggled)); } +void Tab :: tab_init_repeat() +{ + tab_repeat->set_active(tab_pq->get_flags() & PQ_REPEAT); + tab_repeat->signal_toggled().connect(sigc::mem_fun(*this, + &Tab::on_repeat_toggled)); +} + int Tab :: tab_page_num() { Gtk::Notebook *notebook = get_widget("o_notebook"); @@ -173,6 +180,14 @@ void Tab :: on_random_toggled() tab_pq->unset_flag(PQ_RANDOM); } +void Tab :: on_repeat_toggled() +{ + if (tab_repeat->get_active()) + tab_pq->set_flag(PQ_REPEAT); + else + tab_pq->unset_flag(PQ_REPEAT); +} + void Tab :: on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) { Gtk::TreePath model_path = tab_filter->convert_path_to_child_path(path); @@ -549,23 +564,6 @@ void OcarinaPage::setup_columns() } } -void OcarinaPage::check_pq_flags() -{ - if (init_flags & PQ_REPEAT) { - page_repeat.set_active(model->queue->get_flags() & PQ_REPEAT); - page_repeat.signal_toggled().connect(sigc::mem_fun(*this, - &OcarinaPage::on_repeat_toggled)); - } -} - -void OcarinaPage::on_repeat_toggled() -{ - if (page_repeat.get_active()) - model->queue->set_flag(PQ_REPEAT); - else - model->queue->unset_flag(PQ_REPEAT); -} - void OcarinaPage::on_column_clicked(unsigned int col_index) { Gtk::Label *sorting; diff --git a/include/tabs.h b/include/tabs.h index 21e0faea..82924387 100644 --- a/include/tabs.h +++ b/include/tabs.h @@ -29,6 +29,7 @@ protected: * Optional widgets that MAY be set */ Gtk::ToggleButton *tab_random; + Gtk::ToggleButton *tab_repeat; Gtk::Label *tab_size; @@ -36,6 +37,7 @@ protected: * Class helper functions */ void tab_init_random(); + void tab_init_repeat(); bool tab_is_cur(); virtual void tab_set_size(); void tab_unmap(); @@ -66,6 +68,7 @@ public: * GTK-MM callback functions */ void on_random_toggled(); + void on_repeat_toggled(); void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *); bool on_key_pressed(GdkEventKey *key);