gui/audio: Configure pause-after-N through glade

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-24 13:59:30 -05:00
parent 2d45e9e5c4
commit 286085d248
2 changed files with 22 additions and 30 deletions

View File

@ -8,9 +8,6 @@
#include <gui/builder.h>
static GtkSpinButton *o_count;
static GtkToggleButton *o_enabled;
const gchar *TITLE_FMT = "<span size='xx-large'>%s</span>";
const gchar *ARTIST_FMT = "<span size='x-large'>By: %s</span>";
const gchar *ALBUM_FMT = "<span size='x-large'>From: %s</span>";
@ -58,12 +55,25 @@ static void __audio_change_state(GstState state)
static void __audio_config_pause(int n)
{
if (n == -1)
gtk_toggle_button_set_active(o_enabled, false);
else {
gtk_spin_button_set_value(o_count, n);
gtk_toggle_button_set_active(o_enabled, true);
}
GtkToggleButton *enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled"));
if (n >= 0)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count")), n);
gtk_toggle_button_set_active(enabled, n >= 0);
}
void __audio_pause_count(GtkSpinButton *count)
{
audio_pause_after(gtk_spin_button_get_value(count));
}
void __audio_pause_enabled(GtkToggleButton *enabled, GtkSpinButton *count)
{
int val = -1;
if (gtk_toggle_button_get_active(enabled))
val = gtk_spin_button_get_value(count);
audio_pause_after(val);
}
void __audio_seek(GtkScrollType type, double value)
@ -83,34 +93,14 @@ static int __audio_timeout(gpointer data)
}
struct audio_ops audio_ops = {
__audio_load,
__audio_change_state,
__audio_config_pause,
};
static void on_pause_count()
{
gtk_toggle_button_set_active(o_enabled, true);
audio_pause_after(gtk_spin_button_get_value(o_count));
}
static void on_pause_enabled()
{
if (!gtk_toggle_button_get_active(o_enabled))
audio_pause_after(-1);
else
audio_pause_after(gtk_spin_button_get_value(o_count));
}
void gui_audio_init()
{
o_count = GTK_SPIN_BUTTON(gui_builder_widget("o_pause_count"));
o_enabled = GTK_TOGGLE_BUTTON(gui_builder_widget("o_pause_enabled"));
g_signal_connect(o_count, "changed", G_CALLBACK(on_pause_count), NULL);
g_signal_connect(o_enabled, "toggled", G_CALLBACK(on_pause_enabled), NULL);
g_timeout_add(500, __audio_timeout, gui_builder_object("o_progress"));
}

View File

@ -713,6 +713,7 @@ Manager</property>
<property name="focus_on_click">False</property>
<property name="xalign">0.5</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="__audio_pause_enabled" object="o_pause_count" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@ -727,6 +728,7 @@ Manager</property>
<property name="caps_lock_warning">False</property>
<property name="adjustment">adjustment1</property>
<property name="numeric">True</property>
<signal name="changed" handler="__audio_pause_count" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>