]> git.street.me.uk Git - andy/viking.git/blobdiff - src/vikgoto.c
Add Show/Hide all Layers within an Aggregate Layer.
[andy/viking.git] / src / vikgoto.c
index 27a7ce8882299695b31f917b4fe48df31f03320e..ebd1b753528e3c2d9e8c72d142d5201ec3ad7483 100644 (file)
@@ -32,9 +32,8 @@
 
 #include "viking.h"
 #include "util.h"
-#include "curl_download.h"
-
 #include "vikgototool.h"
+#include "vikgoto.h"
 
 static gchar *last_goto_str = NULL;
 static VikCoord *last_coord = NULL;
@@ -46,9 +45,8 @@ int last_goto_tool = 0;
 
 void vik_goto_register ( VikGotoTool *tool )
 {
-  IS_VIK_GOTO_TOOL( tool );
-
-  goto_tools_list = g_list_append ( goto_tools_list, g_object_ref ( tool ) );
+  if ( IS_VIK_GOTO_TOOL( tool ) )
+    goto_tools_list = g_list_append ( goto_tools_list, g_object_ref ( tool ) );
 }
 
 void vik_goto_unregister_all ()
@@ -90,7 +88,7 @@ static gboolean prompt_try_again(VikWindow *vw)
   gtk_window_set_title(GTK_WINDOW(dialog), _("goto"));
 
   GtkWidget *goto_label = gtk_label_new(_("I don't know that place. Do you want another goto?"));
-  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), goto_label, FALSE, FALSE, 5 );
+  gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), goto_label, FALSE, FALSE, 5 );
   gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
   gtk_widget_show_all(dialog);
 
@@ -109,15 +107,14 @@ static gchar *  a_prompt_for_goto_string(VikWindow *vw)
   gtk_window_set_title(GTK_WINDOW(dialog), _("goto"));
 
   GtkWidget *tool_label = gtk_label_new(_("goto provider:"));
-  GtkWidget *tool_list = gtk_combo_box_new_text ();
-
+  GtkWidget *tool_list = vik_combo_box_text_new ();
   GList *current = g_list_first (goto_tools_list);
   while (current != NULL)
   {
     char *label = NULL;
     VikGotoTool *tool = current->data;
     label = vik_goto_tool_get_label (tool);
-    gtk_combo_box_append_text ( GTK_COMBO_BOX( tool_list ), label);
+    vik_combo_box_text_append ( tool_list, label );
     current = g_list_next (current);
   }
   /* Set the previously selected provider as default */
@@ -128,13 +125,19 @@ static gchar *  a_prompt_for_goto_string(VikWindow *vw)
   if (last_goto_str)
     gtk_entry_set_text(GTK_ENTRY(goto_entry), last_goto_str);
 
-  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), tool_label, FALSE, FALSE, 5 );
-  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), tool_list, FALSE, FALSE, 5 );
-  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), goto_label, FALSE, FALSE, 5 );
-  gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), goto_entry, FALSE, FALSE, 5 );
+  // 'ok' when press return in the entry
+  g_signal_connect_swapped (goto_entry, "activate", G_CALLBACK(a_dialog_response_accept), dialog);
+
+  gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), tool_label, FALSE, FALSE, 5 );
+  gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), tool_list, FALSE, FALSE, 5 );
+  gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), goto_label, FALSE, FALSE, 5 );
+  gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), goto_entry, FALSE, FALSE, 5 );
   gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
   gtk_widget_show_all(dialog);
 
+  // Ensure the text field has focus so we can start typing straight away
+  gtk_widget_grab_focus ( goto_entry );
+
   if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_ACCEPT ) {
     gtk_widget_destroy(dialog);
     return NULL;