gui/audio: Add GtkVolumeButton for changing volume

Implements #38: Add volume slider
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-08-18 09:31:53 -04:00
parent d8c3fb9ace
commit 4a4ec3fa36
2 changed files with 57 additions and 0 deletions

View File

@ -71,6 +71,11 @@ void __audio_seek(GtkRange *range, GtkScrollType type, double value, gpointer da
audio_seek(value * GST_SECOND);
}
void __audio_volume_changed(GtkScaleButton *button, gdouble value, gpointer data)
{
audio_set_volume((unsigned int)value);
}
void __audio_favorite(GtkToggleButton *toggle, gpointer data)
{
if (gtk_toggle_button_get_active(toggle))
@ -117,7 +122,10 @@ struct audio_ops audio_ops = {
void gui_audio_init()
{
GtkScaleButton *volume = GTK_SCALE_BUTTON(gui_builder_widget("o_volume"));
g_timeout_add(500, __audio_timeout, gui_builder_object("o_progress"));
gtk_scale_button_set_value(volume, audio_get_volume());
gtk_button_set_relief(GTK_BUTTON(volume), GTK_RELIEF_NORMAL);
}
#ifdef CONFIG_TESTING

View File

@ -2,6 +2,12 @@
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">100</property>
<property name="value">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkImage" id="image">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -459,6 +465,49 @@
<property name="non_homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkVolumeButton" id="o_volume">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="size">button</property>
<property name="adjustment">adjustment1</property>
<property name="icons">audio-volume-muted
audio-volume-high
audio-volume-low
audio-volume-medium</property>
<property name="use_symbolic">False</property>
<signal name="value-changed" handler="__audio_volume_changed" swapped="no"/>
<child internal-child="plus_button">
<object class="GtkButton">
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="relief">none</property>
</object>
</child>
<child internal-child="minus_button">
<object class="GtkButton">
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="relief">none</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
<property name="non_homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">3</property>