From 5e7a25e007fce1f523f242886b922d1a65ada4e8 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 11 Sep 2014 08:09:30 -0400 Subject: [PATCH] gui: Store position and progress widgets Now we don't need to keep looking them up, and the code looks a little bit cleaner =) Signed-off-by: Anna Schumaker --- gui/controls.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gui/controls.cpp b/gui/controls.cpp index 266a98a1..76bde66a 100644 --- a/gui/controls.cpp +++ b/gui/controls.cpp @@ -6,6 +6,8 @@ #include #include +static Gtk::Label *o_position; +static Glib::RefPtr o_pos_bar; static inline bool audio_playing() { @@ -32,12 +34,9 @@ void o_fix_buttons() */ static bool on_timeout() { - Gtk::Label *position = lib :: get_widget("o_cur_position"); - Glib::RefPtr bar = lib :: get_object("o_progress"); - - position->set_text(audio :: position_str()); - bar->set_upper(audio :: duration()); - bar->set_value(audio :: position()); + o_position->set_text(audio :: position_str()); + o_pos_bar->set_upper(audio :: duration()); + o_pos_bar->set_value(audio :: position()); o_fix_buttons(); return audio_playing(); @@ -74,6 +73,9 @@ void o_next() void controls_init() { + o_position = lib :: get_widget("o_cur_position"); + o_pos_bar = lib :: get_object("o_progress"); + connect_button("o_play", o_play); connect_button("o_pause", o_pause); connect_button("o_stop", audio::stop);