From 3a256c3c6744b1bfd53e4670173603172c2d5de7 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 25 Jul 2010 23:31:18 +0100 Subject: [PATCH] Set defaults for geonamesearch dialogs. --- src/geonamessearch.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/geonamessearch.c b/src/geonamessearch.c index a09a501f..b63d3eed 100644 --- a/src/geonamessearch.c +++ b/src/geonamessearch.c @@ -98,6 +98,7 @@ static void none_found(VikWindow *vw) GtkWidget *search_label = gtk_label_new(_("No entries found!")); gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), search_label, FALSE, FALSE, 5 ); + gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); gtk_widget_show_all(dialog); gtk_dialog_run ( GTK_DIALOG(dialog) ); @@ -135,6 +136,13 @@ GList *a_select_geoname_from_list(GtkWindow *parent, GList *geonames, gboolean m GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); + /* When something is selected then OK */ + gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT ); + GtkWidget *response_w = NULL; +#if GTK_CHECK_VERSION (2, 20, 0) + /* Default to not apply - as initially nothing is selected! */ + response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_REJECT ); +#endif GtkWidget *label = gtk_label_new ( msg ); GtkTreeStore *store; if (multiple_selection_allowed) @@ -188,6 +196,8 @@ GList *a_select_geoname_from_list(GtkWindow *parent, GList *geonames, gboolean m gtk_widget_show ( label ); gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), view, FALSE, FALSE, 0); gtk_widget_show ( view ); + if ( response_w ) + gtk_widget_grab_focus ( response_w ); while ( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT ) { GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); -- 2.39.5