gui/audio: Set the pause entry text based on remaining tracks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
fd68cdf70a
commit
af5bafb03e
22
gui/audio.c
22
gui/audio.c
|
@ -42,16 +42,38 @@ static void __gui_audio_load(struct track *track)
|
|||
g_free(duration);
|
||||
}
|
||||
|
||||
static void __gui_audio_set_pause_text(int n, GstState state)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
if (n == -1) {
|
||||
if (state == GST_STATE_PLAYING)
|
||||
text = g_strdup("Keep playing");
|
||||
else
|
||||
text = g_strdup("Paused");
|
||||
} else if (n == 0)
|
||||
text = g_strdup("Pause after this track");
|
||||
else if (n == 1)
|
||||
text = g_strdup("Pause after next track");
|
||||
else
|
||||
text = g_strdup_printf("Pause after %d tracks", n);
|
||||
|
||||
gtk_entry_set_text(gui_pause_entry(), text);
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
static void __gui_audio_change_state(GstState state)
|
||||
{
|
||||
bool playing = (state == GST_STATE_PLAYING);
|
||||
gtk_widget_set_visible(GTK_WIDGET(gui_play_button()), !playing);
|
||||
gtk_widget_set_visible(GTK_WIDGET(gui_pause_button()), playing);
|
||||
__gui_audio_set_pause_text(audio_get_pause_count(), state);
|
||||
}
|
||||
|
||||
static void __gui_audio_config_pause(int n)
|
||||
{
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(gui_pause_after()), n + 1);
|
||||
__gui_audio_set_pause_text(n, audio_cur_state());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ static void test_audio_load()
|
|||
g_assert_cmpstr(gtk_label_get_text(gui_duration()), ==, length);
|
||||
g_assert_cmpstr(gtk_label_get_text(gui_position()), ==, "0:00");
|
||||
|
||||
test_main_loop();
|
||||
test_main_loop();
|
||||
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_play_button())));
|
||||
g_assert_true( gtk_widget_is_visible(GTK_WIDGET(gui_pause_button())));
|
||||
|
@ -67,12 +68,14 @@ static void test_audio_buttons()
|
|||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PAUSED);
|
||||
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_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Paused");
|
||||
|
||||
gtk_button_clicked(gui_play_button());
|
||||
test_main_loop();
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_play_button())));
|
||||
g_assert_true( gtk_widget_is_visible(GTK_WIDGET(gui_pause_button())));
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Keep playing");
|
||||
|
||||
gtk_button_clicked(gui_next_button());
|
||||
if (track_get(0)->tr_track == 1)
|
||||
|
@ -81,17 +84,37 @@ static void test_audio_buttons()
|
|||
|
||||
gtk_button_clicked(gui_prev_button());
|
||||
g_assert(audio_cur_track() == track_get(0));
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(gui_pause_after()), 3);
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Pause after 2 tracks");
|
||||
|
||||
test_audio_eos();
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(gtk_combo_box_get_active(
|
||||
GTK_COMBO_BOX(gui_pause_after())), ==, 2);
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Pause after next track");
|
||||
|
||||
gtk_button_clicked(gui_pause_button());
|
||||
test_main_loop();
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PAUSED);
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Pause after next track");
|
||||
gtk_button_clicked(gui_play_button());
|
||||
test_main_loop();
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Pause after next track");
|
||||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(gui_pause_after()), 2);
|
||||
test_audio_eos();
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
g_assert_cmpuint(gtk_combo_box_get_active(
|
||||
GTK_COMBO_BOX(gui_pause_after())), ==, 1);
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Pause after this track");
|
||||
|
||||
test_audio_eos();
|
||||
test_main_loop();
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PAUSED);
|
||||
g_assert_cmpuint(gtk_combo_box_get_active(
|
||||
GTK_COMBO_BOX(gui_pause_after())), ==, 0);
|
||||
test_main_loop(); /* Give the text entry time to update */
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Paused");
|
||||
|
||||
gtk_scale_button_set_value(gui_volume_button(), 50);
|
||||
g_assert_cmpuint(audio_get_volume(), ==, 50);
|
||||
|
|
Loading…
Reference in New Issue