gui/audio: Change down-button sensitivity based on pause count
The pause count can't go below -1, so disable the button once we reach this limit. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
af5bafb03e
commit
994234caf2
|
@ -44,9 +44,11 @@ static void __gui_audio_load(struct track *track)
|
|||
|
||||
static void __gui_audio_set_pause_text(int n, GstState state)
|
||||
{
|
||||
bool sensitive = true;
|
||||
gchar *text;
|
||||
|
||||
if (n == -1) {
|
||||
sensitive = false;
|
||||
if (state == GST_STATE_PLAYING)
|
||||
text = g_strdup("Keep playing");
|
||||
else
|
||||
|
@ -58,6 +60,7 @@ static void __gui_audio_set_pause_text(int n, GstState state)
|
|||
else
|
||||
text = g_strdup_printf("Pause after %d tracks", n);
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(gui_pause_down()), sensitive);
|
||||
gtk_entry_set_text(gui_pause_entry(), text);
|
||||
g_free(text);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ static void test_audio_buttons()
|
|||
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");
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(gui_pause_down())));
|
||||
|
||||
gtk_button_clicked(gui_play_button());
|
||||
test_main_loop();
|
||||
|
@ -86,33 +87,39 @@ static void test_audio_buttons()
|
|||
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");
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(gui_pause_down())));
|
||||
|
||||
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");
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(gui_pause_down())));
|
||||
|
||||
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");
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(gui_pause_down())));
|
||||
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");
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(gui_pause_down())));
|
||||
|
||||
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");
|
||||
g_assert_true(gtk_widget_get_sensitive(GTK_WIDGET(gui_pause_down())));
|
||||
|
||||
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);
|
||||
g_assert_false(gtk_widget_get_sensitive(GTK_WIDGET(gui_pause_down())));
|
||||
test_main_loop(); /* Give the text entry time to update */
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Paused");
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user