48 lines
974 B
C++
48 lines
974 B
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <lib/lib.h>
|
|
#include <core/audio.h>
|
|
#include <core/driver.h>
|
|
|
|
|
|
static inline bool audio_playing()
|
|
{
|
|
return driver :: get_driver()->is_playing();
|
|
}
|
|
|
|
|
|
/*
|
|
* Timeout function is called every half-second.
|
|
*/
|
|
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());
|
|
|
|
return audio_playing();
|
|
}
|
|
|
|
static void enable_timeout()
|
|
{
|
|
Glib::signal_timeout().connect(sigc::ptr_fun(on_timeout), 500);
|
|
}
|
|
|
|
|
|
static void hide_show_buttons(const std::string &hide, const std::string &show)
|
|
{
|
|
lib :: get_widget<Gtk::Button>(hide)->hide();
|
|
lib :: get_widget<Gtk::Button>(show)->show();
|
|
}
|
|
|
|
void o_play()
|
|
{
|
|
audio :: play();
|
|
hide_show_buttons("o_play", "o_pause");
|
|
enable_timeout();
|
|
}
|