gui/audio: Respond to the user editing the pause entry
We have to disable the up and down buttons when typing in the entry in case the user decides to type a minus or plus sign. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
cd7364300e
commit
1836104f40
27
gui/audio.c
27
gui/audio.c
|
@ -92,6 +92,33 @@ void __gui_audio_pause_changed(GtkComboBox *combo, gpointer data)
|
|||
audio_pause_after(gtk_combo_box_get_active(combo) - 1);
|
||||
}
|
||||
|
||||
void __gui_audio_pause_change_text(GtkEntry *entry, gpointer data)
|
||||
{
|
||||
const gchar *text = gtk_entry_get_text(entry);
|
||||
int n = audio_get_pause_count();
|
||||
unsigned int i;
|
||||
|
||||
if (g_str_match_string("Keep", text, true))
|
||||
n = -1;
|
||||
else if (g_str_match_string("This", text, true))
|
||||
n = 0;
|
||||
else if (g_str_match_string("Next", text, true))
|
||||
n = 1;
|
||||
else {
|
||||
for (i = 0; text[i] != '\0'; i++) {
|
||||
if (!g_ascii_isdigit(text[i]))
|
||||
continue;
|
||||
if (i > 0 && text[i-1] == '-')
|
||||
i -= 1;
|
||||
n = g_strtod(text + i, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!audio_pause_after(n))
|
||||
__gui_audio_set_pause_text(audio_get_pause_count(), audio_cur_state());
|
||||
}
|
||||
|
||||
void __gui_audio_pause_inc(GtkButton *button, gpointer data)
|
||||
{
|
||||
audio_pause_after(audio_get_pause_count() + 1);
|
||||
|
|
|
@ -737,6 +737,7 @@ audio-volume-medium</property>
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="text" translatable="yes">Paused</property>
|
||||
<signal name="activate" handler="__gui_audio_pause_change_text" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -750,6 +751,7 @@ audio-volume-medium</property>
|
|||
<property name="sensitive">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="can-activate-accel" handler="__gui_audio_can_accel" swapped="no"/>
|
||||
<signal name="clicked" handler="__gui_audio_pause_dec" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
|
@ -775,6 +777,7 @@ audio-volume-medium</property>
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="can-activate-accel" handler="__gui_audio_can_accel" swapped="no"/>
|
||||
<signal name="clicked" handler="__gui_audio_pause_inc" swapped="no"/>
|
||||
<child>
|
||||
<object class="GtkImage">
|
||||
|
|
|
@ -96,7 +96,9 @@ static void test_audio_buttons()
|
|||
gtk_button_clicked(gui_pause_down());
|
||||
g_assert_cmpint(audio_get_pause_count(), ==, -1);
|
||||
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(gui_pause_after()), 3);
|
||||
gtk_entry_set_text(gui_pause_entry(), "2 tracks");
|
||||
gtk_widget_activate(GTK_WIDGET(gui_pause_entry()));
|
||||
g_assert_cmpint(audio_get_pause_count(), ==, 2);
|
||||
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())));
|
||||
|
||||
|
|
Loading…
Reference in New Issue