#include "config.h"
+#include <stdlib.h>
#include <glib/gstdio.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <locale.h>
+#include <gtkmap.h>
#include "ui-maemo.h"
#include "hildon-wrappers.h"
if (dialog)
gtk_widget_destroy(dialog);
}
+
+gboolean
+dialog_goto_latlon(GtkWidget *window, GtkWidget *map)
+{
+GtkWidget *dialog;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *txt_lat;
+GtkWidget *txt_lon;
+gchar buffer[16];
+gdouble lat, lon;
+
+dialog = gtk_dialog_new_with_buttons(_("Go to Lat/Lon"),
+ GTK_WINDOW(window),
+ GTK_DIALOG_MODAL, GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT, NULL);
+
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), table = gtk_table_new(2, 3, FALSE), TRUE, TRUE, 0);
+
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Latitude")),0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+
+gtk_table_attach(GTK_TABLE(table), txt_lat = gtk_entry_new(), 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Longitude")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+
+gtk_table_attach(GTK_TABLE(table), txt_lon = gtk_entry_new(), 1, 2, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
+
+#if defined (WITH_DEVICE_770) && !defined(WITH_HILDON_NEW)
+g_object_set(G_OBJECT(txt_lat), HILDON_INPUT_MODE_HINT, HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
+g_object_set(G_OBJECT(txt_lon), HILDON_INPUT_MODE_HINT, HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
+#endif
+
+gtk_map_get_center_latlon(map, &lat, &lon);
+
+g_snprintf(buffer, sizeof(buffer), "%.06f", lat);
+gtk_label_set_text(GTK_LABEL(txt_lat), buffer);
+
+g_snprintf(buffer, sizeof(buffer), "%.06f", lon);
+gtk_label_set_text(GTK_LABEL(txt_lon), buffer);
+
+gtk_widget_show_all(dialog);
+
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+ const gchar *text;
+ gchar *error_check;
+ gdouble lat, lon;
+
+ text = gtk_entry_get_text(GTK_ENTRY(txt_lat));
+ lat = strtod(text, &error_check);
+ if (text == error_check || lat < -90.f || lat > 90.f) {
+ popup_error(dialog, _("Invalid Latitude"));
+ continue;
+ }
+
+ text = gtk_entry_get_text(GTK_ENTRY(txt_lon));
+ lon = strtod(text, &error_check);
+ if (text == error_check || lon < -180.f || lon > 180.f) {
+ popup_error(dialog, _("Invalid Longitude"));
+ continue;
+ }
+
+ gtk_map_set_center_latlon(map, lat, lon);
+ break;
+}
+gtk_widget_destroy(dialog);
+return TRUE;
+}