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 <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-09-11 08:09:30 -04:00
parent 62cdc4c909
commit 5e7a25e007
1 changed files with 8 additions and 6 deletions

View File

@ -6,6 +6,8 @@
#include <core/driver.h>
#include <gui/ocarina.h>
static Gtk::Label *o_position;
static Glib::RefPtr<Gtk::Adjustment> 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<Gtk::Label>("o_cur_position");
Glib::RefPtr<Gtk::Adjustment> bar = lib :: get_object<Gtk::Adjustment>("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<Gtk::Label>("o_cur_position");
o_pos_bar = lib :: get_object<Gtk::Adjustment>("o_progress");
connect_button("o_play", o_play);
connect_button("o_pause", o_pause);
connect_button("o_stop", audio::stop);