From bfcc94de210aed3b950f6e81feec611352d9a163 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 23 Feb 2014 20:38:24 -0500 Subject: [PATCH] gui: Generic toggle button function Signed-off-by: Anna Schumaker --- gui/tabs.cpp | 18 ++++++++++-------- include/tabs.h | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 1bce66a3..851407e5 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -67,6 +67,14 @@ void Tab :: tab_init_repeat() &Tab::on_repeat_toggled)); } +void Tab :: tab_toggle_button(Gtk::ToggleButton *button, playqueue_flags flag) +{ + if (button->get_active()) + tab_pq->set_flag(flag); + else + tab_pq->unset_flag(flag); +} + int Tab :: tab_page_num() { Gtk::Notebook *notebook = get_widget("o_notebook"); @@ -174,18 +182,12 @@ bool Tab :: on_key_press_event(const std::string &key) void Tab :: on_random_toggled() { - if (tab_random->get_active()) - tab_pq->set_flag(PQ_RANDOM); - else - tab_pq->unset_flag(PQ_RANDOM); + tab_toggle_button(tab_random, 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); + tab_toggle_button(tab_repeat, PQ_REPEAT); } void Tab :: on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) diff --git a/include/tabs.h b/include/tabs.h index 82924387..ff319ec6 100644 --- a/include/tabs.h +++ b/include/tabs.h @@ -38,6 +38,7 @@ protected: */ void tab_init_random(); void tab_init_repeat(); + void tab_toggle_button(Gtk::ToggleButton *, playqueue_flags); bool tab_is_cur(); virtual void tab_set_size(); void tab_unmap();