gui/audio: Add a test for the volume button
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
96e5749e7f
commit
8fd4e4c637
|
@ -75,7 +75,8 @@ void __gui_audio_seek(GtkRange *range, GtkScrollType type,
|
||||||
audio_seek(value * GST_SECOND);
|
audio_seek(value * GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __audio_volume_changed(GtkScaleButton *button, gdouble value, gpointer data)
|
void __gui_audio_volume_changed(GtkScaleButton *button, gdouble value,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
audio_set_volume((unsigned int)value);
|
audio_set_volume((unsigned int)value);
|
||||||
}
|
}
|
||||||
|
@ -90,9 +91,8 @@ gboolean __gui_audio_can_accel(GtkWidget *widget, guint signal_id)
|
||||||
|
|
||||||
void gui_audio_init()
|
void gui_audio_init()
|
||||||
{
|
{
|
||||||
GtkScaleButton *volume = GTK_SCALE_BUTTON(gui_builder_widget("o_volume"));
|
gtk_scale_button_set_value(gui_volume_button(), audio_get_volume());
|
||||||
gtk_scale_button_set_value(volume, audio_get_volume());
|
gtk_button_set_relief(GTK_BUTTON(gui_volume_button()), GTK_RELIEF_NORMAL);
|
||||||
gtk_button_set_relief(GTK_BUTTON(volume), GTK_RELIEF_NORMAL);
|
|
||||||
|
|
||||||
audio_timeout = g_timeout_add(500, gui_audio_timeout, NULL);
|
audio_timeout = g_timeout_add(500, gui_audio_timeout, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,4 +83,10 @@ static inline GtkAdjustment *gui_seek(void)
|
||||||
return GTK_ADJUSTMENT(gui_builder_object("seek"));
|
return GTK_ADJUSTMENT(gui_builder_object("seek"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Called to get the volume button. */
|
||||||
|
static inline GtkScaleButton *gui_volume_button(void)
|
||||||
|
{
|
||||||
|
return GTK_SCALE_BUTTON(gui_builder_widget("volume_button"));
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* OCARINA_GUI_AUDIO_H */
|
#endif /* OCARINA_GUI_AUDIO_H */
|
||||||
|
|
|
@ -431,7 +431,7 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkVolumeButton" id="o_volume">
|
<object class="GtkVolumeButton" id="volume_button">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="focus_on_click">False</property>
|
<property name="focus_on_click">False</property>
|
||||||
|
@ -446,7 +446,7 @@ audio-volume-high
|
||||||
audio-volume-low
|
audio-volume-low
|
||||||
audio-volume-medium</property>
|
audio-volume-medium</property>
|
||||||
<property name="use_symbolic">False</property>
|
<property name="use_symbolic">False</property>
|
||||||
<signal name="value-changed" handler="__audio_volume_changed" swapped="no"/>
|
<signal name="value-changed" handler="__gui_audio_volume_changed" swapped="no"/>
|
||||||
<child internal-child="plus_button">
|
<child internal-child="plus_button">
|
||||||
<object class="GtkButton">
|
<object class="GtkButton">
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
@ -1123,7 +1123,7 @@ audio-volume-medium</property>
|
||||||
<object class="GtkSizeGroup">
|
<object class="GtkSizeGroup">
|
||||||
<widgets>
|
<widgets>
|
||||||
<widget name="random_button"/>
|
<widget name="random_button"/>
|
||||||
<widget name="o_volume"/>
|
<widget name="volume_button"/>
|
||||||
</widgets>
|
</widgets>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkSizeGroup">
|
<object class="GtkSizeGroup">
|
||||||
|
|
|
@ -31,6 +31,8 @@ static void test_audio_init()
|
||||||
==, "(disabled)");
|
==, "(disabled)");
|
||||||
g_assert_cmpuint(gtk_combo_box_get_active(
|
g_assert_cmpuint(gtk_combo_box_get_active(
|
||||||
GTK_COMBO_BOX(gui_pause_after())), ==, 0);
|
GTK_COMBO_BOX(gui_pause_after())), ==, 0);
|
||||||
|
g_assert_cmpfloat(gtk_scale_button_get_value(gui_volume_button()),
|
||||||
|
==, 100);
|
||||||
g_assert_true( gtk_widget_is_visible(GTK_WIDGET(gui_play_button())));
|
g_assert_true( gtk_widget_is_visible(GTK_WIDGET(gui_play_button())));
|
||||||
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_pause_button())));
|
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_pause_button())));
|
||||||
}
|
}
|
||||||
|
@ -90,6 +92,13 @@ static void test_audio_buttons()
|
||||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PAUSED);
|
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PAUSED);
|
||||||
g_assert_cmpuint(gtk_combo_box_get_active(
|
g_assert_cmpuint(gtk_combo_box_get_active(
|
||||||
GTK_COMBO_BOX(gui_pause_after())), ==, 0);
|
GTK_COMBO_BOX(gui_pause_after())), ==, 0);
|
||||||
|
|
||||||
|
gtk_scale_button_set_value(gui_volume_button(), 50);
|
||||||
|
g_assert_cmpuint(audio_get_volume(), ==, 50);
|
||||||
|
gtk_scale_button_set_value(gui_volume_button(), 0);
|
||||||
|
g_assert_cmpuint(audio_get_volume(), ==, 0);
|
||||||
|
gtk_scale_button_set_value(gui_volume_button(), 100);
|
||||||
|
g_assert_cmpuint(audio_get_volume(), ==, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_audio_seek()
|
static void test_audio_seek()
|
||||||
|
|
Loading…
Reference in New Issue