gui: Move pause count widgets into gst.cpp

These values affect audio playback, so they should go with the other
audio widgets.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-01-15 09:34:17 -05:00
parent 88136c0c95
commit 4643a5ff22
3 changed files with 21 additions and 42 deletions

View File

@ -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<Gtk::Scale>("o_seek");
o_stop = lib :: get_widget<Gtk::Button>("o_stop");
o_count = lib :: get_widget<Gtk::SpinButton>("o_pause_count");
o_enabled = lib :: get_widget<Gtk::CheckButton>("o_pause_enabled");
o_album = lib :: get_widget<Gtk::Label>("o_album");
o_artist = lib :: get_widget<Gtk::Label>("o_artist");
o_duration = lib :: get_widget<Gtk::Label>("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);
}

View File

@ -11,36 +11,6 @@
#include <gui/ocarina.h>
#include <gui/tabs.h>
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<Gtk::CheckButton>("o_pause_enabled");
Gtk::SpinButton *p_count = lib :: get_widget<Gtk::SpinButton>("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<Gtk::SpinButton>("o_pause_count");
enabled = lib :: get_widget<Gtk::CheckButton>("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());

View File

@ -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);