region: Tick an unselected row when enter is pressed

This makes the dialog easier to use via keyboard navigation since
otherwise we would just dismiss the dialog with the current selection
on enter when the user actually intended to change the selection.

https://bugzilla.gnome.org/show_bug.cgi?id=752001
This commit is contained in:
Rui Matos 2015-07-07 17:58:47 +02:00
parent 73644fdecc
commit 7916040cea

View file

@ -471,6 +471,26 @@ row_activated (GtkListBox *box,
}
}
static void
activate_default (GtkWindow *window,
GtkDialog *chooser)
{
CcFormatChooserPrivate *priv = GET_PRIVATE (chooser);
GtkWidget *focus;
gchar *locale_id;
focus = gtk_window_get_focus (window);
if (!focus)
return;
locale_id = g_object_get_data (G_OBJECT (focus), "locale-id");
if (g_strcmp0 (locale_id, priv->region) == 0)
return;
g_signal_stop_emission_by_name (window, "activate-default");
gtk_widget_activate (focus);
}
static void
cc_format_chooser_private_free (gpointer data)
{
@ -546,6 +566,9 @@ cc_format_chooser_new (GtkWidget *parent)
gtk_window_set_transient_for (GTK_WINDOW (chooser), GTK_WINDOW (parent));
g_signal_connect (chooser, "activate-default",
G_CALLBACK (activate_default), chooser);
return chooser;
}