gui/audio: Add a popover menu to clear automatic pausing
The popover is shown whenever the user pauses manually with automatic pausing enabled. This will give the user a chance to disable pausing if it is no longer needed. Implements #113: Cancel "pause after" configuration when user manually pauses Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
94f3a7f387
commit
f167f968ba
21
gui/audio.c
21
gui/audio.c
|
@ -86,6 +86,13 @@ struct audio_callbacks audio_cb = {
|
|||
};
|
||||
|
||||
|
||||
void __gui_audio_pause(GtkButton *button, gpointer data)
|
||||
{
|
||||
audio_pause();
|
||||
if (audio_get_pause_count() > -1)
|
||||
gtk_popover_popup(gui_pause_popover());
|
||||
}
|
||||
|
||||
void __gui_audio_pause_change_text(GtkEntry *entry, gpointer data)
|
||||
{
|
||||
const gchar *text = gtk_entry_get_text(entry);
|
||||
|
@ -123,6 +130,20 @@ void __gui_audio_pause_dec(GtkButton *button, gpointer data)
|
|||
audio_pause_after(audio_get_pause_count() - 1);
|
||||
}
|
||||
|
||||
void __gui_audio_pause_popover_popdown(GtkButton *button, gpointer data)
|
||||
{
|
||||
gtk_popover_popdown(gui_pause_popover());
|
||||
#ifdef CONFIG_TESTING
|
||||
gtk_widget_hide(GTK_WIDGET(gui_pause_popover()));
|
||||
#endif /* CONFIG_TESTING */
|
||||
}
|
||||
|
||||
void __gui_audio_pause_popover_clear(GtkButton *button, gpointer data)
|
||||
{
|
||||
audio_pause_after(-1);
|
||||
__gui_audio_pause_popover_popdown(button, data);
|
||||
}
|
||||
|
||||
void __gui_audio_seek(GtkRange *range, GtkScrollType type,
|
||||
double value, gpointer data)
|
||||
{
|
||||
|
|
|
@ -88,6 +88,11 @@ static inline GtkButton *gui_pause_up(void)
|
|||
return GTK_BUTTON(gui_builder_widget("pause_up"));
|
||||
}
|
||||
|
||||
static inline GtkPopover *gui_pause_popover(void)
|
||||
{
|
||||
return GTK_POPOVER(gui_builder_widget("pause_popover"));
|
||||
}
|
||||
|
||||
/* Called to get the seeking GtkAdjustment. */
|
||||
static inline GtkAdjustment *gui_seek(void)
|
||||
{
|
||||
|
|
|
@ -266,7 +266,7 @@
|
|||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<signal name="can-activate-accel" handler="__gui_audio_can_accel" swapped="no"/>
|
||||
<signal name="clicked" handler="audio_pause" swapped="no"/>
|
||||
<signal name="clicked" handler="__gui_audio_pause" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
|
@ -1143,4 +1143,55 @@ audio-volume-medium</property>
|
|||
<widget name="filter_how"/>
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkPopover" id="pause_popover">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="relative_to">play_button</property>
|
||||
<property name="position">bottom</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="row_homogeneous">True</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Cancel "pause after" configuration?</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="pause_popover_no">
|
||||
<property name="label" translatable="yes">No</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="__gui_audio_pause_popover_popdown" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="pause_popover_yes">
|
||||
<property name="label" translatable="yes">Yes</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="clicked" handler="__gui_audio_pause_popover_clear" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -28,6 +28,7 @@ static void test_audio_init()
|
|||
==, 100);
|
||||
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_popover())));
|
||||
}
|
||||
|
||||
static void test_audio_load()
|
||||
|
@ -66,6 +67,7 @@ static void test_audio_buttons()
|
|||
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())));
|
||||
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_pause_popover())));
|
||||
|
||||
gtk_button_clicked(gui_play_button());
|
||||
test_main_loop();
|
||||
|
@ -108,6 +110,25 @@ static void test_audio_buttons()
|
|||
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())));
|
||||
g_assert_true(gtk_widget_is_visible(GTK_WIDGET(gui_pause_popover())));
|
||||
|
||||
gtk_button_clicked(GTK_BUTTON(gui_builder_widget("pause_popover_yes")));
|
||||
test_main_loop();
|
||||
g_assert_cmpint(audio_get_pause_count(), ==, -1);
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Paused");
|
||||
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_pause_popover())));
|
||||
|
||||
gtk_button_clicked(gui_play_button());
|
||||
gtk_button_clicked(gui_pause_up());
|
||||
gtk_button_clicked(gui_pause_up());
|
||||
gtk_button_clicked(gui_pause_button());
|
||||
g_assert_true(gtk_widget_is_visible(GTK_WIDGET(gui_pause_popover())));
|
||||
|
||||
gtk_button_clicked(GTK_BUTTON(gui_builder_widget("pause_popover_no")));
|
||||
g_assert_cmpint(audio_get_pause_count(), ==, 1);
|
||||
g_assert_cmpstr(gtk_entry_get_text(gui_pause_entry()), ==, "Pause after next track");
|
||||
g_assert_false(gtk_widget_is_visible(GTK_WIDGET(gui_pause_popover())));
|
||||
|
||||
gtk_button_clicked(gui_play_button());
|
||||
test_main_loop();
|
||||
g_assert_cmpuint(audio_cur_state(), ==, GST_STATE_PLAYING);
|
||||
|
|
Loading…
Reference in New Issue