gui: Move position tracking into gst code
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
e539a2d208
commit
434b278b61
|
@ -5,21 +5,6 @@
|
|||
#include <core/audio.h>
|
||||
#include <gui/ocarina.h>
|
||||
|
||||
static Gtk::Label *o_position;
|
||||
static Glib::RefPtr<Gtk::Adjustment> o_pos_bar;
|
||||
|
||||
/*
|
||||
* Timeout function is called every half-second.
|
||||
*/
|
||||
static bool on_timeout()
|
||||
{
|
||||
o_position->set_text(audio :: position_str());
|
||||
o_pos_bar->set_upper(audio :: duration());
|
||||
o_pos_bar->set_value(audio :: position());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void o_toggle()
|
||||
{
|
||||
if (audio :: get_driver()->is_playing())
|
||||
|
@ -27,11 +12,3 @@ void o_toggle()
|
|||
else
|
||||
audio :: play();
|
||||
}
|
||||
|
||||
|
||||
void controls_init()
|
||||
{
|
||||
o_position = lib :: get_widget<Gtk::Label>("o_cur_position");
|
||||
o_pos_bar = lib :: get_object<Gtk::Adjustment>("o_progress");
|
||||
lib :: schedule(on_timeout, 500);
|
||||
}
|
||||
|
|
15
gui/gst.cpp
15
gui/gst.cpp
|
@ -20,6 +20,9 @@ static Gtk::Button *o_prev;
|
|||
static Gtk::Scale *o_seek;
|
||||
static Gtk::Button *o_stop;
|
||||
|
||||
static Gtk::Label *o_position;
|
||||
static Glib::RefPtr<Gtk::Adjustment> o_pos_bar;
|
||||
|
||||
|
||||
static bool gst_change_state(GstState state)
|
||||
{
|
||||
|
@ -150,6 +153,14 @@ static bool on_seek(Gtk::ScrollType type, double value)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool on_timeout()
|
||||
{
|
||||
o_position->set_text(audio :: position_str());
|
||||
o_pos_bar->set_upper(audio :: duration());
|
||||
o_pos_bar->set_value(audio :: position());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void init_gst(int *argc, char ***argv)
|
||||
{
|
||||
|
@ -166,6 +177,9 @@ void init_gst(int *argc, char ***argv)
|
|||
o_seek = lib :: get_widget<Gtk::Scale>("o_seek");
|
||||
o_stop = lib :: get_widget<Gtk::Button>("o_stop");
|
||||
|
||||
o_position = lib :: get_widget<Gtk::Label>("o_cur_position");
|
||||
o_pos_bar = lib :: get_object<Gtk::Adjustment>("o_progress");
|
||||
|
||||
o_next->signal_clicked().connect(sigc::ptr_fun(on_next));
|
||||
o_pause->signal_clicked().connect(sigc::ptr_fun(audio :: pause));
|
||||
o_play->signal_clicked().connect(sigc::ptr_fun(audio :: play));
|
||||
|
@ -174,6 +188,7 @@ void init_gst(int *argc, char ***argv)
|
|||
o_stop->signal_clicked().connect(sigc::ptr_fun(audio :: stop));
|
||||
|
||||
gst_bus_add_watch(gst_bus, on_gst_message, NULL);
|
||||
lib :: schedule(on_timeout, 500);
|
||||
}
|
||||
|
||||
void quit_gst()
|
||||
|
|
|
@ -129,7 +129,6 @@ Gtk::Window *setup_gui()
|
|||
on_track_loaded(audio :: current_track());
|
||||
|
||||
/* Set up other tabs */
|
||||
controls_init();
|
||||
collection_mgr_init();
|
||||
init_tabs();
|
||||
return window_init();
|
||||
|
|
|
@ -7,6 +7,5 @@
|
|||
void o_toggle();
|
||||
void on_next();
|
||||
|
||||
void controls_init();
|
||||
|
||||
#endif /* OCARINA_GUI_CONTROLS_H */
|
||||
|
|
Loading…
Reference in New Issue