diff --git a/gui/gst.cpp b/gui/gst.cpp index 3bb8bd6e..895ff52a 100644 --- a/gui/gst.cpp +++ b/gui/gst.cpp @@ -20,6 +20,9 @@ static Gtk::Button *o_prev; static Gtk::Scale *o_seek; static Gtk::Button *o_stop; +static Gtk::SpinButton *o_count; +static Gtk::CheckButton *o_enabled; + static Gtk::Label *o_album; static Gtk::Label *o_artist; static Gtk::Label *o_duration; @@ -147,8 +150,8 @@ static gboolean on_gst_message(GstBus *bus, GstMessage *message, gpointer data) break; case GST_MESSAGE_EOS: gst_driver->eos(); - on_pause_count_changed(audio :: pause_enabled(), - audio :: pause_count()); + o_count->set_value(audio :: pause_count()); + o_enabled->set_active(audio :: pause_enabled()); break; default: break; @@ -169,6 +172,16 @@ static bool on_seek(Gtk::ScrollType type, double value) return true; } +static void on_pause_count() +{ + o_enabled->set_active(true); +} + +static void on_pause_enabled() +{ + audio :: pause_after(o_enabled->get_active(), o_count->get_value()); +} + static bool on_timeout() { o_position->set_text(audio :: position_str()); @@ -201,6 +214,9 @@ void init_gst(int *argc, char ***argv) o_seek = lib :: get_widget("o_seek"); o_stop = lib :: get_widget("o_stop"); + o_count = lib :: get_widget("o_pause_count"); + o_enabled = lib :: get_widget("o_pause_enabled"); + o_album = lib :: get_widget("o_album"); o_artist = lib :: get_widget("o_artist"); o_duration = lib :: get_widget("o_duration"); @@ -215,6 +231,9 @@ void init_gst(int *argc, char ***argv) o_seek->signal_change_value().connect(sigc::ptr_fun(on_seek)); o_stop->signal_clicked().connect(sigc::ptr_fun(audio :: stop)); + o_count->signal_changed().connect(sigc::ptr_fun(on_pause_count)); + o_enabled->signal_toggled().connect(sigc::ptr_fun(on_pause_enabled)); + gst_bus_add_watch(gst_bus, on_gst_message, NULL); lib :: schedule(on_timeout, 500); } diff --git a/gui/gui.cpp b/gui/gui.cpp index daf0c8b9..e30af1f4 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -11,36 +11,6 @@ #include #include -Gtk::SpinButton *count; -Gtk::CheckButton *enabled; - - - -/* - * Control functions - */ -static void on_config_pause_enabled() -{ - audio :: pause_after(enabled->get_active(), count->get_value()); -} - -static void on_config_pause_count() -{ - enabled->set_active(true); -} - -void on_pause_count_changed(bool enabled, unsigned int count) -{ - Gtk::CheckButton *p_enabled = lib :: get_widget("o_pause_enabled"); - Gtk::SpinButton *p_count = lib :: get_widget("o_pause_count");; - - if (p_enabled->get_active() != enabled) - p_enabled->set_active(enabled); - if (p_count->get_value() != count) - p_count->set_value(count); -} - - /* * Ocarina functions @@ -52,15 +22,6 @@ void connect_button(const std::string &name, void (*func)()) Gtk::Window *setup_gui() { - /* Controls */ - count = lib :: get_widget("o_pause_count"); - enabled = lib :: get_widget("o_pause_enabled"); - - count->signal_changed().connect(sigc::ptr_fun(on_config_pause_count)); - enabled->signal_toggled().connect(sigc::ptr_fun(on_config_pause_enabled)); - - - /* Favorite and ban buttons */ if (audio :: current_track()) on_track_loaded(audio :: current_track()); diff --git a/include/gui/ocarina.h b/include/gui/ocarina.h index 84373f58..5a032807 100644 --- a/include/gui/ocarina.h +++ b/include/gui/ocarina.h @@ -18,7 +18,6 @@ Gtk::Window *ocarina_init(int *, char ***); /* gui.cpp */ void connect_button(const std::string &, void (*func)()); -void on_pause_count_changed(bool, unsigned int); Gtk::Window *setup_gui(); void on_pq_created(Queue *, unsigned int);