]> err.no Git - mapper/commitdiff
Many many changes.
authorKaj-Michael Lang <milang@onion.tal.org>
Mon, 3 Sep 2007 09:20:17 +0000 (12:20 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Mon, 3 Sep 2007 09:20:17 +0000 (12:20 +0300)
- Code formating
- Use GtkUIManager for menu and toolbar
- More spliting of functions to their own files
- Misc fixes here and there... can't remeber anymore

38 files changed:
data/Makefile.am
docs/osm-tables.sql
src/Makefile.am
src/bt-maemo.c
src/cb.c
src/cb.h
src/config-gconf.c
src/gps-conn.c
src/gps-nmea-parse.c
src/gps-panels.c
src/gps-panels.h
src/gps.h
src/gpx.c
src/hildon-wrappers.c
src/hildon-wrappers.h
src/map-poi.c
src/map-repo.c
src/map.c
src/map.h
src/mapper-types.h
src/mapper.c
src/osm-db.c
src/osm.h
src/poi-gui.c
src/poi.h
src/route.c
src/route.h
src/settings-gconf.h
src/settings-gui.c
src/settings-gui.h
src/settings.h
src/speak.c
src/speak.h
src/speed-display.c
src/track.c
src/ui-common.c
src/ui-common.h
src/utils.h

index 836309241cbbb0d5e5ffc930da3752021fd876c1..50d88fa02320b810118dadfb125883d696821f45 100644 (file)
@@ -22,10 +22,13 @@ serviceentry_DATA = org.tal.mapper.service
 
 desktopentry_DATA = mapper.desktop
 
+imagesdir = $(datadir)/pixmaps/mapper
+
 icon_26x26_DATA = icons/26x26/mapper.png 
 icon_40x40_DATA = icons/40x40/mapper.png
 icon_scalable_DATA = icons/scalable/mapper.png
+images_DATA = pixmaps/home.png
 
-EXTRA_DIST = $(serviceentry_DATA) $(desktopentry_DATA) $(icon_26x26_DATA) $(icon_40x40_DATA) $(icon_scalable_DATA)
+EXTRA_DIST = $(serviceentry_DATA) $(desktopentry_DATA) $(icon_26x26_DATA) $(icon_40x40_DATA) $(icon_scalable_DATA) $(images_DATA)
 
 SUBDIRS = help
index c82ef6fb5fcf4fee92ea60e9eba907295bd7eb03..eafbc124959debba588017953146bd5db84c5af6 100644 (file)
@@ -14,13 +14,13 @@ create table way (
        nodes   int not null,
        flags   int not null,
        speed   int not null default 0,
-       isin    int not null default 0
+       isin    int not null default 0,
 );
 
-create table way_seg (
-       wsid    int not null,
-       num             int not null,
-       node    int not null
+create table way_updates (
+       wid             int primary key,
+       utime   int not null,
+       notes   text
 );
 
 create table way_s2s (
@@ -41,6 +41,12 @@ create table way_names (
        name    varchar(256)
 );
 
+create table way_names_nls (
+       wid             int not null,
+       lang    char(2) not null,
+       name    varchar(256)
+);
+
 create table way_ref (
        rid             int primary key,
        ref             varchar(32),
@@ -67,7 +73,8 @@ create table poi (
        cat_id  integer,
        osm_id  integer default 0,
        isin    integer default 0,
-       priority int default 2
+       priority int default 2,
+       addtime integer default 0
 );
 
 create table category (
index 01f5ca51dbed9a8ab751da7accf7ba4219c6d429..2dcf4e5de10c6b49787125d493ab1084624bef99 100644 (file)
@@ -1,6 +1,7 @@
 #
-# This file is part of maemo-mapper
+# This file is part of mapper
 #
+# Copyright (C) 2007 Kaj-Michael Lang
 # Copyright (C) 2006 John Costigan.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -18,6 +19,8 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
 
+INCLUDES = -DDATADIR=\""$(datadir)"\"
+
 bin_PROGRAMS = mapper osm2db
 
 mapper_CFLAGS = $(GLIBGTK_CFLAGS) $(OSSO_CFLAGS) $(HILDON_CFLAGS) $(HILDONFM_CFLAGS) \
@@ -32,9 +35,11 @@ mapper_SOURCES = utils.c \
        db.c file.c \
        gpx.c \
        bt-bluez.c \
+       bt-maemo-marshal.c \
        bt-maemo.c \
        latlon.c \
        osm-db.c \
+       gps.c \
        gps-browse.c \
        gps-nmea-parse.c \
        gps-panels.c \
@@ -46,6 +51,7 @@ mapper_SOURCES = utils.c \
        track.c \
        maemo-osso.c \
        map-repo.c \
+       map-download.c \
        map.c \
        poi.c \
        poi-gui.c \
@@ -57,6 +63,7 @@ mapper_SOURCES = utils.c \
        ui-common.c \
        config-gconf.c \
        speak.c \
+       audio-note.c \
        mapper.c
 
 osm2db_CFLAGS = $(EXPAT_CFLAGS) $(SQLITE_CFLAGS) $(GLIBGTK_CFLAGS)
@@ -64,3 +71,12 @@ osm2db_CFLAGS = $(EXPAT_CFLAGS) $(SQLITE_CFLAGS) $(GLIBGTK_CFLAGS)
 osm2db_LDADD = $(EXPAT_LIBS) $(SQLITE_LIBS) $(GLIBGTK_LIBS) -lm
 
 osm2db_SOURCES = latlon.c osm.c
+
+EXTRA_DIST = bt-maemo-marshal.list
+
+BUILT_SOURCES = bt-maemo-marshal.h bt-maemo-marshal.c
+
+bt-maemo-marshal.h: bt-maemo-marshal.list
+       glib-genmarshal --prefix _bt_maemo --header $< > $@ 
+bt-maemo-marshal.c: bt-maemo-marshal.list
+       glib-genmarshal --prefix _bt_maemo --body $< > $@ 
index ed2e6dd79f6c3e16f81a2f6da7ed08d9fa4979d3..40a94bd55c27b86ca00c09f6e886fc532cf3ee02 100644 (file)
 #include <osso-helplib.h>
 #include <osso-ic-dbus.h>
 #include <osso-ic.h>
-#include <hildon-widgets/hildon-program.h>
-#include <hildon-widgets/hildon-controlbar.h>
-#include <hildon-widgets/hildon-note.h>
-#include <hildon-widgets/hildon-color-button.h>
-#include <hildon-widgets/hildon-file-chooser-dialog.h>
-#include <hildon-widgets/hildon-number-editor.h>
 #include <hildon-widgets/hildon-banner.h>
-#include <hildon-widgets/hildon-system-sound.h>
 
-/*****************************************************************************/
-
-#ifndef __g_cclosure_user_marshal_MARSHAL_H__
-#define __g_cclosure_user_marshal_MARSHAL_H__
-
-#include    <glib-object.h>
-
-G_BEGIN_DECLS
-
-#ifdef G_ENABLE_DEBUG
-#define g_marshal_value_peek_boolean(v)  g_value_get_boolean (v)
-#define g_marshal_value_peek_char(v)     g_value_get_char (v)
-#define g_marshal_value_peek_uchar(v)    g_value_get_uchar (v)
-#define g_marshal_value_peek_int(v)      g_value_get_int (v)
-#define g_marshal_value_peek_uint(v)     g_value_get_uint (v)
-#define g_marshal_value_peek_long(v)     g_value_get_long (v)
-#define g_marshal_value_peek_ulong(v)    g_value_get_ulong (v)
-#define g_marshal_value_peek_int64(v)    g_value_get_int64 (v)
-#define g_marshal_value_peek_uint64(v)   g_value_get_uint64 (v)
-#define g_marshal_value_peek_enum(v)     g_value_get_enum (v)
-#define g_marshal_value_peek_flags(v)    g_value_get_flags (v)
-#define g_marshal_value_peek_float(v)    g_value_get_float (v)
-#define g_marshal_value_peek_double(v)   g_value_get_double (v)
-#define g_marshal_value_peek_string(v)   (char*) g_value_get_string (v)
-#define g_marshal_value_peek_param(v)    g_value_get_param (v)
-#define g_marshal_value_peek_boxed(v)    g_value_get_boxed (v)
-#define g_marshal_value_peek_pointer(v)  g_value_get_pointer (v)
-#define g_marshal_value_peek_object(v)   g_value_get_object (v)
-#else /* !G_ENABLE_DEBUG */
-/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
- *          Do not access GValues directly in your code. Instead, use the
- *          g_value_get_*() functions
- */
-#define g_marshal_value_peek_boolean(v)  (v)->data[0].v_int
-#define g_marshal_value_peek_char(v)     (v)->data[0].v_int
-#define g_marshal_value_peek_uchar(v)    (v)->data[0].v_uint
-#define g_marshal_value_peek_int(v)      (v)->data[0].v_int
-#define g_marshal_value_peek_uint(v)     (v)->data[0].v_uint
-#define g_marshal_value_peek_long(v)     (v)->data[0].v_long
-#define g_marshal_value_peek_ulong(v)    (v)->data[0].v_ulong
-#define g_marshal_value_peek_int64(v)    (v)->data[0].v_int64
-#define g_marshal_value_peek_uint64(v)   (v)->data[0].v_uint64
-#define g_marshal_value_peek_enum(v)     (v)->data[0].v_long
-#define g_marshal_value_peek_flags(v)    (v)->data[0].v_ulong
-#define g_marshal_value_peek_float(v)    (v)->data[0].v_float
-#define g_marshal_value_peek_double(v)   (v)->data[0].v_double
-#define g_marshal_value_peek_string(v)   (v)->data[0].v_pointer
-#define g_marshal_value_peek_param(v)    (v)->data[0].v_pointer
-#define g_marshal_value_peek_boxed(v)    (v)->data[0].v_pointer
-#define g_marshal_value_peek_pointer(v)  (v)->data[0].v_pointer
-#define g_marshal_value_peek_object(v)   (v)->data[0].v_pointer
-#endif /* !G_ENABLE_DEBUG */
-
-
-/* VOID:STRING,STRING,POINTER,UCHAR,UINT (marshal.list:1) */
-extern void g_cclosure_user_marshal_VOID__STRING_STRING_POINTER_UCHAR_UINT (GClosure     *closure,
-                                                                            GValue       *return_value,
-                                                                            guint         n_param_values,
-                                                                            const GValue *param_values,
-                                                                            gpointer      invocation_hint,
-                                                                            gpointer      marshal_data);
-void
-g_cclosure_user_marshal_VOID__STRING_STRING_POINTER_UCHAR_UINT (GClosure     *closure,
-                                                                GValue       *return_value,
-                                                                guint         n_param_values,
-                                                                const GValue *param_values,
-                                                                gpointer      invocation_hint,
-                                                                gpointer      marshal_data)
-{
-  typedef void (*GMarshalFunc_VOID__STRING_STRING_POINTER_UCHAR_UINT) (gpointer     data1,
-                                                                       gpointer     arg_1,
-                                                                       gpointer     arg_2,
-                                                                       gpointer     arg_3,
-                                                                       guchar       arg_4,
-                                                                       guint        arg_5,
-                                                                       gpointer     data2);
-  register GMarshalFunc_VOID__STRING_STRING_POINTER_UCHAR_UINT callback;
-  register GCClosure *cc = (GCClosure*) closure;
-  register gpointer data1, data2;
-
-  g_return_if_fail (n_param_values == 6);
-
-  if (G_CCLOSURE_SWAP_DATA (closure))
-    {
-      data1 = closure->data;
-      data2 = g_value_peek_pointer (param_values + 0);
-    }
-  else
-    {
-      data1 = g_value_peek_pointer (param_values + 0);
-      data2 = closure->data;
-    }
-  callback = (GMarshalFunc_VOID__STRING_STRING_POINTER_UCHAR_UINT) (marshal_data ? marshal_data : cc->callback);
-
-  callback (data1,
-            g_marshal_value_peek_string (param_values + 1),
-            g_marshal_value_peek_string (param_values + 2),
-            g_marshal_value_peek_pointer (param_values + 3),
-            g_marshal_value_peek_uchar (param_values + 4),
-            g_marshal_value_peek_uint (param_values + 5),
-            data2);
-}
-
-G_END_DECLS
-
-#endif /* __g_cclosure_user_marshal_MARSHAL_H__ */
+#include "bt-maemo-marshal.h"
 
 /*****************************************************************************/
 
 gboolean
 channel_cb_connect(GIOChannel * src, GIOCondition condition, gpointer data)
 {
-       printf("%s(%d)\n", __PRETTY_FUNCTION__, condition);
+_gps_read_buf_curr = _gps_read_buf;
+_gps_read_buf_last = _gps_read_buf + GPS_READ_BUF_SIZE - 1;
 
-       _gps_read_buf_curr = _gps_read_buf;
-       _gps_read_buf_last = _gps_read_buf + GPS_READ_BUF_SIZE - 1;
+set_conn_state(RCVR_UP);
 
-       set_conn_state(RCVR_UP);
-       _input_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
-                                        G_IO_IN | G_IO_PRI, channel_cb_input,
-                                        NULL, NULL);
+_input_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
+                G_IO_IN | G_IO_PRI, channel_cb_input, NULL, NULL);
 
-       _connect_sid = 0;
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return FALSE;
+_connect_sid = 0;
+return FALSE;
 }
 
 /**
@@ -150,141 +35,117 @@ channel_cb_connect(GIOChannel * src, GIOCondition condition, gpointer data)
  */
 void rcvr_disconnect()
 {
-       GError *error = NULL;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GError *error = NULL;
 
-       /* Remove watches. */
-       if (_clater_sid) {
-               g_source_remove(_clater_sid);
-               _clater_sid = 0;
-       }
-       if (_error_sid) {
-               g_source_remove(_error_sid);
-               _error_sid = 0;
-       }
-       if (_connect_sid) {
-               g_source_remove(_connect_sid);
-               _connect_sid = 0;
-       }
-       if (_input_sid) {
-               g_source_remove(_input_sid);
-               _input_sid = 0;
-       }
-
-       /* Destroy the GIOChannel object. */
-       if (_channel) {
-               g_io_channel_shutdown(_channel, FALSE, NULL);
-               g_io_channel_unref(_channel);
-               _channel = NULL;
-       }
+/* Remove watches. */
+if (_clater_sid) {
+       g_source_remove(_clater_sid);
+       _clater_sid = 0;
+}
+if (_error_sid) {
+       g_source_remove(_error_sid);
+       _error_sid = 0;
+}
+if (_connect_sid) {
+       g_source_remove(_connect_sid);
+       _connect_sid = 0;
+}
+if (_input_sid) {
+       g_source_remove(_input_sid);
+       _input_sid = 0;
+}
 
-       /* Close the file descriptor. */
-       if (_fd != -1) {
-               close(_fd);
-               _fd = -1;
-       }
+/* Destroy the GIOChannel object. */
+if (_channel) {
+       g_io_channel_shutdown(_channel, FALSE, NULL);
+       g_io_channel_unref(_channel);
+       _channel = NULL;
+}
 
-       if (_rfcomm_req_proxy) {
-               dbus_g_proxy_call(_rfcomm_req_proxy,
-                                 BTCOND_RFCOMM_CANCEL_CONNECT_REQ, &error,
-                                 G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
-                                 "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
-               error = NULL;
-               dbus_g_proxy_call(_rfcomm_req_proxy,
-                                 BTCOND_RFCOMM_DISCONNECT_REQ, &error,
-                                 G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
-                                 "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
-       }
+/* Close the file descriptor. */
+if (_fd != -1) {
+       close(_fd);
+       _fd = -1;
+}
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+if (_rfcomm_req_proxy) {
+       dbus_g_proxy_call(_rfcomm_req_proxy,
+                         BTCOND_RFCOMM_CANCEL_CONNECT_REQ, &error,
+                         G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
+                         "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
+       error = NULL;
+       dbus_g_proxy_call(_rfcomm_req_proxy,
+                         BTCOND_RFCOMM_DISCONNECT_REQ, &error,
+                         G_TYPE_STRING, _rcvr_mac, G_TYPE_STRING,
+                         "SPP", G_TYPE_INVALID, G_TYPE_INVALID);
+}
 }
 
 void rcvr_connect_later();     /* Forward declaration. */
 
 void rcvr_connect_fd(gchar * fdpath)
 {
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, fdpath);
-
-       /* Create the file descriptor. */
-
-       /* If file descriptor creation failed, try again later. */
-       if (-1 == (_fd = open(fdpath, O_RDONLY))) {
-               rcvr_disconnect();
-               rcvr_connect_later();
-       } else {
-               /* Reset GPS read buffer */
-               _gps_read_buf_curr = _gps_read_buf;
-               *_gps_read_buf_curr = '\0';
-
-               /* Create channel and add watches. */
-               _channel = g_io_channel_unix_new(_fd);
-               g_io_channel_set_flags(_channel, G_IO_FLAG_NONBLOCK, NULL);
-               _error_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
-                                                G_IO_ERR | G_IO_HUP,
-                                                channel_cb_error, NULL, NULL);
-               _connect_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
-                                       G_IO_OUT, channel_cb_connect, NULL,
-                                       NULL);
+/* If file descriptor creation failed, try again later. */
+if (-1 == (_fd = open(fdpath, O_RDONLY))) {
+       rcvr_disconnect();
+       rcvr_connect_later();
+} else {
+       /* Reset GPS read buffer */
+       _gps_read_buf_curr = _gps_read_buf;
+       *_gps_read_buf_curr = '\0';
+
+       /* Create channel and add watches. */
+       _channel = g_io_channel_unix_new(_fd);
+       g_io_channel_set_flags(_channel, G_IO_FLAG_NONBLOCK, NULL);
+       _error_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
+               G_IO_ERR | G_IO_HUP, channel_cb_error, NULL, NULL);
+       _connect_sid = g_io_add_watch_full(_channel, G_PRIORITY_HIGH_IDLE,
+               G_IO_OUT, channel_cb_connect, NULL,     NULL);
        }
-       g_free(fdpath);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+g_free(fdpath);
 }
 
 void rcvr_connect_response(DBusGProxy * proxy, DBusGProxyCall * call_id)
 {
-       GError *error = NULL;
-       gchar *fdpath = NULL;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (_conn_state == RCVR_DOWN && _rcvr_mac) {
-               if (!dbus_g_proxy_end_call(_rfcomm_req_proxy, call_id, &error,
-                                          G_TYPE_STRING, &fdpath,
-                                          G_TYPE_INVALID)) {
-                       if (error->domain == DBUS_GERROR
-                           && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
-                               /* If we're already connected, it's not an error, unless
-                                * they don't give us the file descriptor path, in which
-                                * case we re-connect.*/
-                               if (!strcmp(BTCOND_ERROR_CONNECTED,
-                                           dbus_g_error_get_name(error))
-                                   || !fdpath) {
-                                       GtkWidget *confirm;
-                                       printf
-                                           ("Caught remote method exception %s: %s",
-                                            dbus_g_error_get_name(error),
-                                            error->message);
-                                       rcvr_disconnect();
-
-                                       /* Ask user to re-connect. */
-                                       confirm =
-                                           hildon_note_new_confirmation
-                                           (GTK_WINDOW(_window),
-                                            _
-                                            ("Failed to connect to GPS receiver.  Retry?"));
-
-                                       if (GTK_RESPONSE_OK ==
-                                           gtk_dialog_run(GTK_DIALOG(confirm)))
-                                               rcvr_connect_later();   /* Try again later. */
-                                       else
-                                               set_conn_state(RCVR_OFF);
-
-                                       gtk_widget_destroy(confirm);
-                                       return;
-                               }
-                       } else {
-                               /* Unknown error. */
-                               g_printerr("Error: %s\n", error->message);
+GError *error = NULL;
+gchar *fdpath = NULL;
+
+if (_conn_state == RCVR_DOWN && _rcvr_mac) {
+       if (!dbus_g_proxy_end_call(_rfcomm_req_proxy, call_id, &error,
+                                  G_TYPE_STRING, &fdpath, G_TYPE_INVALID)) {
+               if (error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
+                       /* If we're already connected, it's not an error, unless
+                        * they don't give us the file descriptor path, in which
+                        * case we re-connect.*/
+                       if (!strcmp(BTCOND_ERROR_CONNECTED, dbus_g_error_get_name(error)) || !fdpath) {
+                               GtkWidget *confirm;
+                               printf("Caught remote method exception %s: %s", dbus_g_error_get_name(error), error->message);
                                rcvr_disconnect();
-                               rcvr_connect_later();   /* Try again later. */
+
+                               /* Ask user to re-connect. */
+                               confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
+                                            _("Failed to connect to GPS receiver.  Retry?"));
+
+                               if (GTK_RESPONSE_OK ==
+                                   gtk_dialog_run(GTK_DIALOG(confirm)))
+                                       rcvr_connect_later();   /* Try again later. */
+                               else
+                                       set_conn_state(RCVR_OFF);
+
+                               gtk_widget_destroy(confirm);
                                return;
                        }
+               } else {
+                       /* Unknown error. */
+                       g_printerr("Error: %s\n", error->message);
+                       rcvr_disconnect();
+                       rcvr_connect_later();   /* Try again later. */
+                       return;
                }
-               rcvr_connect_fd(fdpath);
        }
-       /* else { Looks like the middle of a disconnect.  Do nothing. } */
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+       rcvr_connect_fd(fdpath);
+}
+/* else { Looks like the middle of a disconnect.  Do nothing. } */
 }
 
 /**
@@ -296,38 +157,34 @@ void rcvr_connect_response(DBusGProxy * proxy, DBusGProxyCall * call_id)
  */
 gboolean rcvr_connect_now()
 {
-       printf("%s(%d)\n", __PRETTY_FUNCTION__, _conn_state);
-
-       if (_conn_state == RCVR_DOWN && _rcvr_mac) {
+if (_conn_state == RCVR_DOWN && _rcvr_mac) {
 #ifndef DEBUG
-               if (*_rcvr_mac != '/') {
-                       if (_rfcomm_req_proxy) {
-                               gint mybool = TRUE;
-                               dbus_g_proxy_begin_call(_rfcomm_req_proxy,
-                                                       BTCOND_RFCOMM_CONNECT_REQ,
-                                                       (DBusGProxyCallNotify)
-                                                       rcvr_connect_response,
-                                                       NULL, NULL,
-                                                       G_TYPE_STRING,
-                                                       _rcvr_mac,
-                                                       G_TYPE_STRING, "SPP",
-                                                       G_TYPE_BOOLEAN, &mybool,
-                                                       G_TYPE_INVALID);
-                       }
-               } else
-                       rcvr_connect_fd(g_strdup(_rcvr_mac));
+       if (*_rcvr_mac != '/') {
+               if (_rfcomm_req_proxy) {
+                       gint mybool = TRUE;
+                       dbus_g_proxy_begin_call(_rfcomm_req_proxy,
+                                               BTCOND_RFCOMM_CONNECT_REQ,
+                                               (DBusGProxyCallNotify)
+                                               rcvr_connect_response,
+                                               NULL, NULL,
+                                               G_TYPE_STRING,
+                                               _rcvr_mac,
+                                               G_TYPE_STRING, "SPP",
+                                               G_TYPE_BOOLEAN, &mybool,
+                                               G_TYPE_INVALID);
+               }
+       } else
+               rcvr_connect_fd(g_strdup(_rcvr_mac));
 
 #else
-               /* We're in DEBUG mode, so instead of connecting, skip to FIXED. */
-               printf("FIXED!\n");
-               set_conn_state(RCVR_FIXED);
+       /* We're in DEBUG mode, so instead of connecting, skip to FIXED. */
+       printf("FIXED!\n");
+       set_conn_state(RCVR_FIXED);
 #endif
-       }
-
-       _clater_sid = 0;
+}
 
-       vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
-       return FALSE;
+_clater_sid = 0;
+return FALSE;
 }
 
 /**
@@ -335,11 +192,7 @@ gboolean rcvr_connect_now()
  */
 void rcvr_connect_later()
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _clater_sid = g_timeout_add(1000, (GSourceFunc) rcvr_connect_now, NULL);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+_clater_sid = g_timeout_add(1000, (GSourceFunc) rcvr_connect_now, NULL);
 }
 
 void
@@ -347,32 +200,24 @@ scan_cb_dev_found(DBusGProxy * sig_proxy, const gchar * bda,
                  const gchar * name, gpointer * class, guchar rssi, gint coff,
                  ScanInfo * scan_info)
 {
-       GtkTreeIter iter;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       gtk_list_store_append(scan_info->store, &iter);
-       gtk_list_store_set(scan_info->store, &iter,
-                          0, g_strdup(bda), 1, g_strdup(name), -1);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+GtkTreeIter iter;
+gtk_list_store_append(scan_info->store, &iter);
+gtk_list_store_set(scan_info->store, &iter, 0, g_strdup(bda), 1, g_strdup(name), -1);
 }
 
 void scan_cb_search_complete(DBusGProxy * sig_proxy, ScanInfo * scan_info)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       gtk_widget_destroy(scan_info->banner);
-       dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_DEV_FOUND_SIG,
-                                      G_CALLBACK(scan_cb_dev_found),
-                                      scan_info);
-       dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG,
-                                      G_CALLBACK(scan_cb_search_complete),
-                                      scan_info);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+gtk_widget_destroy(scan_info->banner);
+dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_DEV_FOUND_SIG,
+                      G_CALLBACK(scan_cb_dev_found), scan_info);
+dbus_g_proxy_disconnect_signal(sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG,
+                      G_CALLBACK(scan_cb_search_complete), scan_info);
 }
 
 gint scan_start_search(ScanInfo * scan_info)
 {
-       GError *error = NULL;
-       DBusGConnection *dbus_conn;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GError *error = NULL;
+DBusGConnection *dbus_conn;
 
        /* Initialize D-Bus. */
        if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) {
@@ -400,8 +245,7 @@ gint scan_start_search(ScanInfo * scan_info)
                return 2;
        }
 
-       dbus_g_object_register_marshaller
-           (g_cclosure_user_marshal_VOID__STRING_STRING_POINTER_UCHAR_UINT,
+       dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_POINTER_UCHAR_UINT,
             G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, DBUS_TYPE_G_UCHAR_ARRAY,
             G_TYPE_UCHAR, G_TYPE_UINT, G_TYPE_INVALID);
 
@@ -411,15 +255,13 @@ gint scan_start_search(ScanInfo * scan_info)
                                G_TYPE_STRING,
                                DBUS_TYPE_G_UCHAR_ARRAY,
                                G_TYPE_UCHAR, G_TYPE_UINT, G_TYPE_INVALID);
-       dbus_g_proxy_connect_signal(scan_info->sig_proxy,
-                                   BTSEARCH_DEV_FOUND_SIG,
+       dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_DEV_FOUND_SIG,
                                    G_CALLBACK(scan_cb_dev_found), scan_info,
                                    NULL);
 
        dbus_g_proxy_add_signal(scan_info->sig_proxy,
                                BTSEARCH_SEARCH_COMPLETE_SIG, G_TYPE_INVALID);
-       dbus_g_proxy_connect_signal(scan_info->sig_proxy,
-                                   BTSEARCH_SEARCH_COMPLETE_SIG,
+       dbus_g_proxy_connect_signal(scan_info->sig_proxy, BTSEARCH_SEARCH_COMPLETE_SIG,
                                    G_CALLBACK(scan_cb_search_complete),
                                    scan_info, NULL);
 
@@ -429,15 +271,13 @@ gint scan_start_search(ScanInfo * scan_info)
                if (error->domain == DBUS_GERROR
                    && error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
                        g_printerr("Caught remote method exception %s: %s",
-                                  dbus_g_error_get_name(error),
-                                  error->message);
+                                  dbus_g_error_get_name(error), error->message);
                } else
                        g_printerr("Error: %s\n", error->message);
                return 3;
        }
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return 0;
+return 0;
 }
 
 #endif
index 1b578fd65754927884f2281c6807315508e433e2..df75b7744be8e2a6cd15c4d3b595fbe0e64bfaf3 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -8,13 +8,11 @@
 #include <strings.h>
 #include <stddef.h>
 #include <locale.h>
-#include <math.h>
 #include <errno.h>
 #include <sys/wait.h>
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
 #include <fcntl.h>
-#include <gconf/gconf-client.h>
 #include <libintl.h>
 #include <locale.h>
 
 #include "cb.h"
 #include "gps-panels.h"
 
-gboolean map_cb_configure(GtkWidget * widget, GdkEventConfigure * event)
+gboolean 
+menu_cb_route_download(GtkAction * action)
 {
-       printf("%s(%d, %d)\n", __PRETTY_FUNCTION__,
-              _map_widget->allocation.width, _map_widget->allocation.height);
-
-       _screen_width_pixels = _map_widget->allocation.width;
-       _screen_height_pixels = _map_widget->allocation.height;
-       _screen_grids_halfwidth = pixel2grid(_screen_width_pixels) / 2;
-       _screen_grids_halfheight = pixel2grid(_screen_height_pixels) / 2;
-
-       /* Set _scale_rect. */
-       _scale_rect.x = (_screen_width_pixels - SCALE_WIDTH) / 2;
-       _scale_rect.width = SCALE_WIDTH;
-       pango_layout_set_text(_scale_layout, "0", -1);
-       pango_layout_get_pixel_size(_scale_layout, NULL, &_scale_rect.height);
-       _scale_rect.y = _screen_height_pixels - _scale_rect.height - 1;
-
-       MACRO_RECALC_FOCUS_BASE();
-       MACRO_RECALC_FOCUS_SIZE();
-
-       _min_center.unitx = pixel2unit(grid2pixel(_screen_grids_halfwidth));
-       _min_center.unity = pixel2unit(grid2pixel(_screen_grids_halfheight));
-       _max_center.unitx = WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfwidth) - 1;
-       _max_center.unity = WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfheight) - 1;
-
-       map_center_unit(_center.unitx, _center.unity);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
-}
-
-gboolean menu_cb_route_download(GtkAction * action)
-{
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       route_download(NULL);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_download(NULL);
+return TRUE;
 }
 
-gboolean menu_cb_route_open(GtkAction * action)
+gboolean 
+menu_cb_route_open(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       route_open_file();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_open_file();
+return TRUE;
 }
 
-gboolean menu_cb_route_distnext(GtkAction * action)
+gboolean 
+menu_cb_route_distnext(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       route_show_distance_to_next();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_show_distance_to_next();
+return TRUE;
 }
 
-gboolean menu_cb_route_distlast(GtkAction * action)
+gboolean 
+menu_cb_route_distlast(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       route_show_distance_to_last();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_show_distance_to_last();
+return TRUE;
 }
 
-gboolean menu_cb_route_reset(GtkAction * action)
+gboolean 
+menu_cb_route_reset(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       route_find_nearest_point();
-       MACRO_MAP_RENDER_DATA();
-       MACRO_QUEUE_DRAW_AREA();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_find_nearest_point();
+map_render_data();
+MACRO_QUEUE_DRAW_AREA();
+return TRUE;
 }
 
-gboolean menu_cb_route_clear(GtkAction * action)
+gboolean 
+menu_cb_route_clear(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       route_clear();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_clear();
+return TRUE;
 }
 
-gboolean menu_cb_track_open(GtkAction * action)
+gboolean 
+menu_cb_track_open(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       track_open();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+track_open();
+return TRUE;
 }
 
-gboolean menu_cb_track_save(GtkAction * action)
+gboolean 
+menu_cb_track_save(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       track_save();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+track_save();
+return TRUE;
 }
 
-gboolean menu_cb_track_insert_break(GtkAction * action)
+gboolean 
+menu_cb_track_insert_break(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       track_insert_break();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+track_insert_break();
+return TRUE;
 }
 
-gboolean menu_cb_track_insert_mark(GtkAction * action)
+gboolean 
+menu_cb_track_insert_mark(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       track_insert_mark();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+track_insert_mark();
+return TRUE;
 }
 
-gboolean menu_cb_track_distlast(GtkAction * action)
+gboolean 
+menu_cb_track_distlast(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       track_show_distance_from_last();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+track_show_distance_from_last();
+return TRUE;
 }
 
-gboolean menu_cb_track_distfirst(GtkAction * action)
+gboolean 
+menu_cb_track_distfirst(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       track_show_distance_from_first();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+track_show_distance_from_first();
+return TRUE;
 }
 
-gboolean menu_cb_route_save(GtkAction * action)
+gboolean 
+menu_cb_route_save(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       route_save();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_save();
+return TRUE;
 }
 
-gboolean menu_cb_track_clear(GtkAction * action)
+gboolean 
+menu_cb_track_clear(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       track_clear();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+track_clear();
+return TRUE;
 }
 
-gboolean menu_cb_track_filter(GtkAction * action)
+gboolean 
+menu_cb_track_filter(GtkAction * action)
 {
 filter_dialog();
 return TRUE;
 }
 
-gboolean menu_cb_show_tracks(GtkAction * action)
+gboolean 
+menu_cb_show_tracks(GtkAction *action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _show_tracks ^= TRACKS_MASK;
-       if (gtk_check_menu_item_get_active
-           (GTK_CHECK_MENU_ITEM(_menu_show_tracks_item))) {
-               _show_tracks |= TRACKS_MASK;
-               map_render_paths();
-               MACRO_QUEUE_DRAW_AREA();
-               MACRO_BANNER_SHOW_INFO(_window, _("Tracks are now shown"));
-       } else {
-               _show_tracks &= ~TRACKS_MASK;
-               map_force_redraw();
-               MACRO_BANNER_SHOW_INFO(_window, _("Tracks are now hidden"));
-       }
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
-}
-
-gboolean menu_cb_show_scale(GtkAction * action)
-{
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _show_scale =
-           gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM
-                                          (_menu_show_scale_item));
+_show_tracks ^= TRACKS_MASK;
+if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) {
+       _show_tracks |= TRACKS_MASK;
+       map_render_paths();
        MACRO_QUEUE_DRAW_AREA();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+       MACRO_BANNER_SHOW_INFO(_window, _("Tracks are now shown"));
+} else {
+       _show_tracks &= ~TRACKS_MASK;
+       map_force_redraw();
+       MACRO_BANNER_SHOW_INFO(_window, _("Tracks are now hidden"));
 }
-
-gboolean menu_cb_show_routes(GtkAction * action)
-{
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (gtk_check_menu_item_get_active
-           (GTK_CHECK_MENU_ITEM(_menu_show_routes_item))) {
-               _show_tracks |= ROUTES_MASK;
-               map_render_paths();
-               MACRO_QUEUE_DRAW_AREA();
-               MACRO_BANNER_SHOW_INFO(_window, _("Routes are now shown"));
-       } else {
-               _show_tracks &= ~ROUTES_MASK;
-               map_force_redraw();
-               MACRO_BANNER_SHOW_INFO(_window, _("Routes are now hidden"));
-       }
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_show_velvec(GtkAction * action)
+gboolean 
+menu_cb_show_scale(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _show_velvec = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_show_velvec_item));
-       map_move_mark();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+_show_scale = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+MACRO_QUEUE_DRAW_AREA();
+return TRUE;
 }
 
-gboolean menu_cb_show_poi(GtkAction * action)
+gboolean 
+menu_cb_show_routes(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _show_poi = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_show_poi_item));
+if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action))) {
+       _show_tracks |= ROUTES_MASK;
+       map_render_paths();
+       MACRO_QUEUE_DRAW_AREA();
+       MACRO_BANNER_SHOW_INFO(_window, _("Routes are now shown"));
+} else {
+       _show_tracks &= ~ROUTES_MASK;
        map_force_redraw();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+       MACRO_BANNER_SHOW_INFO(_window, _("Routes are now hidden"));
 }
-
-gboolean menu_cb_gps_show_info(GtkAction * action)
-{
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _gps_info = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_gps_show_info_item));
-
-       gps_show_info();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_ac_lead(GtkAction * action)
+gboolean 
+menu_cb_show_velvec(GtkAction * action)
 {
-       guint new_center_unitx, new_center_unity;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _center_mode = CENTER_LEAD;
-       MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Mode: Lead"));
-       MACRO_RECALC_CENTER(new_center_unitx, new_center_unity);
-       map_center_unit(new_center_unitx, new_center_unity);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+_show_velvec = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+map_move_mark();
+return TRUE;
 }
 
-gboolean menu_cb_ac_latlon(GtkAction * action)
+gboolean 
+menu_cb_show_poi(GtkAction * action)
 {
-       guint new_center_unitx, new_center_unity;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _center_mode = CENTER_LATLON;
-       MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Mode: Lat/Lon"));
-       MACRO_RECALC_CENTER(new_center_unitx, new_center_unity);
-       map_center_unit(new_center_unitx, new_center_unity);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+_show_poi = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+map_force_redraw();
+return TRUE;
 }
 
-gboolean menu_cb_ac_none(GtkAction * action)
+gboolean 
+menu_cb_gps_show_info(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+_gps_info = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+gps_show_info();
+return TRUE;
+}
 
-       _center_mode = -_center_mode;
-       MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Off"));
+gboolean
+menu_cb_autocenter(GtkAction *action, GtkRadioAction *current)
+{
+guint new_center_unitx, new_center_unity;
+gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
+
+switch (value) {
+       case CENTER_LEAD:
+               _center_mode = CENTER_LEAD;
+               MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Mode: Lead"));
+       break;
+       case CENTER_LATLON:
+               _center_mode = CENTER_LATLON;
+               MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Mode: Lat/Lon"));
+       break;
+       case CENTER_MANUAL:
+               _center_mode = -_center_mode;
+               MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Off"));
+               return TRUE;
+       break;
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+MACRO_RECALC_CENTER(new_center_unitx, new_center_unity);
+map_center_unit(new_center_unitx, new_center_unity);
+return TRUE;
 }
 
-gboolean menu_cb_goto_latlon(GtkAction * action)
+gboolean 
+menu_cb_goto_latlon(GtkAction * action)
 {
-       GtkWidget *dialog;
-       GtkWidget *table;
-       GtkWidget *label;
-       GtkWidget *txt_lat;
-       GtkWidget *txt_lon;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GtkWidget *dialog;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *txt_lat;
+GtkWidget *txt_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);
+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_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), 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), 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), 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);
+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);
 
 #ifdef WITH_DEVICE_770
-       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);
+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
 
-       /* Initialize with the current center position. */
-       {
-               gchar buffer[32];
-               gdouble lat, lon;
-               unit2latlon(_center.unitx, _center.unity, lat, lon);
-               snprintf(buffer, sizeof(buffer), "%.06f", lat);
-               gtk_label_set_text(GTK_LABEL(txt_lat), buffer);
-               snprintf(buffer, sizeof(buffer), "%.06f", lon);
-               gtk_label_set_text(GTK_LABEL(txt_lon), buffer);
-       }
+/* Initialize with the current center position. */
+{
+       gchar buffer[32];
+       gdouble lat, lon;
+       unit2latlon(_center.unitx, _center.unity, lat, lon);
+       snprintf(buffer, sizeof(buffer), "%.06f", lat);
+       gtk_label_set_text(GTK_LABEL(txt_lat), buffer);
+       snprintf(buffer, sizeof(buffer), "%.06f", lon);
+       gtk_label_set_text(GTK_LABEL(txt_lon), buffer);
+}
 
-       gtk_widget_show_all(dialog);
+gtk_widget_show_all(dialog);
 
-       while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               const gchar *text;
-               gchar *error_check;
-               gdouble lat, lon;
-               guint unitx, unity;
-
-               text = gtk_entry_get_text(GTK_ENTRY(txt_lat));
-               lat = strtof(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 = strtof(text, &error_check);
-               if (text == error_check || lon < -180.f || lon > 180.f) {
-                       popup_error(dialog, _("Invalid Longitude"));
-                       continue;
-               }
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+       const gchar *text;
+       gchar *error_check;
+       gdouble lat, lon;
+       guint unitx, unity;
 
-               latlon2unit(lat, lon, unitx, unity);
-               if (_center_mode > 0)
-                       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                                      (_menu_ac_none_item), TRUE);
-               map_center_unit(unitx, unity);
-               break;
+       text = gtk_entry_get_text(GTK_ENTRY(txt_lat));
+       lat = strtof(text, &error_check);
+       if (text == error_check || lat < -90.f || lat > 90.f) {
+               popup_error(dialog, _("Invalid Latitude"));
+               continue;
        }
-       gtk_widget_destroy(dialog);
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
-}
 
-gboolean menu_cb_goto_home(GtkAction * action)
-{
-       guint unitx, unity;
-
-       printf("%s()\n", __PRETTY_FUNCTION__);
+       text = gtk_entry_get_text(GTK_ENTRY(txt_lon));
+       lon = strtof(text, &error_check);
+       if (text == error_check || lon < -180.f || lon > 180.f) {
+               popup_error(dialog, _("Invalid Longitude"));
+               continue;
+       }
 
+       latlon2unit(lat, lon, unitx, unity);
        if (_center_mode > 0)
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_ac_none_item), TRUE);
+               set_action_activate("autocenter_none", TRUE);
 
-       latlon2unit(_home.lat, _home.lon, unitx, unity);
        map_center_unit(unitx, unity);
-    map_set_autozoom(FALSE);
-       map_update_location_from_center();
+       break;
+}
+gtk_widget_destroy(dialog);
+return TRUE;
+}
+
+gboolean 
+menu_cb_goto_home(GtkAction * action)
+{
+guint unitx, unity;
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+if (_home.valid==FALSE) {
+       MACRO_BANNER_SHOW_INFO(_window, _("Home not set."));
        return TRUE;
 }
+_center_mode = CENTER_MANUAL;
+latlon2unit(_home.lat, _home.lon, unitx, unity);
+map_center_unit(unitx, unity);
+map_set_autozoom(FALSE);
+map_update_location_from_center();
+MACRO_BANNER_SHOW_INFO(_window, _("At home location"));
+return TRUE;
+}
 
-gboolean menu_cb_goto_destination(GtkAction *action)
+gboolean 
+menu_cb_goto_destination(GtkAction *action)
 {
 guint unitx, unity;
 
@@ -458,54 +339,46 @@ if (_dest.valid==FALSE) {
        MACRO_BANNER_SHOW_INFO(_window, _("Destination not set."));
        return TRUE;
 }
+_center_mode = CENTER_MANUAL;
 latlon2unit(_dest.lat, _dest.lon, unitx, unity);
 map_center_unit(unitx, unity);
 map_set_autozoom(FALSE);
+map_update_location_from_center();
+MACRO_BANNER_SHOW_INFO(_window, _("At destination"));
 return TRUE;
 }
 
-gboolean menu_cb_goto_gps(GtkAction * action)
+gboolean 
+menu_cb_goto_gps(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (_center_mode > 0)
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_ac_none_item), TRUE);
-
-       map_center_unit(_pos.unitx, _pos.unity);
-       map_update_location_from_center();
+_center_mode = CENTER_LATLON;
+map_center_unit(_pos.unitx, _pos.unity);
+map_update_location_from_center();
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_goto_nextway(GtkAction * action)
+gboolean 
+menu_cb_goto_nextway(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (_next_way && _next_way->point->unity) {
-               if (_center_mode > 0)
-                       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                                      (_menu_ac_none_item),
-                                                      TRUE);
+if (_next_way && _next_way->point->unity) {
+       if (_center_mode > 0)
+               set_action_activate("autocenter_none", TRUE);
 
-               map_center_unit(_next_way->point->unitx,
-                               _next_way->point->unity);
-       } else {
-               MACRO_BANNER_SHOW_INFO(_window, _("There is no next waypoint."));
-       }
+       map_center_unit(_next_way->point->unitx, _next_way->point->unity);
+} else {
+       MACRO_BANNER_SHOW_INFO(_window, _("There is no next waypoint."));
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_goto_nearpoi(GtkAction * action)
+gboolean 
+menu_cb_goto_nearpoi(GtkAction * action)
 {
 gdouble lat, lon;
 poi_info *p;
 
-printf("%s()\n", __PRETTY_FUNCTION__);
-
 if (_center_mode > 0) {
        /* Auto-Center is enabled - use the GPS position. */
        unit2latlon(_pos.unitx, _pos.unity, lat, lon);
@@ -528,7 +401,7 @@ if (p) {
        poi_free(p);
 
        if (_center_mode > 0)
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_none_item), TRUE);
+               set_action_activate("autocenter_none", TRUE);
 
        map_center_unit(unitx, unity);
        map_update_location_from_center();
@@ -536,193 +409,145 @@ if (p) {
        MACRO_BANNER_SHOW_INFO(_window, _("No POIs found."));
 }
 
-vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
 return TRUE;
 }
 
-gboolean menu_cb_maps_repoman(GtkAction * action)
+gboolean 
+menu_cb_maps_repoman(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       repoman_dialog();
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+repoman_dialog();
+return TRUE;
 }
 
-gboolean menu_cb_maps_select(GtkAction * action, gpointer new_repo)
+gboolean 
+menu_cb_maps_select(GtkAction * action, gpointer new_repo)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       repo_set_curr(new_repo);
-       map_force_redraw();
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+repo_set_curr(new_repo);
+map_force_redraw();
+return TRUE;
 }
 
-gboolean cb_zoom_autozoom(GtkAction * action)
+gboolean 
+cb_zoom_auto(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       map_set_autozoom(TRUE);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+map_set_autozoom(TRUE);
+return TRUE;
 }
 
-gboolean cb_zoom_base(GtkAction * action)
+gboolean 
+cb_zoom_base(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       map_set_autozoom(FALSE);
-       map_set_zoom(4);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+map_set_autozoom(FALSE);
+map_set_zoom(4);
+return TRUE;
 }
 
-gboolean cb_zoomin(GtkAction * action)
+gboolean 
+cb_zoomin(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       map_set_autozoom(FALSE);
-       map_zoom(-1);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+map_set_autozoom(FALSE);
+map_zoom(-1);
+return TRUE;
 }
 
-gboolean cb_zoomout(GtkAction * action)
+gboolean 
+cb_zoomout(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       map_set_autozoom(FALSE);
-       map_zoom(1);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+map_set_autozoom(FALSE);
+map_zoom(1);
+return TRUE;
 }
 
-gboolean cb_fullscreen_click(GtkAction * action)
+gboolean 
+cb_fullscreen(GtkAction * action)
 {
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_fullscreen_item), !_fullscreen);
-       return TRUE;
+if ((_fullscreen = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
+       gtk_window_fullscreen(GTK_WINDOW(_window));
+} else {
+       gtk_window_unfullscreen(GTK_WINDOW(_window));
 }
-
-gboolean cb_fullscreen(GtkAction * action)
-{
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if ((_fullscreen = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_fullscreen_item)))) {
-               gtk_window_fullscreen(GTK_WINDOW(_window));
-               gtk_widget_set_state(GTK_WIDGET(_toolbar_fullscreen_item), GTK_STATE_ACTIVE);
-       } else {
-               gtk_window_unfullscreen(GTK_WINDOW(_window));
-               gtk_widget_set_state(GTK_WIDGET(_toolbar_fullscreen_item), GTK_STATE_NORMAL);
-       }
-
-       gtk_idle_add((GSourceFunc) window_present, NULL);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gtk_idle_add((GSourceFunc) window_present, NULL);
+return TRUE;
 }
 
-gboolean menu_cb_enable_gps(GtkAction * action)
+gboolean 
+menu_cb_enable_gps(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if ((_enable_gps =
-            gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM
-                                           (_menu_enable_gps_item)))) {
-               if (_rcvr_mac) {
-                       set_conn_state(RCVR_DOWN);
-                       rcvr_connect_now();
-               } else {
-                       popup_error(_window,
-                                   _("Cannot enable GPS until a GPS Receiver MAC "
-                                    "is set in the Settings dialog box."));
-                       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                                      (_menu_enable_gps_item),
-                                                      FALSE);
-               }
+if ((_enable_gps = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
+       if (_rcvr_mac) {
+               set_conn_state(RCVR_DOWN);
+               rcvr_connect_now();
        } else {
-               if (_conn_state > RCVR_OFF)
-                       set_conn_state(RCVR_OFF);
-               rcvr_disconnect();
-               track_add(0, FALSE);
-               _speed_excess = FALSE;
+               popup_error(_window, _("Cannot enable GPS until a GPS Receiver MAC is set in the Settings dialog box."));
+               set_action_activate("gps_enable", FALSE);
        }
-       map_move_mark();
-       gps_show_info();
-       gtk_widget_set_sensitive(GTK_WIDGET(_menu_gps_details_item), _enable_gps);
+} else {
+       if (_conn_state > RCVR_OFF)
+               set_conn_state(RCVR_OFF);
+       rcvr_disconnect();
+       track_add(0, FALSE);
+       _speed_excess = FALSE;
+}
+map_move_mark();
+gps_show_info();
+set_action_sensitive("gps_details", _enable_gps);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_auto_download(GtkAction * action)
+gboolean 
+menu_cb_auto_download(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if ((_auto_download =
-            gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(_menu_auto_download_item)))) {
-               if (_curr_repo->url == REPOTYPE_NONE)
-                       popup_error(_window,
-                                   _("NOTE: You must set a Map URI in the current repository in "
-                                    "order to download maps."));
-               map_force_redraw();
-       }
+if ((_auto_download = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) )) {
+       if (_curr_repo->url == REPOTYPE_NONE)
+               popup_error(_window, _("NOTE: You must set a Map URI in the current repository in order to download maps."));
+       map_force_redraw();
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_gps_details(GtkAction * action)
+gboolean 
+menu_cb_gps_details(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       gps_details();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gps_details();
+return TRUE;
 }
 
-gboolean menu_cb_settings(GtkAction * action)
+gboolean 
+menu_cb_settings(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (settings_dialog()) {
-               /* Settings have changed - reconnect to receiver. */
-               if (_enable_gps) {
-                       set_conn_state(RCVR_DOWN);
-                       rcvr_disconnect();
-                       rcvr_connect_now();
-               }
+if (settings_dialog()) {
+       /* Settings have changed - reconnect to receiver. */
+       if (_enable_gps) {
+               set_conn_state(RCVR_DOWN);
+               rcvr_disconnect();
+               rcvr_connect_now();
        }
-       MACRO_RECALC_FOCUS_BASE();
-       MACRO_RECALC_FOCUS_SIZE();
-       map_force_redraw();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+}
+MACRO_RECALC_FOCUS_BASE();
+MACRO_RECALC_FOCUS_SIZE();
+map_force_redraw();
+return TRUE;
 }
 
-gboolean menu_cb_help(GtkAction * action)
+gboolean 
+menu_cb_help(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
 #ifdef WITH_OSSO
-       ossohelp_show(_osso, HELP_ID_INTRO, 0);
+ossohelp_show(_osso, HELP_ID_INTRO, 0);
 #endif
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_about(GtkAction * action)
+gboolean 
+menu_cb_about(GtkAction * action)
 {
-#ifdef WITH_OSSO
-ossohelp_show(_osso, HELP_ID_ABOUT, OSSO_HELP_SHOW_DIALOG);
-#else
 gchar *authors[]={
-       "Kaj-Michael Lang","John Costigan","Cezary Jackiewicz", NULL};
+       "Kaj-Michael Lang",
+       "John Costigan",
+       "Cezary Jackiewicz", NULL
+};
 
 gtk_show_about_dialog(GTK_WINDOW(_window), 
        "name", "Mapper",
@@ -731,108 +556,92 @@ gtk_show_about_dialog(GTK_WINDOW(_window),
        "license", "GPL",
        "authors", authors,
        NULL);
-#endif
 return TRUE;
 }
 
-gboolean window_cb_key_press(GtkWidget * widget, GdkEventKey * event)
+gboolean 
+window_cb_key_press(GtkWidget * widget, GdkEventKey * event)
 {
-       CustomKey custom_key;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+CustomKey custom_key;
 
-       switch (event->keyval) {
+switch (event->keyval) {
        case HILDON_HARDKEY_UP:
                custom_key = CUSTOM_KEY_UP;
-               break;
+       break;
        case HILDON_HARDKEY_DOWN:
                custom_key = CUSTOM_KEY_DOWN;
-               break;
+       break;
        case HILDON_HARDKEY_LEFT:
                custom_key = CUSTOM_KEY_LEFT;
-               break;
+       break;
        case HILDON_HARDKEY_RIGHT:
                custom_key = CUSTOM_KEY_RIGHT;
-               break;
+       break;
        case HILDON_HARDKEY_SELECT:
                custom_key = CUSTOM_KEY_SELECT;
-               break;
+       break;
        case HILDON_HARDKEY_INCREASE:
                custom_key = CUSTOM_KEY_INCREASE;
-               break;
+       break;
        case HILDON_HARDKEY_DECREASE:
                custom_key = CUSTOM_KEY_DECREASE;
-               break;
+       break;
        case HILDON_HARDKEY_FULLSCREEN:
                custom_key = CUSTOM_KEY_FULLSCREEN;
-               break;
+       break;
        case HILDON_HARDKEY_ESC:
                custom_key = CUSTOM_KEY_ESC;
-               break;
+       break;
        default:
-               vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
                return FALSE;
-       }
+}
 
        switch (_action[custom_key]) {
        case CUSTOM_ACTION_PAN_NORTH:
                map_pan(0, -PAN_UNITS);
-               break;
-
+       break;
        case CUSTOM_ACTION_PAN_WEST:
                map_pan(-PAN_UNITS, 0);
-               break;
-
+       break;
        case CUSTOM_ACTION_PAN_SOUTH:
                map_pan(0, PAN_UNITS);
-               break;
-
+       break;
        case CUSTOM_ACTION_PAN_EAST:
                map_pan(PAN_UNITS, 0);
-               break;
-
+       break;
        case CUSTOM_ACTION_TOGGLE_AUTOCENTER:
                switch (_center_mode) {
                case CENTER_LATLON:
                case CENTER_WAS_LEAD:
-                       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                                      (_menu_ac_lead_item),
-                                                      TRUE);
-                       break;
+                       set_action_activate("autocenter_lead", TRUE);
+               break;
                case CENTER_LEAD:
                case CENTER_WAS_LATLON:
-                       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                                      (_menu_ac_latlon_item),
-                                                      TRUE);
-                       break;
-               default:;
-               }
+                       set_action_activate("autocenter_latlon", TRUE);
                break;
-
+               default:
+                       set_action_activate("autocenter_latlon", TRUE);
+               break;
+               }
+       break;
        case CUSTOM_ACTION_ZOOM_IN:
        case CUSTOM_ACTION_ZOOM_OUT:
                if (!_key_zoom_timeout_sid) {
                        g_printf("Z: %d %d\n", _key_zoom_new, _zoom);
-                       _key_zoom_new = _zoom
-                           + (_action[custom_key] == CUSTOM_ACTION_ZOOM_IN
-                              ? -_curr_repo->view_zoom_steps
-                              : _curr_repo->view_zoom_steps);
+                       _key_zoom_new = _zoom + (_action[custom_key] == CUSTOM_ACTION_ZOOM_IN
+                              ? -_curr_repo->view_zoom_steps : _curr_repo->view_zoom_steps);
                        /* Remember, _key_zoom_new is unsigned. */
                        if (_key_zoom_new < MAX_ZOOM) {
                                gchar buffer[80];
-                               snprintf(buffer, sizeof(buffer), "%s %d",
-                                        _("Zoom to Level"), _key_zoom_new);
+                               snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), _key_zoom_new);
                                MACRO_BANNER_SHOW_INFO(_window, buffer);
-                               _key_zoom_timeout_sid =
-                                   g_timeout_add(500, map_key_zoom_timeout,
-                                                 NULL);
+                               _key_zoom_timeout_sid = g_timeout_add(400, map_key_zoom_timeout, NULL);
                        }
                }
-               break;
-
+       break;
        case CUSTOM_ACTION_TOGGLE_FULLSCREEN:
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_fullscreen_item), !_fullscreen);
-               break;
-
+               set_action_activate("view_fullscreen", !_fullscreen);
+       break;
        case CUSTOM_ACTION_TOGGLE_TRACKS:
                switch (_show_tracks) {
                case 0:
@@ -852,100 +661,68 @@ gboolean window_cb_key_press(GtkWidget * widget, GdkEventKey * event)
                         * clear. */
                        _show_tracks = _show_tracks << 16;
                }
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_show_routes_item),
-                                              _show_tracks & ROUTES_MASK);
-
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_show_tracks_item),
-                                              _show_tracks & TRACKS_MASK);
-
+               set_action_activate("view_route", _show_tracks & ROUTES_MASK);
+               set_action_activate("view_track", _show_tracks & TRACKS_MASK);
+       break;
        case CUSTOM_ACTION_TOGGLE_SCALE:
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_show_scale_item),
-                                              !_show_scale);
-               break;
-
+               set_action_activate("view_scale", _show_scale);
+       break;
        case CUSTOM_ACTION_TOGGLE_POI:
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_show_poi_item),
-                                              !_show_poi);
-               break;
-       case CUSTOM_ACTION_CHANGE_REPO:{
+               set_action_activate("view_poi", _show_poi);
+       break;
+       case CUSTOM_ACTION_CHANGE_REPO: {
                        GList *curr = g_list_find(_repo_list, _curr_repo);
                        if (!curr)
                                break;
 
                        /* Loop until we reach a next-able repo, or until we get
                         * back to the current repo. */
-                       while ((curr = (curr->next ? curr->next : _repo_list))
-                              && !((RepoData *) curr->data)->nextable
-                              && curr->data != _curr_repo) {
+                       while ((curr = (curr->next ? curr->next : _repo_list)) && !((RepoData *) curr->data)->nextable && curr->data != _curr_repo) {
                        }
 
                        if (curr->data != _curr_repo) {
                                repo_set_curr(curr->data);
-                               gtk_check_menu_item_set_active
-                                   (GTK_CHECK_MENU_ITEM(_curr_repo->menu_item),
-                                    TRUE);
+                               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_curr_repo->menu_item), TRUE);
                        } else {
-                               popup_error(_window,
-                                           _
-                                           ("There are no other next-able repositories."));
+                               popup_error(_window, _("There are no other next-able repositories."));
                        }
                        break;
                }
-
+       break;
        case CUSTOM_ACTION_ROUTE_DISTNEXT:
                route_show_distance_to_next();
-               break;
-
+       break;
        case CUSTOM_ACTION_ROUTE_DISTLAST:
                route_show_distance_to_last();
-               break;
-
+       break;
        case CUSTOM_ACTION_TRACK_BREAK:
                track_insert_break();
-               break;
-
+       break;
        case CUSTOM_ACTION_TRACK_DISTLAST:
                track_show_distance_from_last();
-               break;
-
+       break;
        case CUSTOM_ACTION_TRACK_DISTFIRST:
                track_show_distance_from_first();
-               break;
-
+       break;
        case CUSTOM_ACTION_TOGGLE_GPS:
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_enable_gps_item),
-                                              !_enable_gps);
-               break;
-
+               set_action_activate("gps_enable", !_enable_gps);
+       break;
        case CUSTOM_ACTION_TOGGLE_GPSINFO:
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_gps_show_info_item),
-                                              !_gps_info);
-               break;
-
+               set_action_activate("gps_info", !_gps_info);
+       break;
        case CUSTOM_ACTION_TOGGLE_SPEEDLIMIT:
                _speed_limit_on ^= 1;
-               break;
-
+       break;
        default:
-               vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
                return FALSE;
-       }
-
-       return TRUE;
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+}
+return TRUE;
 }
 
-gboolean window_cb_key_release(GtkWidget * widget, GdkEventKey * event)
+gboolean 
+window_cb_key_release(GtkWidget * widget, GdkEventKey * event)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       switch (event->keyval) {
+switch (event->keyval) {
        case HILDON_HARDKEY_INCREASE:
        case HILDON_HARDKEY_DECREASE:
                if (_key_zoom_timeout_sid) {
@@ -953,114 +730,98 @@ gboolean window_cb_key_release(GtkWidget * widget, GdkEventKey * event)
                        _key_zoom_timeout_sid = 0;
                        map_set_zoom(_key_zoom_new);
                }
-               return TRUE;
-
+       return TRUE;
+       break;
        default:
                return FALSE;
-       }
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+}
 }
 
-void cmenu_show_latlon(guint unitx, guint unity)
+void 
+cmenu_show_latlon(guint unitx, guint unity)
 {
-       gdouble lat, lon;
-       gchar buffer[80], tmp1[16], tmp2[16];
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       g_printf("S: %d %d\n", unitx, unity);
-
-       unit2latlon(unitx, unity, lat, lon);
-       lat_format(lat, tmp1);
-       lon_format(lon, tmp2);
+gdouble lat, lon;
+gchar buffer[80], tmp1[16], tmp2[16];
 
-       snprintf(buffer, sizeof(buffer),
-                "%s: %s\n"
-                "%s: %s", _("Latitude"), tmp1, _("Longitude"), tmp2);
+unit2latlon(unitx, unity, lat, lon);
+lat_format(lat, tmp1);
+lon_format(lon, tmp2);
 
-       MACRO_BANNER_SHOW_INFO(_window, buffer);
+snprintf(buffer, sizeof(buffer),
+        "%s: %s\n"
+        "%s: %s", _("Latitude"), tmp1, _("Longitude"), tmp2);
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+MACRO_BANNER_SHOW_INFO(_window, buffer);
 }
 
-void cmenu_clip_latlon(guint unitx, guint unity)
+void 
+cmenu_clip_latlon(guint unitx, guint unity)
 {
-       gchar buffer[80];
-       gdouble lat, lon;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       unit2latlon(unitx, unity, lat, lon);
-
-       snprintf(buffer, sizeof(buffer), "%.06f,%.06f", lat, lon);
+gchar buffer[80];
+gdouble lat, lon;
 
-       gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD),
-                              buffer, -1);
+unit2latlon(unitx, unity, lat, lon);
+snprintf(buffer, sizeof(buffer), "%.06f,%.06f", lat, lon);
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), buffer, -1);
 }
 
-void cmenu_route_to(guint unitx, guint unity)
+void 
+cmenu_route_to(guint unitx, guint unity)
 {
-       gchar buffer[80];
-       gchar strlat[32];
-       gchar strlon[32];
-       gdouble lat, lon;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       unit2latlon(unitx, unity, lat, lon);
+gchar buffer[80];
+gchar strlat[32];
+gchar strlon[32];
+gdouble lat, lon;
 
-       g_ascii_formatd(strlat, 32, "%.06f", lat);
-       g_ascii_formatd(strlon, 32, "%.06f", lon);
-       snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
+unit2latlon(unitx, unity, lat, lon);
 
-       route_download(buffer);
+g_ascii_formatd(strlat, 32, "%.06f", lat);
+g_ascii_formatd(strlon, 32, "%.06f", lon);
+snprintf(buffer, sizeof(buffer), "%s, %s", strlat, strlon);
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+route_download(buffer);
 }
 
-void cmenu_distance_to(guint unitx, guint unity)
+void 
+cmenu_distance_to(guint unitx, guint unity)
 {
-       gchar buffer[80];
-       gdouble lat, lon;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       unit2latlon(unitx, unity, lat, lon);
+gchar buffer[80];
+gdouble lat, lon;
 
-       snprintf(buffer, sizeof(buffer), "%s: %.02lf %s", _("Distance"),
-                calculate_distance(_gps.lat, _gps.lon, lat, lon)
-                * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
-       MACRO_BANNER_SHOW_INFO(_window, buffer);
+unit2latlon(unitx, unity, lat, lon);
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+snprintf(buffer, sizeof(buffer), "%s: %.02lf %s", _("Distance"),
+        calculate_distance(_gps.lat, _gps.lon, lat, lon) * UNITS_CONVERT[_units], UNITS_TEXT[_units]);
+MACRO_BANNER_SHOW_INFO(_window, buffer);
 }
 
-void cmenu_add_route(guint unitx, guint unity)
+void 
+cmenu_add_route(guint unitx, guint unity)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       MACRO_PATH_INCREMENT_TAIL(_route);
-       _route.tail->unitx = x2unit(_cmenu_position_x);
-       _route.tail->unity = y2unit(_cmenu_position_y);
-       route_find_nearest_point();
-       map_force_redraw();
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+MACRO_PATH_INCREMENT_TAIL(_route);
+_route.tail->unitx = x2unit(_cmenu_position_x);
+_route.tail->unity = y2unit(_cmenu_position_y);
+route_find_nearest_point();
+map_force_redraw();
 }
 
 void cmenu_route_add_way(guint unitx, guint unity)
 {
-       gdouble lat, lon;
-       gchar tmp1[16], tmp2[16], *p_latlon;
-       GtkWidget *dialog;
-       GtkWidget *table;
-       GtkWidget *label;
-       GtkWidget *txt_scroll;
-       GtkWidget *txt_desc;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       dialog = gtk_dialog_new_with_buttons(_("Add Waypoint"),
-                                            GTK_WINDOW(_window),
-                                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                            GTK_RESPONSE_ACCEPT,
-                                            GTK_STOCK_CANCEL,
-                                            GTK_RESPONSE_REJECT, NULL);
+gdouble lat, lon;
+gchar tmp1[16], tmp2[16], *p_latlon;
+GtkWidget *dialog;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *txt_scroll;
+GtkWidget *txt_desc;
+
+dialog = gtk_dialog_new_with_buttons(_("Add Waypoint"),
+                            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, 2, FALSE), TRUE, TRUE, 0);
@@ -1161,98 +922,83 @@ void cmenu_route_add_way(guint unitx, guint unity)
                MACRO_QUEUE_DRAW_AREA();
                break;
        }
-       gtk_widget_destroy(dialog);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+gtk_widget_destroy(dialog);
 }
 
-gboolean cmenu_cb_loc_show_latlon(GtkAction * action)
+gboolean 
+cmenu_cb_loc_show_latlon(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       cmenu_show_latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+cmenu_show_latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_clip_latlon(GtkAction * action)
+gboolean 
+cmenu_cb_loc_clip_latlon(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       cmenu_clip_latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+cmenu_clip_latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_route_to(GtkAction * action)
+gboolean 
+cmenu_cb_loc_route_to(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       cmenu_route_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+cmenu_route_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_distance_to(GtkAction * action)
+gboolean 
+cmenu_cb_loc_distance_to(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       cmenu_distance_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+cmenu_distance_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_add_route(GtkAction * action)
+gboolean 
+cmenu_cb_loc_add_route(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       cmenu_add_route(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+cmenu_add_route(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_add_way(GtkAction * action)
+gboolean 
+cmenu_cb_loc_add_way(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       cmenu_route_add_way(x2unit(_cmenu_position_x),
-                           y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+cmenu_route_add_way(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_add_poi(GtkAction * action)
+gboolean 
+cmenu_cb_loc_add_poi(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       poi_dialog(ACTION_ADD_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+poi_dialog(ACTION_ADD_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cb_add_poi(GtkAction * action)
+gboolean 
+cb_add_poi(GtkAction *action)
 {
-       guint unitx, unity;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+guint unitx, unity;
+const gchar *name = gtk_action_get_name(action);
 
-       if (_center_mode > 0) {
-               latlon2unit(_gps.lat, _gps.lon, unitx, unity);
-               poi_dialog(ACTION_ADD_POI, unitx, unity);
-       } else {
-               poi_dialog(ACTION_ADD_POI, _center.unitx, _center.unity);
-       }
+if (_center_mode > 0) {
+       latlon2unit(_gps.lat, _gps.lon, unitx, unity);
+} else {
+       unitx=_center.unitx;
+       unity=_center.unity;
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+if (strcmp(name, "poi_add")==0) 
+       poi_dialog(ACTION_ADD_POI, unitx, unity);
+else if (strcmp(name, "poi_quick_add")==0) 
+       poi_quick_dialog(unitx, unity);
+else
+       g_assert_not_reached();
+
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_set_home(GtkAction * action)
+gboolean 
+cmenu_cb_loc_set_home(GtkAction * action)
 {
 guint unitx, unity;
 
@@ -1265,7 +1011,8 @@ config_save_home();
 return TRUE;
 }
 
-gboolean cmenu_cb_loc_set_destination(GtkAction *action)
+gboolean 
+cmenu_cb_loc_set_destination(GtkAction *action)
 {
 guint unitx, unity;
 
@@ -1276,249 +1023,224 @@ _dest.valid=TRUE;
 return TRUE;
 }
 
-gboolean cmenu_cb_loc_set_gps(GtkAction * action)
+gboolean 
+cmenu_cb_loc_set_gps(GtkAction * action)
 {
 _pos.unitx = x2unit(_cmenu_position_x);
 _pos.unity = y2unit(_cmenu_position_y);
 unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon);
 
 /* Move mark to new location. */
-refresh_mark();
+map_refresh_mark();
 track_add(time(NULL), FALSE);
 
 return TRUE;
 }
 
-gboolean cmenu_cb_way_show_latlon(GtkAction * action)
+gboolean 
+cmenu_cb_way_show_latlon(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y))))
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
                cmenu_show_latlon(way->point->unitx, way->point->unity);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_way_show_desc(GtkAction * action)
+gboolean 
+cmenu_cb_way_show_desc(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y)))) {
-               MACRO_BANNER_SHOW_INFO(_window, way->desc);
-       }
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+       MACRO_BANNER_SHOW_INFO(_window, way->desc);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_way_clip_latlon(GtkAction * action)
+gboolean 
+cmenu_cb_way_clip_latlon(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y))))
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
                cmenu_clip_latlon(way->point->unitx, way->point->unity);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_way_clip_desc(GtkAction * action)
+gboolean 
+cmenu_cb_way_clip_desc(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y))))
-               gtk_clipboard_set_text(gtk_clipboard_get
-                                      (GDK_SELECTION_CLIPBOARD), way->desc,
-                                      -1);
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+       gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), way->desc, -1);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_way_route_to(GtkAction * action)
+gboolean 
+cmenu_cb_way_route_to(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y))))
-               cmenu_route_to(way->point->unitx, way->point->unity);
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+       cmenu_route_to(way->point->unitx, way->point->unity);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_way_distance_to(GtkAction * action)
+gboolean 
+cmenu_cb_way_distance_to(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y))))
-               route_show_distance_to(way->point);
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+       route_show_distance_to(way->point);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_way_delete(GtkAction * action)
+gboolean 
+cmenu_cb_way_delete(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y)))) {
-               gchar buffer[BUFFER_SIZE];
-               GtkWidget *confirm;
+WayPoint *way;
 
-               snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
-                        _("Confirm delete of waypoint"), way->desc);
-               confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+       gchar buffer[BUFFER_SIZE];
+       GtkWidget *confirm;
 
-               if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
-                       Point *pdel_min, *pdel_max, *pdel_start, *pdel_end;
-                       guint num_del;
+       snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
+                _("Confirm delete of waypoint"), way->desc);
+       confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
 
-                       /* Delete surrounding route data, too. */
-                       if (way == _route.whead)
-                               pdel_min = _route.head;
-                       else
-                               pdel_min = way[-1].point;
+       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+               Point *pdel_min, *pdel_max, *pdel_start, *pdel_end;
+               guint num_del;
 
-                       if (way == _route.wtail)
-                               pdel_max = _route.tail;
-                       else
-                               pdel_max = way[1].point;
+               /* Delete surrounding route data, too. */
+               if (way == _route.whead)
+                       pdel_min = _route.head;
+               else
+                       pdel_min = way[-1].point;
 
-                       /* Find largest continuous segment around the waypoint, EXCLUDING
-                        * pdel_min and pdel_max. */
-                       for (pdel_start = way->point - 1; pdel_start->unity
-                            && pdel_start > pdel_min; pdel_start--) {
-                       }
-                       for (pdel_end = way->point + 1; pdel_end->unity
-                            && pdel_end < pdel_max; pdel_end++) {
-                       }
+               if (way == _route.wtail)
+                       pdel_max = _route.tail;
+               else
+                       pdel_max = way[1].point;
 
-                       /* If pdel_end is set to _route.tail, and if _route.tail is a
-                        * non-zero point, then delete _route.tail. */
-                       if (pdel_end == _route.tail && pdel_end->unity)
-                               pdel_end++;     /* delete _route.tail too */
-                       /* else, if *both* endpoints are zero points, delete one. */
-                       else if (!pdel_start->unity && !pdel_end->unity)
-                               pdel_start--;
-
-                       /* Delete BETWEEN pdel_start and pdel_end, exclusive. */
-                       num_del = pdel_end - pdel_start - 1;
-
-                       memmove(pdel_start + 1, pdel_end,
-                               (_route.tail - pdel_end + 1) * sizeof(Point));
-                       _route.tail -= num_del;
-
-                       /* Remove waypoint and move/adjust subsequent waypoints. */
-                       g_free(way->desc);
-                       while (way++ != _route.wtail) {
-                               way[-1] = *way;
-                               way[-1].point -= num_del;
-                       }
-                       _route.wtail--;
+               /* Find largest continuous segment around the waypoint, EXCLUDING
+                * pdel_min and pdel_max. */
+               for (pdel_start = way->point - 1; pdel_start->unity
+                    && pdel_start > pdel_min; pdel_start--) {
+               }
+               for (pdel_end = way->point + 1; pdel_end->unity
+                    && pdel_end < pdel_max; pdel_end++) {
+               }
 
-                       route_find_nearest_point();
-                       map_force_redraw();
+               /* If pdel_end is set to _route.tail, and if _route.tail is a
+                * non-zero point, then delete _route.tail. */
+               if (pdel_end == _route.tail && pdel_end->unity)
+                       pdel_end++;     /* delete _route.tail too */
+               /* else, if *both* endpoints are zero points, delete one. */
+               else if (!pdel_start->unity && !pdel_end->unity)
+                       pdel_start--;
+
+               /* Delete BETWEEN pdel_start and pdel_end, exclusive. */
+               num_del = pdel_end - pdel_start - 1;
+
+               memmove(pdel_start + 1, pdel_end,(_route.tail - pdel_end + 1) * sizeof(Point));
+               _route.tail -= num_del;
+
+               /* Remove waypoint and move/adjust subsequent waypoints. */
+               g_free(way->desc);
+               while (way++ != _route.wtail) {
+                       way[-1] = *way;
+                       way[-1].point -= num_del;
                }
-               gtk_widget_destroy(confirm);
+               _route.wtail--;
+
+               route_find_nearest_point();
+               map_force_redraw();
        }
+       gtk_widget_destroy(confirm);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_way_add_poi(GtkAction * action)
+gboolean 
+cmenu_cb_way_add_poi(GtkAction * action)
 {
-       WayPoint *way;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
-               poi_dialog(ACTION_ADD_POI, way->point->unitx, way->point->unity);
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y))))
+       poi_dialog(ACTION_ADD_POI, way->point->unitx, way->point->unity);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_poi_route_to(GtkAction * action)
+gboolean 
+cmenu_cb_poi_route_to(GtkAction * action)
 {
-       poi_info poi;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+poi_info poi;
 
-       if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
-               guint unitx, unity;
-               latlon2unit(poi.lat, poi.lon, unitx, unity);
-               cmenu_route_to(unitx, unity);
-       }
+if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
+       guint unitx, unity;
+       latlon2unit(poi.lat, poi.lon, unitx, unity);
+       cmenu_route_to(unitx, unity);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_poi_distance_to(GtkAction * action)
+gboolean 
+cmenu_cb_poi_distance_to(GtkAction * action)
 {
-       poi_info poi;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+poi_info poi;
 
-       if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
-               guint unitx, unity;
-               latlon2unit(poi.lat, poi.lon, unitx, unity);
-               cmenu_distance_to(unitx, unity);
-       }
+if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
+       guint unitx, unity;
+       latlon2unit(poi.lat, poi.lon, unitx, unity);
+       cmenu_distance_to(unitx, unity);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_poi_add_route(GtkAction * action)
+gboolean 
+cmenu_cb_poi_add_route(GtkAction * action)
 {
-       poi_info poi;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+poi_info poi;
 
-       if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
-               guint unitx, unity;
-               latlon2unit(poi.lat, poi.lon, unitx, unity);
-               cmenu_add_route(unitx, unity);
-       }
+if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
+       guint unitx, unity;
+       latlon2unit(poi.lat, poi.lon, unitx, unity);
+       cmenu_add_route(unitx, unity);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_poi_add_way(GtkAction * action)
+gboolean 
+cmenu_cb_poi_add_way(GtkAction * action)
 {
-       poi_info poi;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+poi_info poi;
 
-       if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
-               guint unitx, unity;
-               latlon2unit(poi.lat, poi.lon, unitx, unity);
-               cmenu_route_add_way(unitx, unity);
-       }
+if (select_poi(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), &poi)) {
+       guint unitx, unity;
+       latlon2unit(poi.lat, poi.lon, unitx, unity);
+       cmenu_route_add_way(unitx, unity);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_poi_edit_poi(GtkAction * action)
+gboolean 
+cmenu_cb_poi_edit_poi(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       poi_dialog(ACTION_EDIT_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+poi_dialog(ACTION_EDIT_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
index db088b020aa3bf338e389ccfe57210ab40db5946..126e33d48cb0e7b6a881e59fb74fd18fcc21c87e 100644 (file)
--- a/src/cb.h
+++ b/src/cb.h
 gboolean window_cb_key_press(GtkWidget * widget, GdkEventKey * event);
 gboolean window_cb_key_release(GtkWidget * widget, GdkEventKey * event);
 
-gboolean map_cb_configure(GtkWidget * widget, GdkEventConfigure * event);
-gboolean map_cb_expose(GtkWidget * widget, GdkEventExpose * event);
-gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event);
-gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event);
-gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event);
-
 gboolean heading_panel_expose(GtkWidget * widget, GdkEventExpose * event);
 gboolean sat_panel_expose(GtkWidget * widget, GdkEventExpose * event);
 gboolean sat_details_panel_expose(GtkWidget * widget, GdkEventExpose * event);
@@ -51,7 +45,7 @@ gboolean menu_cb_maps_repoman(GtkAction * action);
 gboolean menu_cb_auto_download(GtkAction * action);
 
 /* Callbacks for the "View" submenu. */
-gboolean cb_zoom_autozoom(GtkAction * action);
+gboolean cb_zoom_auto(GtkAction * action);
 gboolean cb_zoom_base(GtkAction * action);
 gboolean cb_zoomin(GtkAction * action);
 gboolean cb_zoomout(GtkAction * action);
@@ -65,9 +59,7 @@ gboolean menu_cb_show_poi(GtkAction * action);
 gboolean menu_cb_category(GtkAction * action);
 
 /* Callbacks for the "Auto-Center" submenu. */
-gboolean menu_cb_ac_latlon(GtkAction * action);
-gboolean menu_cb_ac_lead(GtkAction * action);
-gboolean menu_cb_ac_none(GtkAction * action);
+gboolean menu_cb_autocenter(GtkAction *action, GtkRadioAction *current);
 
 /* Callbacks for the "Go to" submenu. */
 gboolean menu_cb_goto_latlon(GtkAction * action);
index 0ab3097249c87b949e11dbf312417f36f4453cbf..2816b7495885d6462793caa76b48a549cff80551 100644 (file)
@@ -139,21 +139,18 @@ if (!gconf_client)
        return FALSE;
 
 /* Get Map Cache Dir.  Default is REPO_DEFAULT_CACHE_DIR. */
-repo->cache_dir = gconf_client_get_string(gconf_client,
-                 GCONF_KEY_MAP_DIR_NAME, NULL);
+repo->cache_dir = gconf_client_get_string(gconf_client, GCONF_KEY_MAP_DIR_NAME, NULL);
 
 if (!repo->cache_dir)
        repo->cache_dir = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_DIR);
 
 /* Get Map Download URL Format.  Default is "". */
-repo->url = gconf_client_get_string(gconf_client,
-                           GCONF_KEY_MAP_URI_FORMAT, NULL);
+repo->url = gconf_client_get_string(gconf_client, GCONF_KEY_MAP_URI_FORMAT, NULL);
 if (!repo->url)
        repo->url = g_strdup(REPO_DEFAULT_MAP_URI);
 
-/* Get Map Download Zoom Steps.  Default is 2. */
-repo->dl_zoom_steps = gconf_client_get_int(gconf_client,
-                  GCONF_KEY_MAP_ZOOM_STEPS, NULL);
+/* Get Map Download Zoom Steps.  Default is 1. */
+repo->dl_zoom_steps = gconf_client_get_int(gconf_client, GCONF_KEY_MAP_ZOOM_STEPS, NULL);
 if (!repo->dl_zoom_steps)
        repo->dl_zoom_steps = REPO_DEFAULT_DL_ZOOM_STEPS;
 
@@ -177,9 +174,7 @@ GConfClient *gconf_client = gconf_client_get_default();
 if (!gconf_client)
        return FALSE;
 
-guint curr_repo_index = gconf_client_get_int(gconf_client,
-                            GCONF_KEY_CURRREPO,
-                            NULL);
+guint curr_repo_index = gconf_client_get_int(gconf_client, GCONF_KEY_CURRREPO, NULL);
 list = gconf_client_get_list(gconf_client, GCONF_KEY_REPOSITORIES, GCONF_VALUE_STRING, NULL);
 
 for (curr = list; curr != NULL; curr = curr->next) {
@@ -519,23 +514,27 @@ void config_init(void)
        } else
                _enable_voice = TRUE;
 
-       /* Get Voice Speed - Default is 1.0. */
+       /* Get Voice Speed - Default is . */
        value = gconf_client_get(gconf_client, GCONF_KEY_VOICE_SPEED, NULL);
        if (value) {
-               _voice_speed = gconf_value_get_float(value);
+               _voice_speed = gconf_value_get_int(value);
                gconf_value_free(value);
        } else {
-               _voice_speed = 1.0;
+               _voice_speed = 120;
        }
+       if (_voice_speed<80 || _voice_speed>370)
+               _voice_speed = 120;
 
-       /* Get Voice Speed - Default is 0. */
+       /* Get Voice Speed - Default is 50. */
        value = gconf_client_get(gconf_client, GCONF_KEY_VOICE_PITCH, NULL);
        if (value) {
                _voice_pitch = gconf_value_get_int(value);
                gconf_value_free(value);
        } else {
-               _voice_pitch = 3;
+               _voice_pitch = 50;
        }
+       if (_voice_pitch<1 || _voice_pitch>99)
+               _voice_pitch = 50;
 
        /* Get Always Keep On flag.  Default is FALSE. */
        _always_keep_on = gconf_client_get_bool(gconf_client,GCONF_KEY_ALWAYS_KEEP_ON, NULL);
@@ -688,90 +687,90 @@ void config_init(void)
                latlon2unit(center_lat, center_lon, _center.unitx, _center.unity);
        }
 
-       config_load_repo();
-
-       /* Get last Zoom Level.  Default is 12. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_ZOOM, NULL);
-       if (value) {
-               _zoom = gconf_value_get_int(value) / _curr_repo->view_zoom_steps
-                   * _curr_repo->view_zoom_steps;
-               gconf_value_free(value);
-       } else
-               _zoom = 12 / _curr_repo->view_zoom_steps
-                   * _curr_repo->view_zoom_steps;
-       BOUND(_zoom, 0, MAX_ZOOM - 1);
-       _world_size_tiles = unit2tile(WORLD_SIZE_UNITS);
-
-       /* Speed and Heading are always initialized as 0. */
-       _gps.speed = 0.f;
-       _gps.heading = 0.f;
-
-       /* Get Route Directory.  Default is NULL. */
-       _route_dir_uri = gconf_client_get_string(gconf_client,
-                                                GCONF_KEY_ROUTEDIR, NULL);
-
-       /* Get Last Track File.  Default is NULL. */
-       _track_file_uri = gconf_client_get_string(gconf_client,
-                                                 GCONF_KEY_TRACKFILE, NULL);
+config_load_repo();
 
-       /* Get Auto-Center Mode.  Default is CENTER_LEAD. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_AUTOCENTER_MODE, NULL);
-       if (value) {
-               _center_mode = gconf_value_get_int(value);
-               gconf_value_free(value);
-       } else
-               _center_mode = CENTER_LEAD;
+/* Get last Zoom Level.  Default is 12. */
+value = gconf_client_get(gconf_client, GCONF_KEY_ZOOM, NULL);
+if (value) {
+       _zoom = gconf_value_get_int(value) / _curr_repo->view_zoom_steps * _curr_repo->view_zoom_steps;
+       gconf_value_free(value);
+} else {
+       _zoom = 12 / _curr_repo->view_zoom_steps * _curr_repo->view_zoom_steps;
+}
+BOUND(_zoom, 0, MAX_ZOOM - 1);
+_world_size_tiles = unit2tile(WORLD_SIZE_UNITS);
+
+/* Get Route Directory.  Default is NULL. */
+_route_dir_uri = gconf_client_get_string(gconf_client, GCONF_KEY_ROUTEDIR, NULL);
+
+/* Get Last Track File.  Default is NULL. */
+_track_file_uri = gconf_client_get_string(gconf_client, GCONF_KEY_TRACKFILE, NULL);
+
+/* Get Auto-Center Mode.  Default is CENTER_LEAD. */
+value = gconf_client_get(gconf_client, GCONF_KEY_AUTOCENTER_MODE, NULL);
+if (value) {
+       _center_mode = gconf_value_get_int(value);
+       gconf_value_free(value);
+} else {
+       _center_mode = CENTER_LEAD;
+}
 
-       /* Get Show Scale flag.  Default is TRUE. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_SHOWSCALE, NULL);
-       if (value) {
-               _show_scale = gconf_value_get_bool(value);
-               gconf_value_free(value);
-       } else
-               _show_scale = TRUE;
+/* Get Show Scale flag.  Default is TRUE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_SHOWSCALE, NULL);
+if (value) {
+       _show_scale = gconf_value_get_bool(value);
+       gconf_value_free(value);
+} else {
+       _show_scale = TRUE;
+}
 
-       /* Get Show Tracks flag.  Default is TRUE. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_SHOWTRACKS, NULL);
-       if (value) {
-               _show_tracks |= (gconf_value_get_bool(value) ? TRACKS_MASK : 0);
-               gconf_value_free(value);
-       } else
-               _show_tracks |= TRACKS_MASK;
+/* Get Show Tracks flag.  Default is TRUE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_SHOWTRACKS, NULL);
+if (value) {
+       _show_tracks |= (gconf_value_get_bool(value) ? TRACKS_MASK : 0);
+       gconf_value_free(value);
+} else {
+       _show_tracks |= TRACKS_MASK;
+}
 
-       /* Get Show Routes flag.  Default is TRUE. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_SHOWROUTES, NULL);
-       if (value) {
-               _show_tracks |= (gconf_value_get_bool(value) ? ROUTES_MASK : 0);
-               gconf_value_free(value);
-       } else
-               _show_tracks |= ROUTES_MASK;
+/* Get Show Routes flag.  Default is TRUE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_SHOWROUTES, NULL);
+if (value) {
+       _show_tracks |= (gconf_value_get_bool(value) ? ROUTES_MASK : 0);
+       gconf_value_free(value);
+} else {
+       _show_tracks |= ROUTES_MASK;
+}
 
-       /* Get Show Velocity Vector flag.  Default is TRUE. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_SHOWVELVEC, NULL);
-       if (value) {
-               _show_velvec = gconf_value_get_bool(value);
-               gconf_value_free(value);
-       } else
-               _show_velvec = TRUE;
+/* Get Show Velocity Vector flag.  Default is TRUE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_SHOWVELVEC, NULL);
+if (value) {
+       _show_velvec = gconf_value_get_bool(value);
+       gconf_value_free(value);
+} else {
+       _show_velvec = TRUE;
+}
 
-       /* Get Show Velocity Vector flag.  Default is TRUE. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_SHOWPOIS, NULL);
-       if (value) {
-               _show_poi = gconf_value_get_bool(value);
-               gconf_value_free(value);
-       } else
-               _show_poi = TRUE;
+/* Get Show Velocity Vector flag.  Default is TRUE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_SHOWPOIS, NULL);
+if (value) {
+       _show_poi = gconf_value_get_bool(value);
+       gconf_value_free(value);
+} else {
+       _show_poi = TRUE;
+}
 
-       /* Get Enable GPS flag.  Default is TRUE. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_ENABLE_GPS, NULL);
-       if (value) {
-               _enable_gps = gconf_value_get_bool(value);
-               gconf_value_free(value);
-       } else
-               _enable_gps = TRUE;
+/* Get Enable GPS flag.  Default is TRUE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_ENABLE_GPS, NULL);
+if (value) {
+       _enable_gps = gconf_value_get_bool(value);
+       gconf_value_free(value);
+} else {
+       _enable_gps = TRUE;
+}
 
-       /* Initialize _conn_state based on _enable_gps. */
-       _conn_state = (_enable_gps ? RCVR_DOWN : RCVR_OFF);
+/* Initialize _conn_state based on _enable_gps. */
+_conn_state = (_enable_gps ? RCVR_DOWN : RCVR_OFF);
 
        /* Load the route locations. */
        {
@@ -795,60 +794,51 @@ void config_init(void)
                _mapper_db = gnome_vfs_uri_make_full_from_relative(poi_base, "poi.db");
                g_free(poi_base);
        }
-       mapper_db_connect(&_db, _mapper_db);
 
-       _poi_zoom = gconf_client_get_int(gconf_client,
-                                        GCONF_KEY_POI_ZOOM, NULL);
-       if (!_poi_zoom)
-               _poi_zoom = 6;
+mapper_db_connect(&_db, _mapper_db);
 
-       /* Get GPS Info flag.  Default is FALSE. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_GPS_INFO, NULL);
-       if (value) {
-               _gps_info = gconf_value_get_bool(value);
-               gconf_value_free(value);
-       } else
-               _gps_info = FALSE;
-
-       /* Get Route Download URL.  Default is:
-        * "http://www.gnuite.com/cgi-bin/gpx.cgi?saddr=%s&daddr=%s" */
-       _route_dl_url = gconf_client_get_string(gconf_client,
-                                               GCONF_KEY_ROUTE_DL_URL, NULL);
-       if (_route_dl_url == NULL)
-               _route_dl_url =
-                   g_strdup
-                   ("http://www.gnuite.com/cgi-bin/gpx.cgi?saddr=%s&daddr=%s");
-
-       /* Get Route Download Radius.  Default is 4. */
-       value = gconf_client_get(gconf_client, GCONF_KEY_ROUTE_DL_RADIUS, NULL);
-       if (value) {
-               _route_dl_radius = gconf_value_get_int(value);
-               gconf_value_free(value);
-       } else
-               _route_dl_radius = 4;
+_poi_zoom = gconf_client_get_int(gconf_client, GCONF_KEY_POI_ZOOM, NULL);
+if (!_poi_zoom)
+       _poi_zoom = 6;
 
-       /* Get Colors. */
-       {
-               gint i;
-               for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
-                       str = gconf_client_get_string(gconf_client,
-                                                     COLORABLE_GCONF[i], NULL);
-                       if (!str || !gdk_color_parse(str, &_color[i]))
-                               _color[i] = COLORABLE_DEFAULT[i];
-               }
-       }
+/* Get GPS Info flag.  Default is FALSE. */
+value = gconf_client_get(gconf_client, GCONF_KEY_GPS_INFO, NULL);
+if (value) {
+       _gps_info = gconf_value_get_bool(value);
+       gconf_value_free(value);
+} else {
+       _gps_info = FALSE;
+}
 
-       /* Get current proxy settings. */
-       config_update_proxy();
+/* Get Route Download URL.  Default is:
+ * "http://www.gnuite.com/cgi-bin/gpx.cgi?saddr=%s&daddr=%s" */
+_route_dl_url = gconf_client_get_string(gconf_client, GCONF_KEY_ROUTE_DL_URL, NULL);
+if (_route_dl_url == NULL)
+       _route_dl_url = g_strdup("http://www.gnuite.com/cgi-bin/gpx.cgi?saddr=%s&daddr=%s");
+
+/* Get Route Download Radius.  Default is 4. */
+value = gconf_client_get(gconf_client, GCONF_KEY_ROUTE_DL_RADIUS, NULL);
+if (value) {
+       _route_dl_radius = gconf_value_get_int(value);
+       gconf_value_free(value);
+} else {
+       _route_dl_radius = 4;
+}
 
-       gconf_client_clear_cache(gconf_client);
-       g_object_unref(gconf_client);
-       g_free(config_dir);
+/* Get Colors. */
+{
+       gint i;
+       for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
+               str = gconf_client_get_string(gconf_client, COLORABLE_GCONF[i], NULL);
+               if (!str || !gdk_color_parse(str, &_color[i]))
+                       _color[i] = COLORABLE_DEFAULT[i];
+       }
+}
 
-       /* GPS data init */
-       _gps.fix = 1;
-       _gps.satinuse = 0;
-       _gps.satinview = 0;
+/* Get current proxy settings. */
+config_update_proxy();
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+gconf_client_clear_cache(gconf_client);
+g_object_unref(gconf_client);
+g_free(config_dir);
 }
index 1157a2266e852480aa2173a9d92b11cb025a3dbe..1c177e0af7aed4b778910c21cf331703619c6c9c 100644 (file)
@@ -1,7 +1,5 @@
 #define _GNU_SOURCE
 
-#define _(String) gettext(String)
-
 #include <config.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -9,6 +7,7 @@
 #include <errno.h>
 #include <sys/wait.h>
 #include <glib/gstdio.h>
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <fcntl.h>
 #include <dbus/dbus-glib.h>
index 5c45f5382e4e950fa5455e0fb417415cfc622321..ae27ca9813f7af6068c41ff01b44f8d51460fca7 100644 (file)
@@ -26,7 +26,8 @@
 #include "gps-panels.h"
 #include "settings.h"
 
-gint track_drop_cnt=0;
+#define GPS_FILTER_MAX_SKIP (10)
+static gint track_drop_cnt=0;
 
 gboolean
 channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data)
@@ -48,7 +49,8 @@ channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data)
        return FALSE;
 }
 
-void channel_parse_rmc(gchar * sentence)
+static void 
+channel_parse_rmc(gchar * sentence)
 {
        /* Recommended Minimum Navigation Information C
         *  1) UTC Time
@@ -161,7 +163,7 @@ void channel_parse_rmc(gchar * sentence)
        /* XXX: Set filter logic somewhere else */
 
        if ((_conn_state == RCVR_FIXED) && (_track_store==TRUE)) {
-               if ((_gps_filter==TRUE) && (track_drop_cnt<10)) {
+               if ((_gps_filter==TRUE) && (track_drop_cnt<GPS_FILTER_MAX_SKIP)) {
                        integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps);
                        if ( (_gps.hdop<_filter_hdop || _filter_hdop==0.0) && 
                                (_gps.vdop<_filter_vdop || _filter_vdop==0.0) && 
@@ -172,26 +174,29 @@ void channel_parse_rmc(gchar * sentence)
                                track_drop_cnt=0;
                        } else {
                                track_drop_cnt++;
-                               g_printf("*** Filtering by: [%s %s %s %s] (%d)\n", 
+                               g_printf("*** Filtering by: [%s %s %s %s] A: %f (%d)\n", 
                                        _gps.hdop>_filter_hdop ? "HDOP" : "-", 
                                        _gps.vdop>_filter_vdop ? "VDOP" : "-", 
                                        (fabs(_gps.heading-_gps.lheading)<_filter_angle) ? "Angle" : "-",
-                                       (_map_location_known==TRUE && (_map_location_dist>_filter_osm)) ? "OSM" : "-", track_drop_cnt);
+                                       (_map_location_known==TRUE && (_map_location_dist>_filter_osm)) ? "OSM" : "-", 
+                                       (fabs(_gps.heading-_gps.lheading)<_filter_angle),
+                                       track_drop_cnt);
                        }
-                       refresh_mark();
+                       map_refresh_mark();
                } else {
                        track_drop_cnt=0;
                        integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps);
                        track_add(_pos.time, newly_fixed);
                        _gps.lheading=_gps.heading;
-                       refresh_mark();
+                       map_refresh_mark();
                }
        }
 
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-void channel_parse_gga(gchar * sentence)
+static void 
+channel_parse_gga(gchar * sentence)
 {
        /* GGA          Global Positioning System Fix Data
           1. Fix Time
@@ -258,7 +263,8 @@ void channel_parse_gga(gchar * sentence)
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-void channel_parse_gsa(gchar * sentence)
+static void 
+channel_parse_gsa(gchar * sentence)
 {
        /* GPS DOP and active satellites
         *  1) Auto selection of 2D or 3D fix (M = manual)
@@ -309,7 +315,8 @@ void channel_parse_gsa(gchar * sentence)
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-void channel_parse_gsv(gchar * sentence)
+static void 
+channel_parse_gsv(gchar * sentence)
 {
        /* Must be GSV - Satellites in view
         *  1) total number of messages
@@ -433,8 +440,10 @@ channel_cb_input(GIOChannel * src, GIOCondition condition, gpointer data)
                                        else if (!strncmp(_gps_read_buf + 3, "GSA", 3))
                                                channel_parse_gsa(_gps_read_buf + 7);
                                        else g_print("Unknown NMEA: [%s]\n", _gps_read_buf);
+
                                        if (_gps_info)
                                                gps_display_data();
+
                                        if (_satdetails_on)
                                                gps_display_details();
                                } else {
index e197d542fd69f8c7bbb3b9dae2a90ec57aa15321..dc2711c692ac4448f492414db85a2273a2cd797c 100644 (file)
 #include "latlon.h"
 #include "route.h"
 
+#include "gps-panels.h"
+
+static GtkWidget *text_lat;
+static GtkWidget *text_lon;
+static GtkWidget *text_speed;
+static GtkWidget *text_alt;
+static GtkWidget *text_dop;
+static GtkWidget *text_time;
+static GtkWidget *sat_panel;
+static GtkWidget *heading_panel;
+
+static gboolean sat_panel_expose(GtkWidget * widget, GdkEventExpose * event);
+static gboolean heading_panel_expose(GtkWidget * widget, GdkEventExpose * event);
+
+static void gps_clear_text_fields(void);
+
+GtkWidget *
+gps_info_panel(void)
+{
+GtkWidget *label, *vbox;
+
+vbox = gtk_vbox_new(FALSE, 0);
+
+label = gtk_label_new(" ");
+gtk_widget_set_size_request(GTK_WIDGET(label), -1, 10);
+gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
+
+text_lat = gtk_label_new(NULL);
+gtk_widget_set_size_request(GTK_WIDGET(text_lat), -1, 30);
+gtk_box_pack_start(GTK_BOX(vbox), text_lat, FALSE, TRUE, 0);
+
+text_lon = gtk_label_new(NULL);
+gtk_widget_set_size_request(GTK_WIDGET(text_lon), -1, 30);
+gtk_box_pack_start(GTK_BOX(vbox), text_lon, FALSE, TRUE, 0);
+
+text_speed = gtk_label_new(NULL);
+gtk_widget_set_size_request(GTK_WIDGET(text_speed), -1, 30);
+gtk_box_pack_start(GTK_BOX(vbox), text_speed, FALSE, TRUE, 0);
+
+text_alt = gtk_label_new(NULL);
+gtk_widget_set_size_request(GTK_WIDGET(text_alt), -1, 30);
+gtk_box_pack_start(GTK_BOX(vbox), text_alt, FALSE, TRUE, 0);
+
+text_dop = gtk_label_new(NULL);
+gtk_widget_set_size_request(GTK_WIDGET(text_dop), -1, 30);
+gtk_box_pack_start(GTK_BOX(vbox), text_dop, FALSE, TRUE, 0);
+
+sat_panel = gtk_drawing_area_new();
+gtk_widget_set_size_request(sat_panel, -1, 100);
+gtk_box_pack_start(GTK_BOX(vbox), sat_panel, TRUE, TRUE, 0);
+
+text_time = gtk_label_new(NULL);
+gtk_widget_set_size_request(GTK_WIDGET(text_time), -1, 30);
+gtk_box_pack_start(GTK_BOX(vbox), text_time, FALSE, TRUE, 0);
+
+heading_panel = gtk_drawing_area_new();
+gtk_widget_set_size_request(heading_panel, -1, 100);
+gtk_box_pack_start(GTK_BOX(vbox), heading_panel, TRUE, TRUE, 0);
+
+gps_clear_text_fields();
+
+g_signal_connect(G_OBJECT(sat_panel), "expose_event", G_CALLBACK(sat_panel_expose), NULL);
+g_signal_connect(G_OBJECT(heading_panel), "expose_event", G_CALLBACK(heading_panel_expose), NULL);
+
+return vbox;
+}
+
 void
 gps_display_data_speed(GtkWidget *widget, gfloat s)
 {
@@ -45,6 +112,17 @@ gtk_label_set_label(GTK_LABEL(widget), buffer);
 g_free(buffer);
 }
 
+static void
+gps_clear_text_fields(void)
+{
+gtk_label_set_label(GTK_LABEL(text_lat), " --- ");
+gtk_label_set_label(GTK_LABEL(text_lon), " --- ");
+gtk_label_set_label(GTK_LABEL(text_speed), " --- ");
+gtk_label_set_label(GTK_LABEL(text_alt), " --- ");
+gtk_label_set_label(GTK_LABEL(text_dop), " --- ");
+gtk_label_set_label(GTK_LABEL(text_time), "--:--:--");
+}
+
 void 
 gps_display_data(void)
 {
@@ -53,26 +131,22 @@ printf("%s()\n", __PRETTY_FUNCTION__);
 
 /* local time */
 strftime(litbuf, 15, "%X", localtime(&_pos.time));
-gtk_label_set_label(GTK_LABEL(_text_time), litbuf);
+gtk_label_set_label(GTK_LABEL(text_time), litbuf);
 
 if (_gps.fix < 2) {
        /* no fix no fun */
-       gtk_label_set_label(GTK_LABEL(_text_lat), " --- ");
-       gtk_label_set_label(GTK_LABEL(_text_lon), " --- ");
-       gtk_label_set_label(GTK_LABEL(_text_speed), " --- ");
-       gtk_label_set_label(GTK_LABEL(_text_alt), " --- ");
-       gtk_label_set_label(GTK_LABEL(_text_dop), "0/0/0");
+       gps_clear_text_fields();
 } else {
        /* latitude */
        lat_format(_gps.lat, litbuf);
-       gtk_label_set_label(GTK_LABEL(_text_lat), litbuf);
+       gtk_label_set_label(GTK_LABEL(text_lat), litbuf);
 
        /* longitude */
        lon_format(_gps.lon, litbuf);
-       gtk_label_set_label(GTK_LABEL(_text_lon), litbuf);
+       gtk_label_set_label(GTK_LABEL(text_lon), litbuf);
 
        /* speed */
-       gps_display_data_speed(_text_speed, _gps.speed);
+       gps_display_data_speed(text_speed, _gps.speed);
 
        /* altitude */
        switch (_units) {
@@ -83,24 +157,24 @@ if (_gps.fix < 2) {
        default:
                buffer = g_strdup_printf("Alt: %.1f m", _pos.altitude);
        }
-       gtk_label_set_label(GTK_LABEL(_text_alt), buffer);
+       gtk_label_set_label(GTK_LABEL(text_alt), buffer);
        g_free(buffer);
 
        /* DOP */
        buffer = g_strdup_printf("%.1f/%.1f/%.1f", _gps.hdop, _gps.vdop, _gps.pdop);
-       gtk_label_set_label(GTK_LABEL(_text_dop), buffer);
+       gtk_label_set_label(GTK_LABEL(text_dop), buffer);
        g_free(buffer);
 }
 
 /* refresh sat panel */
-gtk_widget_queue_draw_area(GTK_WIDGET(_sat_panel), 0, 0,
-                          _sat_panel->allocation.width,
-                          _sat_panel->allocation.height);
+gtk_widget_queue_draw_area(GTK_WIDGET(sat_panel), 0, 0,
+                          sat_panel->allocation.width,
+                          sat_panel->allocation.height);
 
 /* refresh heading panel */
-gtk_widget_queue_draw_area(GTK_WIDGET(_heading_panel), 0, 0,
-                          _heading_panel->allocation.width,
-                          _heading_panel->allocation.height);
+gtk_widget_queue_draw_area(GTK_WIDGET(heading_panel), 0, 0,
+                          heading_panel->allocation.width,
+                          heading_panel->allocation.height);
 
 vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 return;
@@ -220,7 +294,8 @@ vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 return;
 }
 
-gboolean sat_panel_expose(GtkWidget * widget, GdkEventExpose * event)
+static gboolean 
+sat_panel_expose(GtkWidget * widget, GdkEventExpose * event)
 {
 gchar *tmp = NULL;
 guint x, y;
@@ -262,7 +337,7 @@ vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 return TRUE;
 }
 
-gboolean 
+static gboolean 
 heading_panel_expose(GtkWidget * widget, GdkEventExpose * event)
 {
 guint size, xoffset, yoffset, i, x, y;
@@ -789,7 +864,8 @@ gtk_widget_destroy(dialog);
 
 }
 
-void gps_details(void)
+void 
+gps_details(void)
 {
 GtkWidget *dialog;
 GtkWidget *table;
index b01bc32ffcd91265750b018ecbc5e7943b665147..a9268311d85e56b8ecf8929c5a539812fbfef29f 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef _GPS_PANELS_H
 #define _GPS_PANELS_H
 
+GtkWidget *gps_info_panel(void);
 void gps_display_data_speed(GtkWidget *widget, gfloat s);
 void gps_display_data(void);
 
index 3e46447669057ec562cdecb579138cdaacfb4c53..d93b32369c8bad3e5607bf9ee5807baec719455c 100644 (file)
--- a/src/gps.h
+++ b/src/gps.h
@@ -84,6 +84,8 @@ gint _vel_offsety;
 GpsData _gps;
 GpsSatelliteData _gps_sat[12];
 
+void gps_init(void);
+
 gboolean channel_cb_error(GIOChannel * src, GIOCondition condition, gpointer data);
 gboolean channel_cb_connect(GIOChannel * src, GIOCondition condition, gpointer data);
 gboolean channel_cb_input(GIOChannel * src, GIOCondition condition, gpointer data);
index eb8f70e4c5d5a87ad759bb5e39143a505e0d6b67..3f7643e461de86e09ecc8c7ebbb0bb1eea384c77 100644 (file)
--- a/src/gpx.c
+++ b/src/gpx.c
@@ -1,5 +1,5 @@
 /*
- * This file is part of maemo-mapper
+ * This file is part of mapper
  *
  * Copyright (C) 2006-2007 John Costigan.
  *
@@ -24,8 +24,6 @@
 
 #define _GNU_SOURCE
 
-#define _(String) gettext(String)
-
 #include <config.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -37,6 +35,7 @@
 #include <errno.h>
 #include <sys/wait.h>
 #include <glib/gstdio.h>
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <fcntl.h>
 #include <libgnomevfs/gnome-vfs.h>
@@ -360,15 +359,9 @@ gpx_end_element(SaxData * data, const xmlChar * name)
                                                        if (error_check !=
                                                            (ptr + 1)) {
                                                                /* Parse of minutes worked. Calculate. */
-                                                               data->path.
-                                                                   tail->
-                                                                   time +=
-                                                                   (time.
-                                                                    tm_gmtoff -
-                                                                    (offhours *
-                                                                     60 * 60 +
-                                                                     offmins *
-                                                                     60));
+                                                               data->path.tail->time +=
+                                                                   (time.tm_gmtoff -
+                                                                    (offhours * 60 * 60 + offmins * 60));
                                                        }
                                                }
                                        }
index 64198b3ef92d27de27c6e885c743f33036dbe308..4ce9187e47eba25d482c34e0f8cf3432411f5f90 100644 (file)
@@ -89,13 +89,10 @@ GtkWidget *hildon_banner_show_animation(GtkWidget *widget,
 hildon_banner_show_information(_status_bar, NULL, text);
 gtk_widget_show(_progress_item);
 gtk_progress_bar_pulse(_progress_item);
+gtk_progress_bar_set_text(_progress_item, text);
 return NULL;
 }
 
-void gtk_widget_tap_and_hold_setup(GtkWidget * a, GtkWidget * w, void *p, gint t)
-{
-}
-
 GtkWidget *hildon_number_editor_new(gint min, gint max)
 {
 return gtk_spin_button_new_with_range(min, max, 1);
index bfcff11873f661106803edd3cf8030d46e342795..cbc6eeae7873de32c74966b9d85801fe6446546e 100644 (file)
@@ -39,7 +39,6 @@ void hildon_banner_set_fraction(GtkWidget * widget, gdouble fraction);
 GtkWidget *hildon_banner_show_animation(GtkWidget *widget,
                                        const gchar *animation_name,
                                        const gchar *text);
-void gtk_widget_tap_and_hold_setup(GtkWidget * a, GtkWidget * w, void *p, gint t);
 GtkWidget *hildon_number_editor_new(gint min, gint max);
 gint hildon_number_editor_get_value(GtkWidget * w);
 void hildon_number_editor_set_value(GtkWidget * w, gint v);
index c640171e248c31d00dea51bb03c3ba0159f992cc..98731461d299d0105d08a8d5239cc1966f4a4d2c 100644 (file)
 #include "ui-common.h"
 #include "db.h"
 
-#define POI_FONT_SIZE  (10)
+#define POI_FONT_SIZE_BIG (14)
+#define POI_FONT_SIZE_SMALL (10)
 
 static GHashTable *poi_icon_hash = NULL;
 static PangoContext *context = NULL;
 static PangoLayout *layout = NULL;
 static PangoFontDescription *fontdesc = NULL;
 
-gboolean map_poi_init(GtkWidget *map_widget)
+gboolean 
+map_poi_init(GtkWidget *map_widget)
 {
 poi_icon_hash=g_hash_table_new(g_str_hash, g_str_equal);
 context = gtk_widget_get_pango_context(map_widget);
 layout = pango_layout_new(context);
 fontdesc = pango_font_description_new();
 pango_font_description_set_family(fontdesc,"Sans Serif");
-pango_font_description_set_size(fontdesc, POI_FONT_SIZE*PANGO_SCALE);
+pango_font_description_set_size(fontdesc, POI_FONT_SIZE_SMALL*PANGO_SCALE);
 pango_layout_set_font_description (layout, fontdesc);
 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
+pango_layout_set_width(layout, 70*PANGO_SCALE);
 return TRUE;
 }
 
-static void map_poi_title(gint x, gint y,gchar *title)
+static void 
+map_poi_title(gint x, gint y,gchar *title)
 {
 gint w,h;
 
@@ -43,19 +47,25 @@ pango_layout_get_pixel_size(layout, &w, &h);
 gdk_draw_layout(_map_pixmap, _gc[COLORABLE_POI], x-(w>>1), y-h-_draw_width, layout);
 }
 
-static GdkPixbuf *map_poi_get_icon(gchar *icon)
+static GdkPixbuf *
+map_poi_get_icon(gchar *icon)
 {
 gchar buffer[100];
-GdkPixbuf *pixbuf = NULL;
+GdkPixbuf *pixbuf;
 GError *error = NULL;
 
+if (icon==NULL)
+       return NULL;
+
 pixbuf = g_hash_table_lookup(poi_icon_hash, icon);
 if (pixbuf)
        return pixbuf;
 
-snprintf(buffer, sizeof(buffer),"%s/icons/%s.jpg", _curr_repo->cache_dir, icon);
+snprintf(buffer, sizeof(buffer), DATADIR "/pixmaps/osm/%s.png", icon);
 pixbuf=gdk_pixbuf_new_from_file(buffer, &error);
 
+g_printf("POI icon: %s\n", buffer);
+
 if (error)
        return NULL;
 
@@ -66,13 +76,13 @@ return pixbuf;
 /**
  * Render all the POI data.  This should be done before rendering track data.
  */
-void map_render_poi(void)
+void 
+map_render_poi(void)
 {
 guint unitx, unity;
-gfloat lat1, lat2, lon1, lon2;
+gdouble lat1, lat2, lon1, lon2;
 gint poix, poiy;
 GdkPixbuf *pixbuf = NULL;
-printf("%s()\n", __PRETTY_FUNCTION__);
 
 if (!_db) 
        return;
@@ -95,29 +105,36 @@ if (SQLITE_OK != sqlite3_bind_double(poisql.select_poi, 1, lat1)
        return;
 }
 
+if (_zoom<2) {
+       pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
+       pango_font_description_set_size(fontdesc, POI_FONT_SIZE_SMALL*PANGO_SCALE);
+} else {
+       pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
+       pango_font_description_set_size(fontdesc, POI_FONT_SIZE_BIG*PANGO_SCALE);
+}
+
 while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
        lat1 = sqlite3_column_double(poisql.select_poi, 0);
        lon1 = sqlite3_column_double(poisql.select_poi, 1);
        gchar *poi_label = sqlite3_column_text(poisql.select_poi, 3);
-       gchar *cat_label = g_utf8_strdown(sqlite3_column_text(poisql.select_poi, 6), -1);
+       gchar *cat_icon = sqlite3_column_text(poisql.select_poi, 8);
+       gchar *cat_color = sqlite3_column_text(poisql.select_poi, 9);
 
        latlon2unit(lat1, lon1, unitx, unity);
        poix = unit2bufx(unitx);
        poiy = unit2bufy(unity);
 
-       pixbuf=map_poi_get_icon(cat_label);
-       g_free(cat_label);
+       pixbuf=map_poi_get_icon(cat_icon);
 
        if (!pixbuf) {
                /* No icon for POI or for category - draw default. */
-               gdk_draw_rectangle(_map_pixmap,
-                                  _gc[COLORABLE_POI], TRUE,
-                                  poix - (gint) (1.5f * _draw_width),
-                                  poiy - (gint) (1.5f * _draw_width),
-                                  3 * _draw_width,
-                                  3 * _draw_width);
-               if (_zoom<3 && poi_label)
+               gdk_draw_arc(_map_pixmap, _gc[COLORABLE_POI], FALSE,
+                       poix - _draw_width, poiy - _draw_width, 
+                       (MAX_ZOOM-_zoom)/6 * _draw_width, (MAX_ZOOM-_zoom)/6 * _draw_width, 0, 360 * 64);
+
+               if (_zoom<3 && poi_label) {
                        map_poi_title(poix, poiy, poi_label);
+               }
        } else {
                gdk_draw_pixbuf(_map_pixmap,
                                _gc[COLORABLE_POI],
@@ -130,6 +147,4 @@ while (SQLITE_ROW == sqlite3_step(poisql.select_poi)) {
 }
 sqlite3_reset(poisql.select_poi);
 sqlite3_clear_bindings(poisql.select_poi);
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
index 2b130f07a14121f773c71f9c2b24a25242e6b16d..fc76dde1e2003b54654eaf6c4c50ac63bfe4ba81 100644 (file)
@@ -14,7 +14,6 @@
 #include <libgnomevfs/gnome-vfs.h>
 #include <curl/multi.h>
 #include <gconf/gconf-client.h>
-#include <sqlite3.h>
 
 #include "hildon-mapper.h"
 
 #include "mapper-types.h"
 #include "ui-common.h"
 
-#define REPO_DEFAULT_NAME "OpenStreet"
-#define REPO_DEFAULT_CACHE_BASE "~/MyDocs/.documents/Maps/"
-#define REPO_DEFAULT_CACHE_DIR REPO_DEFAULT_CACHE_BASE"OpenStreet"
-#define REPO_DEFAULT_MAP_URI "http://tile.openstreetmap.org/%0d/%d/%d.png"
-#define REPO_DEFAULT_DL_ZOOM_STEPS (2)
-#define REPO_DEFAULT_VIEW_ZOOM_STEPS (1)
-
 typedef struct _RepoManInfo RepoManInfo;
 struct _RepoManInfo {
        GtkWidget *dialog;
@@ -80,31 +72,28 @@ struct _MapmanInfo {
 
 void set_repo_type(RepoData * repo)
 {
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, repo->url);
-
-       if (repo->url && *repo->url) {
-               gchar *url = g_utf8_strdown(repo->url, -1);
-
-               /* Determine type of repository. */
-               if (strstr(url, "service=wms"))
-                       repo->type = REPOTYPE_WMS;
-               else if (strstr(url, "%s"))
-                       repo->type = REPOTYPE_QUAD_QRST;
-               else if (strstr(url, "%0d"))
-                       repo->type = REPOTYPE_XYZ_INV;
-               else if (strstr(url, "%0s"))
-                       repo->type = REPOTYPE_QUAD_ZERO;
-               else
-                       repo->type = REPOTYPE_XYZ;
-
-               g_free(url);
-       } else
-               repo->type = REPOTYPE_NONE;
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+if (repo->url && *repo->url) {
+       gchar *url = g_utf8_strdown(repo->url, -1);
+
+       /* Determine type of repository. */
+       if (strstr(url, "service=wms"))
+               repo->type = REPOTYPE_WMS;
+       else if (strstr(url, "%s"))
+               repo->type = REPOTYPE_QUAD_QRST;
+       else if (strstr(url, "%0d"))
+               repo->type = REPOTYPE_XYZ_INV;
+       else if (strstr(url, "%0s"))
+               repo->type = REPOTYPE_QUAD_ZERO;
+       else
+               repo->type = REPOTYPE_XYZ;
+
+       g_free(url);
+} else
+       repo->type = REPOTYPE_NONE;
 }
 
-RepoData *config_parse_repo(gchar * str)
+RepoData *
+config_parse_repo(gchar * str)
 {
        /* Parse each part of a repo, delimited by newline characters:
         * 1. name
@@ -113,131 +102,116 @@ RepoData *config_parse_repo(gchar * str)
         * 4. dl_zoom_steps
         * 5. view_zoom_steps
         */
-       gchar *token, *error_check;
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, str);
-
-       RepoData *rd = g_new0(RepoData, 1);
-
-       /* Parse name. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->name = g_strdup(token);
-
-       /* Parse URL format. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->url = g_strdup(token);
-
-       /* Parse cache dir. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->cache_dir = gnome_vfs_expand_initial_tilde(token);
-
-       /* Parse download zoom steps. */
-       token = strsep(&str, "\n\t");
-       if (!token || !*token || !(rd->dl_zoom_steps = atoi(token)))
-               rd->dl_zoom_steps = 2;
-
-       /* Parse view zoom steps. */
-       token = strsep(&str, "\n\t");
-       if (!token || !*token || !(rd->view_zoom_steps = atoi(token)))
-               rd->view_zoom_steps = 1;
-
-       /* Parse double-size. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->double_size = atoi(token);  /* Default is zero (FALSE) */
-
-       /* Parse next-able. */
-       token = strsep(&str, "\n\t");
-       if (!token || !*token
-           || (rd->nextable = strtol(token, &error_check, 10), token == str))
+gchar *token, *error_check;
+
+RepoData *rd = g_new0(RepoData, 1);
+
+/* Parse name. */
+token = strsep(&str, "\n\t");
+if (token)
+       rd->name = g_strdup(token);
+
+/* Parse URL format. */
+token = strsep(&str, "\n\t");
+if (token)
+       rd->url = g_strdup(token);
+
+/* Parse cache dir. */
+token = strsep(&str, "\n\t");
+if (token)
+       rd->cache_dir = gnome_vfs_expand_initial_tilde(token);
+
+/* Parse download zoom steps. */
+token = strsep(&str, "\n\t");
+if (!token || !*token || !(rd->dl_zoom_steps = atoi(token)))
+       rd->dl_zoom_steps = 2;
+
+/* Parse view zoom steps. */
+token = strsep(&str, "\n\t");
+if (!token || !*token || !(rd->view_zoom_steps = atoi(token)))
+       rd->view_zoom_steps = 1;
+
+/* Parse double-size. */
+token = strsep(&str, "\n\t");
+if (token)
+       rd->double_size = atoi(token);  /* Default is zero (FALSE) */
+
+/* Parse next-able. */
+token = strsep(&str, "\n\t");
+if (!token || !*token
+    || (rd->nextable = strtol(token, &error_check, 10), token == str))
                rd->nextable = TRUE;
 
-       set_repo_type(rd);
-
-       vprintf("%s(): return %p\n", __PRETTY_FUNCTION__, rd);
-       return rd;
+set_repo_type(rd);
+return rd;
 }
 
 gboolean
 repo_make_cache_dir(gchar * name, const gchar * cache_dir, GtkWidget * parent)
 {
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, cache_dir);
-       if (g_mkdir_with_parents(cache_dir, 0755)) {
-               /* Failed to create Map Cache directory. */
-               gchar buffer[BUFFER_SIZE];
-               snprintf(buffer, sizeof(buffer), "%s: %s",
-                        _("Unable to create cache directory for repository"),
-                        name);
-               popup_error(parent, buffer);
-               vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
-               return FALSE;
-       }
-       vprintf("%s(): return %d\n", __PRETTY_FUNCTION__,
-               g_file_test(cache_dir, G_FILE_TEST_EXISTS));
-       return g_file_test(cache_dir, G_FILE_TEST_EXISTS);
+if (g_mkdir_with_parents(cache_dir, 0755)) {
+       /* Failed to create Map Cache directory. */
+       gchar buffer[BUFFER_SIZE];
+       snprintf(buffer, sizeof(buffer), "%s: %s",
+                _("Unable to create cache directory for repository"), name);
+       popup_error(parent, buffer);
+       return FALSE;
+}
+return g_file_test(cache_dir, G_FILE_TEST_EXISTS);
 }
 
-gboolean repo_set_curr(RepoData * rd)
+gboolean 
+repo_set_curr(RepoData * rd)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       _curr_repo = rd;
-       return repo_make_cache_dir(rd->name, rd->cache_dir, _window);
+_curr_repo = rd;
+return repo_make_cache_dir(rd->name, rd->cache_dir, _window);
 }
 
-gboolean repoman_dialog_select(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_dialog_select(GtkWidget * widget, RepoManInfo * rmi)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       gint curr_index =
-           gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
-       gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi->notebook), curr_index);
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gint curr_index = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
+gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi->notebook), curr_index);
+return TRUE;
 }
 
-gboolean repoman_dialog_browse(GtkWidget * widget, BrowseInfo * browse_info)
+static gboolean 
+repoman_dialog_browse(GtkWidget * widget, BrowseInfo * browse_info)
 {
-       GtkWidget *dialog;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GtkWidget *dialog;
 
-       dialog = GTK_WIDGET(hildon_file_chooser_dialog_new
-                      (GTK_WINDOW(browse_info->dialog),
-                       GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
-
-       gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
-       gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
-                                           gtk_entry_get_text(GTK_ENTRY
-                                                              (browse_info->
-                                                               txt)));
-
-       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               gchar *filename =
-                   gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-               gtk_entry_set_text(GTK_ENTRY(browse_info->txt), filename);
-               g_free(filename);
-       }
+dialog = GTK_WIDGET(hildon_file_chooser_dialog_new
+       (GTK_WINDOW(browse_info->dialog),
+               GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
 
-       gtk_widget_destroy(dialog);
+gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
+gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), gtk_entry_get_text(GTK_ENTRY(browse_info->txt)));
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(dialog))) {
+       gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+       gtk_entry_set_text(GTK_ENTRY(browse_info->txt), filename);
+       g_free(filename);
 }
 
-gboolean repoman_dialog_rename(GtkWidget * widget, RepoManInfo * rmi)
-{
-       GtkWidget *hbox;
-       GtkWidget *label;
-       GtkWidget *txt_name;
-       GtkWidget *dialog;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+gtk_widget_destroy(dialog);
 
-       dialog = gtk_dialog_new_with_buttons(_("New Name"),
-                                            GTK_WINDOW(rmi->dialog),
-                                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                            GTK_RESPONSE_ACCEPT,
-                                            GTK_STOCK_CANCEL,
-                                            GTK_RESPONSE_REJECT, NULL);
+return TRUE;
+}
+
+static gboolean 
+repoman_dialog_rename(GtkWidget * widget, RepoManInfo * rmi)
+{
+GtkWidget *hbox;
+GtkWidget *label;
+GtkWidget *txt_name;
+GtkWidget *dialog;
+
+dialog = gtk_dialog_new_with_buttons(_("New Name"),
+                                    GTK_WINDOW(rmi->dialog),
+                                    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),
                           hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 4);
@@ -263,26 +237,23 @@ gboolean repoman_dialog_rename(GtkWidget * widget, RepoManInfo * rmi)
                break;
        }
 
-       gtk_widget_destroy(dialog);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gtk_widget_destroy(dialog);
+return TRUE;
 }
 
-gboolean repoman_dialog_delete(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_dialog_delete(GtkWidget * widget, RepoManInfo * rmi)
 {
-       gchar buffer[100];
-       GtkWidget *confirm;
-       gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
-       printf("%s()\n", __PRETTY_FUNCTION__);
+gchar buffer[100];
+GtkWidget *confirm;
+gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
 
        if (gtk_tree_model_iter_n_children
            (GTK_TREE_MODEL
             (gtk_combo_box_get_model(GTK_COMBO_BOX(rmi->cmb_repos))),
             NULL) <= 1) {
                popup_error(rmi->dialog,
-                           _
-                           ("Cannot delete the last repository - there must be at"
+                           _("Cannot delete the last repository - there must be at"
                             " lease one repository."));
                vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
                return TRUE;
@@ -310,21 +281,21 @@ gboolean repoman_dialog_delete(GtkWidget * widget, RepoManInfo * rmi)
        return TRUE;
 }
 
-RepoEditInfo *repoman_dialog_add_repo(RepoManInfo * rmi, gchar * name)
+static RepoEditInfo *
+repoman_dialog_add_repo(RepoManInfo * rmi, gchar * name)
 {
-       GtkWidget *vbox;
-       GtkWidget *table;
-       GtkWidget *label;
-       GtkWidget *hbox;
-       RepoEditInfo *rei = g_new(RepoEditInfo, 1);
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, name);
+GtkWidget *vbox;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *hbox;
+RepoEditInfo *rei = g_new(RepoEditInfo, 1);
 
-       rei->name = name;
+rei->name = name;
 
-       /* Maps page. */
-       gtk_notebook_append_page(GTK_NOTEBOOK(rmi->notebook),
-                                vbox = gtk_vbox_new(FALSE, 4),
-                                gtk_label_new(name));
+/* Maps page. */
+gtk_notebook_append_page(GTK_NOTEBOOK(rmi->notebook),
+                        vbox = gtk_vbox_new(FALSE, 4),
+                        gtk_label_new(name));
 
        gtk_box_pack_start(GTK_BOX(vbox),
                           table = gtk_table_new(2, 2, FALSE), FALSE, FALSE, 0);
@@ -354,10 +325,8 @@ RepoEditInfo *repoman_dialog_add_repo(RepoManInfo * rmi, gchar * name)
 
        /* Initialize cache dir */
        {
-               gchar *cache_base =
-                   gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
-               gchar *cache_dir =
-                   gnome_vfs_uri_make_full_from_relative(cache_base, name);
+               gchar *cache_base = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
+               gchar *cache_dir = gnome_vfs_uri_make_full_from_relative(cache_base, name);
                gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), cache_dir);
                g_free(cache_dir);
                g_free(cache_base);
@@ -441,7 +410,8 @@ RepoEditInfo *repoman_dialog_add_repo(RepoManInfo * rmi, gchar * name)
        return rei;
 }
 
-gboolean repoman_dialog_new(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_dialog_new(GtkWidget * widget, RepoManInfo * rmi)
 {
        GtkWidget *hbox;
        GtkWidget *label;
@@ -479,14 +449,13 @@ gboolean repoman_dialog_new(GtkWidget * widget, RepoManInfo * rmi)
        return TRUE;
 }
 
-gboolean repoman_reset(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean
+repoman_reset(GtkWidget * widget, RepoManInfo * rmi)
 {
-       GtkWidget *confirm;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GtkWidget *confirm;
 
        confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
-                                              _
-                                              ("Replace all repositories with the default repository?"));
+                       _("Replace all repositories with the default repository?"));
 
        if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
                /* First, delete all existing repositories. */
@@ -514,14 +483,13 @@ gboolean repoman_reset(GtkWidget * widget, RepoManInfo * rmi)
        return TRUE;
 }
 
-gboolean repoman_download(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_download(GtkWidget * widget, RepoManInfo * rmi)
 {
-       GtkWidget *confirm;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GtkWidget *confirm;
 
        confirm = hildon_note_new_confirmation(GTK_WINDOW(rmi->dialog),
-                                              _
-                                              ("Maemo Mapper will now download and add a list of "
+                                              _("Maemo Mapper will now download and add a list of "
                                                "possibly-duplicate repositories from the internet.  "
                                                "Continue?"));
 
@@ -590,7 +558,8 @@ gboolean repoman_download(GtkWidget * widget, RepoManInfo * rmi)
        return TRUE;
 }
 
-gboolean repoman_dialog()
+gboolean 
+repoman_dialog()
 {
        RepoManInfo rmi;
        GtkWidget *hbox;
@@ -601,7 +570,6 @@ gboolean repoman_dialog()
        GtkWidget *btn_download;
        guint i, curr_repo_index = 0;
        GList *curr;
-       printf("%s()\n", __PRETTY_FUNCTION__);
 
        rmi.dialog = gtk_dialog_new_with_buttons(_("Manage Repositories"),
                                                 GTK_WINDOW(_window),
@@ -730,6 +698,7 @@ gboolean repoman_dialog()
 
                /* We're good to replace.  Remove old _repo_list menu items. */
                menu_maps_remove_repos();
+
                /* But keep the repo list in memory, in case downloads are using it. */
                _repo_list = NULL;
 
@@ -775,9 +744,8 @@ gboolean repoman_dialog()
                                repo_set_curr(rd);
                }
                if (!_curr_repo)
-                       repo_set_curr((RepoData *) g_list_first(_repo_list)->
-                                     data);
-               menu_maps_add_repos();
+                       repo_set_curr((RepoData *) g_list_first(_repo_list)->data);
+               menu_maps_add_repos(_menu_maps_submenu);
 
                config_save_repo();
                break;
@@ -791,7 +759,7 @@ gboolean repoman_dialog()
        return TRUE;
 }
 
-gboolean
+static gboolean
 mapman_by_area(gfloat start_lat, gfloat start_lon,
               gfloat end_lat, gfloat end_lon, MapmanInfo * mapman_info,
               gboolean is_deleting, gboolean is_overwriting)
@@ -877,7 +845,7 @@ mapman_by_area(gfloat start_lat, gfloat start_lon,
        return TRUE;
 }
 
-gboolean
+static gboolean
 mapman_by_route(MapmanInfo * mapman_info,
                gboolean is_deleting, gboolean is_overwriting)
 {
@@ -962,22 +930,10 @@ mapman_by_route(MapmanInfo * mapman_info,
                                                guint minx, miny, maxx, maxy, x,
                                                    y;
                                                if (prev_tiley != 0) {
-                                                       minx =
-                                                           MIN(tilex,
-                                                               prev_tilex) -
-                                                           radius;
-                                                       miny =
-                                                           MIN(tiley,
-                                                               prev_tiley) -
-                                                           radius;
-                                                       maxx =
-                                                           MAX(tilex,
-                                                               prev_tilex) +
-                                                           radius;
-                                                       maxy =
-                                                           MAX(tiley,
-                                                               prev_tiley) +
-                                                           radius;
+                                                       minx = MIN(tilex, prev_tilex) - radius;
+                                                       miny = MIN(tiley, prev_tiley) - radius;
+                                                       maxx = MAX(tilex, prev_tilex) + radius;
+                                                       maxy = MAX(tiley, prev_tiley) + radius;
                                                } else {
                                                        minx = tilex - radius;
                                                        miny = tiley - radius;
@@ -1010,7 +966,8 @@ mapman_by_route(MapmanInfo * mapman_info,
        return TRUE;
 }
 
-void mapman_clear(GtkWidget * widget, MapmanInfo * mapman_info)
+static void 
+mapman_clear(GtkWidget * widget, MapmanInfo * mapman_info)
 {
        guint i;
        printf("%s()\n", __PRETTY_FUNCTION__);
@@ -1033,7 +990,8 @@ void mapman_clear(GtkWidget * widget, MapmanInfo * mapman_info)
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-void mapman_update_state(GtkWidget * widget, MapmanInfo * mapman_info)
+static void 
+mapman_update_state(GtkWidget * widget, MapmanInfo * mapman_info)
 {
        printf("%s()\n", __PRETTY_FUNCTION__);
        gtk_widget_set_sensitive(mapman_info->chk_overwrite,
@@ -1338,53 +1296,43 @@ gboolean menu_cb_mapman(GtkAction * action)
                        gchar *error_check;
                        gfloat start_lat, start_lon, end_lat, end_lon;
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
+                       text = gtk_entry_get_text(GTK_ENTRY
                                               (mapman_info.txt_topleft_lat));
                        start_lat = strtof(text, &error_check);
                        if (text == error_check || start_lat < -90.f
                            || start_lat > 90.f) {
-                               popup_error(dialog,
-                                           _("Invalid Top-Left Latitude"));
+                               popup_error(dialog, _("Invalid Top-Left Latitude"));
                                continue;
                        }
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
+                       text = gtk_entry_get_text(GTK_ENTRY
                                               (mapman_info.txt_topleft_lon));
                        start_lon = strtof(text, &error_check);
                        if (text == error_check || start_lon < -180.f
                            || start_lon > 180.f) {
-                               popup_error(dialog,
-                                           _("Invalid Top-Left Longitude"));
+                               popup_error(dialog, _("Invalid Top-Left Longitude"));
                                continue;
                        }
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
+                       text = gtk_entry_get_text(GTK_ENTRY
                                               (mapman_info.txt_botright_lat));
                        end_lat = strtof(text, &error_check);
                        if (text == error_check || end_lat < -90.f
                            || end_lat > 90.f) {
-                               popup_error(dialog,
-                                           _("Invalid Bottom-Right Latitude"));
+                               popup_error(dialog, _("Invalid Bottom-Right Latitude"));
                                continue;
                        }
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
+                       text = gtk_entry_get_text(GTK_ENTRY
                                               (mapman_info.txt_botright_lon));
                        end_lon = strtof(text, &error_check);
                        if (text == error_check || end_lon < -180.f
                            || end_lon > 180.f) {
-                               popup_error(dialog,
-                                           _
-                                           ("Invalid Bottom-Right Longitude"));
+                               popup_error(dialog, _("Invalid Bottom-Right Longitude"));
                                continue;
                        }
 
-                       if (mapman_by_area
-                           (start_lat, start_lon, end_lat, end_lon,
+                       if (mapman_by_area(start_lat, start_lon, end_lat, end_lon,
                             &mapman_info, is_deleting, is_overwriting))
                                break;
                }
index 147a11e77f6c8a5176ebba624941a4aaae6cbbd5..53e29b957af6caa0881b61d6a2b184f5a2e0506d 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -31,6 +31,7 @@
 #include "osm-db.h"
 #include "poi.h"
 #include "route.h"
+#include "track.h"
 #include "gps.h"
 #include "bt.h"
 #include "mapper-types.h"
@@ -38,6 +39,7 @@
 #include "settings.h"
 #include "latlon.h"
 #include "gpx.h"
+#include "map-download.h"
 
 Point _min_center = { -1, -1 };
 Point _max_center = { -1, -1 };
@@ -50,16 +52,25 @@ guint _base_tiley = -5;
 guint _zoom = 3;               /* zoom level, from 0 to MAX_ZOOM. */
 Point _center = { -1, -1 };    /* current center location, X. */
 
+CenterMode _center_mode = CENTER_LEAD;
+
 static guint press[2] = { 0, 0 };
 static guint release[2] = { 0, 0 };
 static guint before[2] = { 0, 0 };
 static guint _id = 0;
 
-static gint _zoom_timeout_sid=0;
-static gint _map_mode=0;
+/** VARIABLES FOR ACCESSING THE LOCATION/BOUNDS OF THE CURRENT MARK. */
+static gint _mark_x1;
+static gint _mark_x2;
+static gint _mark_y1;
+static gint _mark_y2;
+static gint _mark_minx;
+static gint _mark_miny;
+static gint _mark_width;
+static gint _mark_height;
 
-guint _num_downloads=0;
-guint _curr_download=0;
+static gint zoom_timeout_sid=0;
+static gint map_mode=0;
 
 static osm_location map_loc = {NULL, NULL, NULL, FALSE, FALSE, 0, 0, 0.0, 0.0 };
 
@@ -71,208 +82,67 @@ struct _map_tile_rdata {
 
 void map_render_paths();
 void map_force_redraw();
-gboolean curl_download_timeout();
-gchar *map_construct_url(guint tilex, guint tiley, guint zoom);
-gboolean map_download_idle_refresh(ProgressUpdateInfo * pui);
 static void map_update_location(gint x, gint y, gboolean force);
+void map_draw_position_icon(Position *pos);
 
-gboolean get_next_pui(gpointer key, gpointer value, ProgressUpdateInfo ** data)
+gboolean 
+map_cb_configure(GtkWidget * widget, GdkEventConfigure * event)
 {
-*data = key;
-return TRUE;
-}
+_screen_width_pixels = _map_widget->allocation.width;
+_screen_height_pixels = _map_widget->allocation.height;
+_screen_grids_halfwidth = pixel2grid(_screen_width_pixels) / 2;
+_screen_grids_halfheight = pixel2grid(_screen_height_pixels) / 2;
 
-gboolean curl_download_timeout()
-{
-       static guint destroy_counter = 50;
-       gint num_transfers = 0, num_msgs = 0;
-       gint deletes_left = 50; /* only do 50 deletes at a time. */
-       CURLMsg *msg;
-       vprintf("%s()\n", __PRETTY_FUNCTION__);
+/* Set _scale_rect. */
+_scale_rect.x = (_screen_width_pixels - SCALE_WIDTH) / 2;
+_scale_rect.width = SCALE_WIDTH;
+pango_layout_set_text(_scale_layout, "0", -1);
+pango_layout_get_pixel_size(_scale_layout, NULL, &_scale_rect.height);
+_scale_rect.y = _screen_height_pixels - _scale_rect.height - 1;
 
-       if (_curl_multi && CURLM_CALL_MULTI_PERFORM == curl_multi_perform(_curl_multi, &num_transfers))
-               return TRUE;    /* Give UI a chance first. */
-
-       while (_curl_multi && (msg = curl_multi_info_read(_curl_multi, &num_msgs))) {
-               if (msg->msg == CURLMSG_DONE) {
-                       if (msg->easy_handle == _autoroute_data.curl_easy) {
-                               /* This is the autoroute download. */
-                               /* Now, parse the autoroute and update the display. */
-                               if (_autoroute_data.enabled
-                                   && parse_gpx(&_route,
-                                                _autoroute_data.rdl_data.bytes,
-                                                _autoroute_data.rdl_data.
-                                                bytes_read, 0)) {
-                                       /* Find the nearest route point, if we're connected. */
-                                       route_find_nearest_point();
-                                       map_force_redraw();
-                               }
-                               cancel_autoroute(TRUE); /* We're done. Clean up. */
-                       } else {
-                               ProgressUpdateInfo *pui = g_hash_table_lookup(_pui_by_easy, msg->easy_handle);
-                               g_queue_push_head(_curl_easy_queue, msg->easy_handle);
-                               g_hash_table_remove(_pui_by_easy, msg->easy_handle);
-                               fclose(pui->file);
-                               if (msg->data.result != CURLE_OK)
-                                       g_unlink(pui->dest_str);        /* Delete so we try again. */
-                               curl_multi_remove_handle(_curl_multi, msg->easy_handle);
-                               g_idle_add_full(G_PRIORITY_HIGH_IDLE,
-                                               (GSourceFunc)map_download_idle_refresh, pui, NULL);
-                       }
-               }
-       }
-
-       /* Up to 1 transfer per tile. */
-       while (num_transfers < (BUF_WIDTH_TILES * BUF_HEIGHT_TILES)
-              && g_tree_nnodes(_pui_tree)) {
-               ProgressUpdateInfo *pui;
-               g_tree_foreach(_pui_tree, (GTraverseFunc) get_next_pui, &pui);
-
-               if (pui->retries) {
-                       /* This is a download. */
-                       FILE *f;
-                       g_tree_steal(_pui_tree, pui);
-                       g_tree_insert(_downloading_tree, pui, pui);
-
-                       pui->src_str = map_construct_url(pui->tilex, pui->tiley, pui->zoom);
-                       pui->dest_str = g_strdup_printf("%s/%u/%u/%u.jpg",
-                                           pui->repo->cache_dir, pui->zoom,
-                                           pui->tilex, pui->tiley);
-
-                       if (!pui->src_str) {
-                               /* Failed to generate URL. */
-                               g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_download_idle_refresh, pui, NULL);
-                               continue;
-                       }
+MACRO_RECALC_FOCUS_BASE();
+MACRO_RECALC_FOCUS_SIZE();
 
-                       /* Check to see if we need to overwrite. */
-                       if (pui->retries > 0) {
-                               /* We're not updating - check if file already exists. */
-                               if (g_file_test(pui->dest_str, G_FILE_TEST_EXISTS)) {
-                                       g_idle_add_full(G_PRIORITY_HIGH_IDLE,
-                                                       (GSourceFunc)map_download_idle_refresh, pui, NULL);
-                                       continue;
-                               }
-                       }
+_min_center.unitx = pixel2unit(grid2pixel(_screen_grids_halfwidth));
+_min_center.unity = pixel2unit(grid2pixel(_screen_grids_halfheight));
+_max_center.unitx = WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfwidth) - 1;
+_max_center.unity = WORLD_SIZE_UNITS - grid2unit(_screen_grids_halfheight) - 1;
 
-                       /* Attempt to open the file for writing. */
-                       if (!(f = g_fopen(pui->dest_str, "w"))
-                           && errno == ENOENT) {
-                               /* Directory doesn't exist yet - create it, then we'll retry */
-                               gchar buffer[BUFFER_SIZE];
-                               snprintf(buffer, sizeof(buffer), "%s/%u/%u",
-                                        pui->repo->cache_dir, pui->zoom,
-                                        pui->tilex);
-                               g_mkdir_with_parents(buffer, 0775);
-                               f = g_fopen(pui->dest_str, "w");
-                       }
+map_center_unit(_center.unitx, _center.unity);
 
-                       if (f) {
-                               CURL *curl_easy;
-                               pui->file = f;
-                               curl_easy = g_queue_pop_tail(_curl_easy_queue);
-                               if (!curl_easy) {
-                                       /* Need a new curl_easy. */
-                                       MACRO_CURL_EASY_INIT(curl_easy);
-                               }
-                               curl_easy_setopt(curl_easy, CURLOPT_URL, pui->src_str);
-                               curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, f);
-                               g_hash_table_insert(_pui_by_easy, curl_easy, pui);
-                               if (!_curl_multi) {
-                                       /* Initialize CURL. */
-                                       _curl_multi = curl_multi_init();
-                                       /*curl_multi_setopt(_curl_multi, CURLMOPT_PIPELINING, 1); */
-                               }
-                               curl_multi_add_handle(_curl_multi, curl_easy);
-                               num_transfers++;
-                       } else {
-                               /* Unable to download file. */
-                               gchar buffer[BUFFER_SIZE];
-                               snprintf(buffer, sizeof(buffer), "%s:\n%s",
-                                        _("Failed to open file for writing"),
-                                        pui->dest_str);
-                               MACRO_BANNER_SHOW_INFO(_window, buffer);
-                               g_idle_add_full(G_PRIORITY_HIGH_IDLE,
-                                               (GSourceFunc)map_download_idle_refresh, pui,
-                                               NULL);
-                               continue;
-                       }
-               } else if (--deletes_left) {
-                       /* This is a delete. */
-                       gchar buffer[BUFFER_SIZE];
-                       g_tree_steal(_pui_tree, pui);
-                       g_tree_insert(_downloading_tree, pui, pui);
-
-                       snprintf(buffer, sizeof(buffer), "%s/%u/%u/%u.jpg",
-                                pui->repo->cache_dir, pui->zoom, pui->tilex,
-                                pui->tiley);
-                       g_unlink(buffer);
-                       g_idle_add_full(G_PRIORITY_HIGH_IDLE,
-                                       (GSourceFunc)map_download_idle_refresh,
-                                       pui, NULL);
-               } else
-                       break;
-       }
-
-       if (!(num_transfers || g_tree_nnodes(_pui_tree))) {
-               /* Destroy curl after 50 counts (5 seconds). */
-               if (--destroy_counter) {
-                       /* Clean up curl. */
-                       CURL *curr;
-                       while ((curr = g_queue_pop_tail(_curl_easy_queue)))
-                               curl_easy_cleanup(curr);
-
-                       curl_multi_cleanup(_curl_multi);
-                       _curl_multi = NULL;
-
-                       _curl_sid = 0;
-                       vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
-                       return FALSE;
-               }
-       } else
-               destroy_counter = 50;
-
-       vprintf("%s(): return TRUE (%d, %d)\n", __PRETTY_FUNCTION__,
-               num_transfers, g_tree_nnodes(_pui_tree));
-       return TRUE;
+return TRUE;
 }
 
 /**
  * Draw the current mark (representing the current GPS location) onto
  * _map_widget.  This method does not queue the draw area.
  */
-void map_draw_mark()
+static void 
+map_draw_mark()
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       gdk_draw_arc(_map_widget->window, _conn_state == RCVR_FIXED ? _gc[COLORABLE_MARK] : _gc[COLORABLE_MARK_OLD], FALSE,     /* not filled. */
-                    _mark_x1 - _draw_width, _mark_y1 - _draw_width,
-                    2 * _draw_width, 2 * _draw_width, 0, 360 * 64);
-       gdk_draw_line(_map_widget->window,
-                     _conn_state == RCVR_FIXED ? (_show_velvec ? _gc[COLORABLE_MARK_VELOCITY] : _gc[COLORABLE_MARK]) : _gc[COLORABLE_MARK_OLD],
-                     _mark_x1, _mark_y1, _mark_x2, _mark_y2);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+gdk_draw_arc(_map_widget->window, _conn_state == RCVR_FIXED ? _gc[COLORABLE_MARK] : _gc[COLORABLE_MARK_OLD], FALSE,
+     _mark_x1 - _draw_width, _mark_y1 - _draw_width, 
+       2 * _draw_width, 2 * _draw_width, 0, 360 * 64);
+gdk_draw_line(_map_widget->window,
+      _conn_state == RCVR_FIXED ? (_show_velvec ? _gc[COLORABLE_MARK_VELOCITY] : _gc[COLORABLE_MARK]) : _gc[COLORABLE_MARK_OLD],
+      _mark_x1, _mark_y1, _mark_x2, _mark_y2);
 }
 
 /**
  * "Set" the mark, which translates the current GPS position into on-screen
  * units in preparation for drawing the mark with map_draw_mark().
  */
-void map_set_mark()
+static void 
+map_set_mark()
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _mark_x1 = unit2x(_pos.unitx);
-       _mark_y1 = unit2y(_pos.unity);
-       _mark_x2 = _mark_x1 + (_show_velvec ? _vel_offsetx : 0);
-       _mark_y2 = _mark_y1 + (_show_velvec ? _vel_offsety : 0);
-       _mark_minx = MIN(_mark_x1, _mark_x2) - (2 * _draw_width);
-       _mark_miny = MIN(_mark_y1, _mark_y2) - (2 * _draw_width);
-       _mark_width = abs(_mark_x1 - _mark_x2) + (4 * _draw_width);
-       _mark_height = abs(_mark_y1 - _mark_y2) + (4 * _draw_width);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+_mark_x1 = unit2x(_pos.unitx);
+_mark_y1 = unit2y(_pos.unity);
+_mark_x2 = _mark_x1 + (_show_velvec ? _vel_offsetx : 0);
+_mark_y2 = _mark_y1 + (_show_velvec ? _vel_offsety : 0);
+_mark_minx = MIN(_mark_x1, _mark_x2) - (2 * _draw_width);
+_mark_miny = MIN(_mark_y1, _mark_y2) - (2 * _draw_width);
+_mark_width = abs(_mark_x1 - _mark_x2) + (4 * _draw_width);
+_mark_height = abs(_mark_y1 - _mark_y2) + (4 * _draw_width);
 }
 
 /**
@@ -339,291 +209,86 @@ map_pixbuf_scale_inplace(GdkPixbuf * pixbuf, guint ratio_p2, guint src_x, guint
  * Trim pixbufs that are bigger than tiles. (Those pixbufs result, when
  * captions should be cut off.)
  */
-static GdkPixbuf *pixbuf_trim(GdkPixbuf * pixbuf)
-{
-       vprintf("%s()\n", __PRETTY_FUNCTION__);
-       GdkPixbuf *mpixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, gdk_pixbuf_get_has_alpha(pixbuf),
-                          8, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
-
-       gdk_pixbuf_copy_area(pixbuf,
-                            (gdk_pixbuf_get_width(pixbuf) - TILE_SIZE_PIXELS) / 2,
-                            (gdk_pixbuf_get_height(pixbuf) - TILE_SIZE_PIXELS) / 2, 
-                            TILE_SIZE_PIXELS,
-                            TILE_SIZE_PIXELS, mpixbuf, 0, 0);
-
-       g_object_unref(pixbuf);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return mpixbuf;
-}
-
-/**
- * Given a wms uri pattern, compute the coordinate transformation and
- * trimming.
- * 'proj' is used for the conversion
- */
-static gchar *map_convert_wms_to_wms(gint tilex, gint tiley, gint zoomlevel,
-                             gchar * uri)
-{
-       gint system_retcode;
-       gchar cmd[BUFFER_SIZE], srs[BUFFER_SIZE];
-       gchar *ret = NULL;
-       FILE *in;
-       gdouble lon1, lat1, lon2, lat2;
-
-       gchar *widthstr = strcasestr(uri, "WIDTH=");
-       gchar *heightstr = strcasestr(uri, "HEIGHT=");
-       gchar *srsstr = strcasestr(uri, "SRS=EPSG");
-       gchar *srsstre = strchr(srsstr, '&');
-       vprintf("%s()\n", __PRETTY_FUNCTION__);
-
-       /* missing: test if found */
-       strcpy(srs, "epsg");
-       strncpy(srs + 4, srsstr + 8, 256);
-       /* missing: test srsstre-srsstr < 526 */
-       srs[srsstre - srsstr - 4] = 0;
-       /* convert to lower, as WMC is EPSG and cs2cs is epsg */
-
-       gint dwidth = widthstr ? atoi(widthstr + 6) - TILE_SIZE_PIXELS : 0;
-       gint dheight = heightstr ? atoi(heightstr + 7) - TILE_SIZE_PIXELS : 0;
-
-       unit2latlon(tile2zunit(tilex, zoomlevel)
-                   - pixel2zunit(dwidth / 2, zoomlevel),
-                   tile2zunit(tiley + 1, zoomlevel)
-                   + pixel2zunit((dheight + 1) / 2, zoomlevel), lat1, lon1);
-
-       unit2latlon(tile2zunit(tilex + 1, zoomlevel)
-                   + pixel2zunit((dwidth + 1) / 2, zoomlevel),
-                   tile2zunit(tiley, zoomlevel)
-                   - pixel2zunit(dheight / 2, zoomlevel), lat2, lon2);
-
-       setlocale(LC_NUMERIC, "C");
-
-       snprintf(cmd, sizeof(cmd),
-                "(echo \"%.6f %.6f\"; echo \"%.6f %.6f\") | "
-                "/usr/bin/cs2cs +proj=longlat +datum=WGS84 +to +init=%s -f %%.6f "
-                " > /tmp/tmpcs2cs ", lon1, lat1, lon2, lat2, srs);
-       vprintf("Running command: %s\n", cmd);
-       system_retcode = system(cmd);
-
-       if (system_retcode)
-               g_printerr("cs2cs returned error code %d\n",
-                          WEXITSTATUS(system_retcode));
-       else if (!(in = g_fopen("/tmp/tmpcs2cs", "r")))
-               g_printerr("Cannot open results of conversion\n");
-       else if (5 !=
-                fscanf(in, "%lf %lf %s %lf %lf", &lon1, &lat1, cmd, &lon2, &lat2)) {
-               g_printerr("Wrong conversion\n");
-               fclose(in);
-       } else {
-               fclose(in);
-               ret = g_strdup_printf(uri, lon1, lat1, lon2, lat2);
-       }
-
-       setlocale(LC_NUMERIC, "");
-
-       vprintf("%s(): return %s\n", __PRETTY_FUNCTION__, ret);
-       return ret;
-}
-
-/**
- * Given the xyz coordinates of our map coordinate system, write the qrst
- * quadtree coordinates to buffer.
- */
-static void
-map_convert_coords_to_quadtree_string(gint x, gint y, gint zoomlevel,
-                                     gchar * buffer, const gchar initial,
-                                     const gchar * const quadrant)
+static GdkPixbuf *
+pixbuf_trim(GdkPixbuf * pixbuf)
 {
-       gchar *ptr = buffer;
-       gint n;
-       vprintf("%s()\n", __PRETTY_FUNCTION__);
+GdkPixbuf *mpixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, gdk_pixbuf_get_has_alpha(pixbuf),
+                  8, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
 
-       if (initial)
-               *ptr++ = initial;
+gdk_pixbuf_copy_area(pixbuf,
+                    (gdk_pixbuf_get_width(pixbuf) - TILE_SIZE_PIXELS) / 2,
+                    (gdk_pixbuf_get_height(pixbuf) - TILE_SIZE_PIXELS) / 2, 
+                    TILE_SIZE_PIXELS,
+                    TILE_SIZE_PIXELS, mpixbuf, 0, 0);
 
-       for (n = 16 - zoomlevel; n >= 0; n--) {
-               gint xbit = (x >> n) & 1;
-               gint ybit = (y >> n) & 1;
-               *ptr++ = quadrant[xbit + 2 * ybit];
-       }
-       *ptr++ = '\0';
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-/**
- * Construct the URL that we should fetch, based on the current URI format.
- * This method works differently depending on if a "%s" string is present in
- * the URI format, since that would indicate a quadtree-based map coordinate
- * system.
- */
-static gchar *map_construct_url(guint tilex, guint tiley, guint zoom)
-{
-       vprintf("%s()\n", __PRETTY_FUNCTION__);
-       switch (_curr_repo->type) {
-       case REPOTYPE_XYZ:
-               return g_strdup_printf(_curr_repo->url, tilex, tiley, zoom);
-
-       case REPOTYPE_XYZ_INV:
-               return g_strdup_printf(_curr_repo->url, 17 - zoom, tilex,
-                                      tiley);
-
-       case REPOTYPE_QUAD_QRST:
-               {
-                       gchar location[MAX_ZOOM + 2];
-                       map_convert_coords_to_quadtree_string(tilex, tiley,
-                                                             zoom, location,
-                                                             't', "qrts");
-                       return g_strdup_printf(_curr_repo->url, location);
-               }
-
-       case REPOTYPE_QUAD_ZERO:
-               {
-                       /* This is a zero-based quadtree URI. */
-                       gchar location[MAX_ZOOM + 2];
-                       map_convert_coords_to_quadtree_string(tilex, tiley,
-                                                             zoom, location,
-                                                             '\0', "0123");
-                       return g_strdup_printf(_curr_repo->url, location);
-               }
-
-       case REPOTYPE_WMS:
-               return map_convert_wms_to_wms(tilex, tiley, zoom,
-                                             _curr_repo->url);
-
-       default:
-               return NULL;
-       }
-       vprintf("%s(): ERROR\n", __PRETTY_FUNCTION__);
-       return "";
-}
-
-#ifdef WITH_OSSO
-void con_check_connection(void)
-{
-iap_connect();
-}
-#else
-void con_check_connection(void) 
-{
-/* NetworkManager support ? */
-}
-#endif
-
-/**
- * Initiate a download of the given xyz coordinates using the given buffer
- * as the URL.  If the map already exists on disk, or if we are already
- * downloading the map, then this method does nothing.
- */
-void map_initiate_download(guint tilex, guint tiley, guint zoom, gint retries)
-{
-       ProgressUpdateInfo *pui;
-       vprintf("%s(%u, %u, %u, %d)\n", __PRETTY_FUNCTION__, tilex, tiley, zoom,
-               retries);
-
-       con_check_connection();
-
-       pui = g_slice_new(ProgressUpdateInfo);
-       pui->tilex = tilex;
-       pui->tiley = tiley;
-       pui->zoom = zoom;
-       pui->priority = (abs((gint) tilex - unit2tile(_center.unitx))
-                        + abs((gint) tiley - unit2tile(_center.unity)));
-       if (!retries)
-               pui->priority = -pui->priority; /* "Negative" makes them lowest pri. */
-       pui->retries = retries;
-       pui->repo = _curr_repo;
-
-       if (g_tree_lookup(_pui_tree, pui)
-           || g_tree_lookup(_downloading_tree, pui)) {
-               /* Already downloading. */
-               g_slice_free(ProgressUpdateInfo, pui);
-               return;
-       }
-       pui->src_str = NULL;
-       pui->dest_str = NULL;
-       pui->file = NULL;
-
-       g_tree_insert(_pui_tree, pui, pui);
-#ifdef WITH_OSSO
-       if (iap_is_connected() && !_curl_sid)
-#endif
-               _curl_sid = g_timeout_add(100, (GSourceFunc) curl_download_timeout, NULL);
-
-       if (!_num_downloads++ && !_download_banner)
-               _download_banner = hildon_banner_show_progress(_window, NULL,_("Downloading maps"));
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+g_object_unref(pixbuf);
+return mpixbuf;
 }
 
 void
-map_render_tile(guint tilex, guint tiley, guint destx, guint desty,
-               gboolean fast_fail)
+map_render_tile(guint tilex, guint tiley, guint destx, guint desty, gboolean fast_fail)
 {
-       GdkPixbuf *pixbuf = NULL;
-       gchar buffer[BUFFER_SIZE];
-       GError *error = NULL;
-       gint zoff;
-
-       vprintf("%s(%u, %u, %u, %u)\n", __PRETTY_FUNCTION__,
-               tilex, tiley, destx, desty);
-
-       if (tilex < _world_size_tiles && tiley < _world_size_tiles) {
-               /* The tile is possible. */
-               for (zoff = (_curr_repo->double_size ? 1 : 0);
-                    !pixbuf && (_zoom + zoff) <= MAX_ZOOM
-                    && zoff <= TILE_SIZE_P2; zoff += 1) {
-                       snprintf(buffer, sizeof(buffer), "%s/%u/%u/%u.jpg",
-                                _curr_repo->cache_dir, _zoom + zoff,
-                                (tilex >> zoff), (tiley >> zoff));
-
-                       pixbuf = gdk_pixbuf_new_from_file(buffer, &error);
-                       if (error || !pixbuf) {
-                               /* Delete so we try again some other day. */
-                               g_unlink(buffer);       
-                               pixbuf = NULL;
-                               error = NULL;
-
-                               /* Download, if we should. */
-                               if (_auto_download && _curr_repo->type != REPOTYPE_NONE &&
-                                   !((_zoom + zoff - (_curr_repo->double_size ? 1 : 0)) % _curr_repo->dl_zoom_steps)) {
-                                       if (!fast_fail)
-                                               map_initiate_download(tilex >> zoff,
-                                                                     tiley >> zoff,
-                                                                     _zoom + zoff,
-                                                                     -INITIAL_DOWNLOAD_RETRIES);
-                                       fast_fail = TRUE;
-                               }
-                       } else {
-                               /* Check if we need to trim. */
-                               if (gdk_pixbuf_get_width(pixbuf) != TILE_SIZE_PIXELS || gdk_pixbuf_get_height(pixbuf) != TILE_SIZE_PIXELS)
-                                       pixbuf = pixbuf_trim(pixbuf);
-
-                               /* Check if we need to blit. */
-                               if (zoff) {
-                                       map_pixbuf_scale_inplace(pixbuf, zoff,
-                                                        (tilex - ((tilex >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff),
-                                                        (tiley - ((tiley >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff));
-                               }
+GdkPixbuf *pixbuf = NULL;
+gchar buffer[BUFFER_SIZE];
+GError *error = NULL;
+gint zoff;
+
+if (tilex < _world_size_tiles && tiley < _world_size_tiles) {
+       /* The tile is possible. */
+       for (zoff = (_curr_repo->double_size ? 1 : 0);
+            !pixbuf && (_zoom + zoff) <= MAX_ZOOM
+            && zoff <= TILE_SIZE_P2; zoff += 1) {
+               snprintf(buffer, sizeof(buffer), "%s/%u/%u/%u.jpg",
+                        _curr_repo->cache_dir, _zoom + zoff,
+                        (tilex >> zoff), (tiley >> zoff));
+
+               pixbuf = gdk_pixbuf_new_from_file(buffer, &error);
+               if (error || !pixbuf) {
+                       /* Delete so we try again some other day. */
+                       g_unlink(buffer);       
+                       pixbuf = NULL;
+                       error = NULL;
+
+                       /* Download, if we should. */
+                       if (_auto_download && _curr_repo->type != REPOTYPE_NONE &&
+                           !((_zoom + zoff - (_curr_repo->double_size ? 1 : 0)) % _curr_repo->dl_zoom_steps)) {
+                               if (!fast_fail)
+                                       map_initiate_download(tilex >> zoff,
+                                                             tiley >> zoff,
+                                                             _zoom + zoff,
+                                                             -INITIAL_DOWNLOAD_RETRIES);
+                               fast_fail = TRUE;
+                       }
+               } else {
+                       /* Check if we need to trim. */
+                       if (gdk_pixbuf_get_width(pixbuf) != TILE_SIZE_PIXELS || gdk_pixbuf_get_height(pixbuf) != TILE_SIZE_PIXELS)
+                               pixbuf = pixbuf_trim(pixbuf);
+
+                       /* Check if we need to blit. */
+                       if (zoff) {
+                               map_pixbuf_scale_inplace(pixbuf, zoff,
+                                                (tilex - ((tilex >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff),
+                                                (tiley - ((tiley >> zoff) << zoff)) << (TILE_SIZE_P2 - zoff));
                        }
                }
        }
+}
 
-       if (pixbuf) {
-               gdk_draw_pixbuf(_map_pixmap,
-                               _gc[COLORABLE_MARK],
-                               pixbuf, 0, 0, destx, desty,
-                               TILE_SIZE_PIXELS, TILE_SIZE_PIXELS,
-                               GDK_RGB_DITHER_NONE, 0, 0);
-               g_object_unref(pixbuf);
-       } else {
-               gdk_draw_rectangle(_map_pixmap, _map_widget->style->black_gc,
-                                  TRUE, destx, desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
-       }
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+if (pixbuf) {
+       gdk_draw_pixbuf(_map_pixmap,
+                       _gc[COLORABLE_MARK],
+                       pixbuf, 0, 0, destx, desty,
+                       TILE_SIZE_PIXELS, TILE_SIZE_PIXELS,
+                       GDK_RGB_DITHER_NONE, 0, 0);
+       g_object_unref(pixbuf);
+} else {
+       gdk_draw_rectangle(_map_pixmap, _map_widget->style->black_gc,
+                          TRUE, destx, desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
+}
 }
 
-gboolean map_render_tile_idle(map_tile_rdata *mtr)
+gboolean 
+map_render_tile_idle(map_tile_rdata *mtr)
 {
 map_render_tile(mtr->tilex, mtr->tiley, mtr->destx, mtr->desty, FALSE);
 gtk_widget_queue_draw_area(_map_widget, mtr->destx, mtr->desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
@@ -632,91 +297,21 @@ g_slice_free(map_tile_rdata, mtr);
 return FALSE;
 }
 
-gboolean map_download_idle_refresh(ProgressUpdateInfo * pui)
+void
+map_render_data(void)
 {
-       vprintf("%s(%p, %s)\n", __PRETTY_FUNCTION__, pui, pui->src_str);
-
-       /* Test if download succeeded (only if retries != 0). */
-       if (!pui->retries || g_file_test(pui->dest_str, G_FILE_TEST_EXISTS)) {
-               gint zoom_diff = pui->zoom - _zoom;
-               /* Only refresh at same or "lower" (more detailed) zoom level. */
-               if (zoom_diff >= 0) {
-                       /* If zoom has changed since we first put in the request for
-                        * this tile, then we may have to update more than one tile. */
-                       guint tilex, tiley, tilex_end, tiley_end;
-                       for (tilex = pui->tilex << zoom_diff,
-                            tilex_end = tilex + (1 << zoom_diff);
-                            tilex < tilex_end; tilex++) {
-                               for (tiley = pui->tiley << zoom_diff,
-                                    tiley_end = tiley + (1 << zoom_diff);
-                                    tiley < tiley_end; tiley++) {
-                                       if ((tilex - _base_tilex) < BUF_WIDTH_TILES && (tiley - _base_tiley) < BUF_HEIGHT_TILES) {
-                                               map_render_tile(tilex, tiley,
-                                                               ((tilex - _base_tilex) << TILE_SIZE_P2),
-                                                               ((tiley - _base_tiley) << TILE_SIZE_P2),
-                                                               TRUE);
-                                               MACRO_MAP_RENDER_DATA();
-                                               gtk_widget_queue_draw_area
-                                                   (_map_widget,
-                                                    ((tilex - _base_tilex) << TILE_SIZE_P2) - _offsetx,
-                                                    ((tiley - _base_tiley) << TILE_SIZE_P2) - _offsety,
-                                                    TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
-                                       }
-                               }
-                       }
-               }
-       }
-       /* Else the download failed. Update retries and maybe try again. */
-       else {
-               if (pui->retries > 0)
-                       --pui->retries;
-               else if (pui->retries < 0)
-                       ++pui->retries;
-               if (pui->retries) {
-                       /* removal automatically calls progress_update_info_free(). */
-                       g_tree_steal(_downloading_tree, pui);
-                       g_tree_insert(_pui_tree, pui, pui);
-#ifdef WITH_OSSO
-                       if (iap_is_connected() && !_curl_sid)
-#endif
-                               _curl_sid = g_timeout_add(100,
-                                                         (GSourceFunc)
-                                                         curl_download_timeout,
-                                                         NULL);
-                       /* Don't do anything else. */
-                       return FALSE;
-               } else {
-                       /* No more retries left - something must be wrong. */
-                       MACRO_BANNER_SHOW_INFO(_window,
-                                              _("Error in download.  Check internet connection"
-                                               " and/or Map Repository URL Format."));
-               }
-       }
-
-       /* removal automatically calls progress_update_info_free(). */
-       g_tree_remove(_downloading_tree, pui);
-
-       if (++_curr_download == _num_downloads) {
-#ifdef WITH_HILDON
-               gtk_widget_destroy(_download_banner);
-               _download_banner = NULL;
-#else
-               gtk_widget_hide(GTK_WIDGET(_progress_item));
-#endif
-               _num_downloads = _curr_download = 0;
-       } else
-               hildon_banner_set_fraction(HILDON_BANNER(_download_banner),
-                                          _curr_download / (double)_num_downloads);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return FALSE;
+if(_show_poi)
+       map_render_poi();
+if(_show_tracks > 0)
+       map_render_paths();
 }
 
 /**
  * Force a redraw of the entire _map_pixmap, including fetching the
  * background maps from disk and redrawing the tracks on top of them.
  */
-void map_force_redraw()
+void 
+map_force_redraw()
 {
        guint new_x, new_y;
        printf("%s()\n", __PRETTY_FUNCTION__);
@@ -728,7 +323,7 @@ void map_force_redraw()
                                        new_x * TILE_SIZE_PIXELS,
                                        new_y * TILE_SIZE_PIXELS, FALSE);
                }
-       MACRO_MAP_RENDER_DATA();
+       map_render_data();
        MACRO_QUEUE_DRAW_AREA();
 
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
@@ -739,7 +334,8 @@ void map_force_redraw()
  * current zoom level, or if the new zoom is invalid
  * (not MIN_ZOOM <= new_zoom < MAX_ZOOM), then this method does nothing.
  */
-void map_set_zoom(guint new_zoom)
+void 
+map_set_zoom(guint new_zoom)
 {
        printf("%s(%d)\n", __PRETTY_FUNCTION__, _zoom);
 
@@ -787,127 +383,105 @@ void map_set_zoom(guint new_zoom)
 /**
  * Center the view on the given unitx/unity.
  */
-void map_center_unit(guint new_center_unitx, guint new_center_unity)
+void 
+map_center_unit(guint new_center_unitx, guint new_center_unity)
 {
-       gint new_base_tilex, new_base_tiley;
-       guint new_x, new_y;
-       guint j, k, base_new_x, base_old_x, old_x, old_y, iox, ioy;
-       printf("%s(%d, %d)\n", __PRETTY_FUNCTION__,
-              new_center_unitx, new_center_unity);
-
-       /* Assure that _center.unitx/y are bounded. */
-       BOUND(new_center_unitx, _min_center.unitx, _max_center.unitx);
-       BOUND(new_center_unity, _min_center.unity, _max_center.unity);
-
-       _center.unitx = new_center_unitx;
-       _center.unity = new_center_unity;
-
-       new_base_tilex = grid2tile((gint) pixel2grid((gint)unit2pixel((gint) _center.unitx))
-                                  - (gint)_screen_grids_halfwidth);
-       new_base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity))
-                                  - _screen_grids_halfheight);
-
-       /* Same zoom level, so it's likely that we can reuse some of the old
-        * buffer's pixels. */
-
-       if (new_base_tilex != _base_tilex || new_base_tiley != _base_tiley) {
-               /* If copying from old parts to new parts, we need to make sure we
-                * don't overwrite the old parts when copying, so set up new_x,
-                * new_y, old_x, old_y, iox, and ioy with that in mind. */
-               if (new_base_tiley < _base_tiley) {
-                       /* New is lower than old - start at bottom and go up. */
-                       new_y = BUF_HEIGHT_TILES - 1;
-                       ioy = -1;
-               } else {
-                       /* New is higher than old - start at top and go down. */
-                       new_y = 0;
-                       ioy = 1;
-               }
-               if (new_base_tilex < _base_tilex) {
-                       /* New is righter than old - start at right and go left. */
-                       base_new_x = BUF_WIDTH_TILES - 1;
-                       iox = -1;
-               } else {
-                       /* New is lefter than old - start at left and go right. */
-                       base_new_x = 0;
-                       iox = 1;
-               }
-
-               /* Iterate over the y tile values. */
-               old_y = new_y + new_base_tiley - _base_tiley;
-               base_old_x = base_new_x + new_base_tilex - _base_tilex;
-               _base_tilex = new_base_tilex;
-               _base_tiley = new_base_tiley;
-               for (j = 0; j < BUF_HEIGHT_TILES;
-                    ++j, new_y += ioy, old_y += ioy) {
-                       new_x = base_new_x;
-                       old_x = base_old_x;
-                       /* Iterate over the x tile values. */
-                       for (k = 0; k < BUF_WIDTH_TILES;
-                            ++k, new_x += iox, old_x += iox) {
-                               /* Can we get this grid block from the old buffer?. */
-                               if (old_x >= 0 && old_x < BUF_WIDTH_TILES
-                                   && old_y >= 0 && old_y < BUF_HEIGHT_TILES) {
-                                       /* Copy from old buffer to new buffer. */
-                                       gdk_draw_drawable(_map_pixmap,
-                                                         _gc[COLORABLE_MARK],
-                                                         _map_pixmap,
-                                                         old_x * TILE_SIZE_PIXELS,
-                                                         old_y * TILE_SIZE_PIXELS,
-                                                         new_x * TILE_SIZE_PIXELS,
-                                                         new_y * TILE_SIZE_PIXELS,
-                                                         TILE_SIZE_PIXELS,
-                                                         TILE_SIZE_PIXELS);
-                               } else {
-#if 0
-                                       map_tile_rdata *mtr;
-
-                                       mtr=g_slice_new(map_tile_rdata);
-                                       mtr->tilex=new_base_tilex + new_x;
-                                       mtr->tiley=new_base_tiley + new_y;
-                                       mtr->destx=new_x * TILE_SIZE_PIXELS;
-                                       mtr->desty=new_y * TILE_SIZE_PIXELS;
-
-                               gdk_draw_rectangle(_map_pixmap, _gc[COLORABLE_MARK_VELOCITY],
-                      TRUE, mtr->destx, mtr->desty, TILE_SIZE_PIXELS, TILE_SIZE_PIXELS);
+gint new_base_tilex, new_base_tiley;
+guint new_x, new_y;
+guint j, k, base_new_x, base_old_x, old_x, old_y, iox, ioy;
+g_printf("%s(%d, %d)\n", __PRETTY_FUNCTION__, new_center_unitx, new_center_unity);
+
+/* Assure that _center.unitx/y are bounded. */
+BOUND(new_center_unitx, _min_center.unitx, _max_center.unitx);
+BOUND(new_center_unity, _min_center.unity, _max_center.unity);
+
+_center.unitx = new_center_unitx;
+_center.unity = new_center_unity;
+
+new_base_tilex = grid2tile((gint) pixel2grid((gint)unit2pixel((gint) _center.unitx))
+                          - (gint)_screen_grids_halfwidth);
+new_base_tiley = grid2tile(pixel2grid(unit2pixel(_center.unity))
+                          - _screen_grids_halfheight);
+
+/* Same zoom level, so it's likely that we can reuse some of the old
+ * buffer's pixels. */
+
+if (new_base_tilex != _base_tilex || new_base_tiley != _base_tiley) {
+       /* If copying from old parts to new parts, we need to make sure we
+        * don't overwrite the old parts when copying, so set up new_x,
+        * new_y, old_x, old_y, iox, and ioy with that in mind. */
+       if (new_base_tiley < _base_tiley) {
+               /* New is lower than old - start at bottom and go up. */
+               new_y = BUF_HEIGHT_TILES - 1;
+               ioy = -1;
+       } else {
+               /* New is higher than old - start at top and go down. */
+               new_y = 0;
+               ioy = 1;
+       }
+       if (new_base_tilex < _base_tilex) {
+               /* New is righter than old - start at right and go left. */
+               base_new_x = BUF_WIDTH_TILES - 1;
+               iox = -1;
+       } else {
+               /* New is lefter than old - start at left and go right. */
+               base_new_x = 0;
+               iox = 1;
+       }
 
-                                       g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_render_tile_idle, mtr,NULL);
-#else
-                                       map_render_tile(new_base_tilex + new_x,
-                                                       new_base_tiley + new_y,
-                                                       new_x * TILE_SIZE_PIXELS,
-                                                       new_y * TILE_SIZE_PIXELS,
-                                                       FALSE);
-#endif
-                               }
+       /* Iterate over the y tile values. */
+       old_y = new_y + new_base_tiley - _base_tiley;
+       base_old_x = base_new_x + new_base_tilex - _base_tilex;
+       _base_tilex = new_base_tilex;
+       _base_tiley = new_base_tiley;
+       for (j = 0; j < BUF_HEIGHT_TILES; ++j, new_y += ioy, old_y += ioy) {
+               new_x = base_new_x;
+               old_x = base_old_x;
+               /* Iterate over the x tile values. */
+               for (k = 0; k < BUF_WIDTH_TILES;
+                    ++k, new_x += iox, old_x += iox) {
+                       /* Can we get this grid block from the old buffer?. */
+                       if (old_x >= 0 && old_x < BUF_WIDTH_TILES
+                           && old_y >= 0 && old_y < BUF_HEIGHT_TILES) {
+                               /* Copy from old buffer to new buffer. */
+                               gdk_draw_drawable(_map_pixmap,
+                                                 _gc[COLORABLE_MARK],
+                                                 _map_pixmap,
+                                                 old_x * TILE_SIZE_PIXELS,
+                                                 old_y * TILE_SIZE_PIXELS,
+                                                 new_x * TILE_SIZE_PIXELS,
+                                                 new_y * TILE_SIZE_PIXELS,
+                                                 TILE_SIZE_PIXELS,
+                                                 TILE_SIZE_PIXELS);
+                       } else {
+                               map_render_tile(new_base_tilex + new_x,
+                                               new_base_tiley + new_y,
+                                               new_x * TILE_SIZE_PIXELS,
+                                               new_y * TILE_SIZE_PIXELS,
+                                               FALSE);
                        }
                }
-               MACRO_MAP_RENDER_DATA();
        }
+       map_render_data();
+}
 
-       MACRO_RECALC_OFFSET();
-       MACRO_RECALC_FOCUS_BASE();
-
-       map_set_mark();
-       MACRO_QUEUE_DRAW_AREA();
+MACRO_RECALC_OFFSET();
+MACRO_RECALC_FOCUS_BASE();
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+map_set_mark();
+MACRO_QUEUE_DRAW_AREA();
 }
 
 /**
  * Pan the view by the given number of units in the X and Y directions.
  */
-void map_pan(gint delta_unitx, gint delta_unity)
+void 
+map_pan(gint delta_unitx, gint delta_unity)
 {
-       printf("%s(%d, %d)\n", __PRETTY_FUNCTION__, delta_unitx, delta_unity);
+if (_center_mode > 0)
+       set_action_activate("autocenter_none", TRUE);
 
-       if (_center_mode > 0)
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_ac_none_item), TRUE);
-       map_center_unit(_center.unitx + delta_unitx,
-                       _center.unity + delta_unity);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+map_center_unit(_center.unitx + delta_unitx, _center.unity + delta_unity);
 }
 
 /**
@@ -916,22 +490,19 @@ void map_pan(gint delta_unitx, gint delta_unity)
  * drawing of the background map), then updates the mark, then queus the
  * draw area of the new mark.
  */
-void map_move_mark()
+void 
+map_move_mark()
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       /* Just queue the old and new draw areas. */
-       gtk_widget_queue_draw_area(_map_widget,
-                                  _mark_minx<0 ? 0 : _mark_minx,
-                                  _mark_miny<0 ? 0 : _mark_miny, 
-                                  _mark_width, _mark_height);
-       map_set_mark();
-       gtk_widget_queue_draw_area(_map_widget,
-                                  _mark_minx<0 ? 0 : _mark_minx,
-                                  _mark_miny<0 ? 0 : _mark_miny, 
-                                  _mark_width, _mark_height);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+/* Just queue the old and new draw areas. */
+gtk_widget_queue_draw_area(_map_widget,
+                  _mark_minx<0 ? 0 : _mark_minx,
+                  _mark_miny<0 ? 0 : _mark_miny, 
+                  _mark_width, _mark_height);
+map_set_mark();
+gtk_widget_queue_draw_area(_map_widget,
+                  _mark_minx<0 ? 0 : _mark_minx,
+                  _mark_miny<0 ? 0 : _mark_miny, 
+                  _mark_width, _mark_height);
 }
 
 gboolean
@@ -951,33 +522,59 @@ return FALSE;
 }
 
 /**
- * Make sure the mark is up-to-date.  This function triggers a panning of
- * the view if the mark is appropriately close to the edge of the view.
+ * Draw given pixbuf on map, centered on x,y
  */
-void refresh_mark()
+void
+map_draw_pixbuf(guint unitx, guint unity, GdkPixmap *p)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+gint x,y;
+x = unit2bufx(unitx);
+y = unit2bufy(unity);
+
+gdk_draw_pixbuf(_map_pixmap, _gc[COLORABLE_POI],
+       p, 0, 0,
+       x - gdk_pixbuf_get_width(p) / 2,
+       y - gdk_pixbuf_get_height(p) / 2,
+       -1, -1, GDK_RGB_DITHER_NONE, 0, 0);
+}
+
+void
+map_draw_position_icon(Position *pos)
+{
+guint x,y;
+GdkPixbuf *p;
 
-       guint new_center_unitx;
-       guint new_center_unity;
+latlon2unit(pos->lat, pos->lon, x, y);
+p=gdk_pixbuf_new_from_file(DATADIR "/pixmaps/mapper/home.png", NULL);
+map_draw_pixbuf(x,y,p);
+g_object_unref(p);
+}
 
-       MACRO_RECALC_CENTER(new_center_unitx, new_center_unity);
+/**
+ * Make sure the mark is up-to-date.  This function triggers a panning of
+ * the view if the mark is appropriately close to the edge of the view.
+ */
+void
+map_refresh_mark()
+{
+guint new_center_unitx;
+guint new_center_unity;
 
-       if ((new_center_unitx - _focus.unitx) < _focus_unitwidth
-           && (new_center_unity - _focus.unity) < _focus_unitheight)
-               /* We're not changing the view - just move the mark. */
-               map_move_mark();
-       else
-               map_center_unit(new_center_unitx, new_center_unity);
+MACRO_RECALC_CENTER(new_center_unitx, new_center_unity);
 
-       /* Draw speed info */
-       if (_speed_limit_on)
-               speed_limit();
+if ((new_center_unitx - _focus.unitx) < _focus_unitwidth
+    && (new_center_unity - _focus.unity) < _focus_unitheight)
+       /* We're not changing the view - just move the mark. */
+       map_move_mark();
+else
+       map_center_unit(new_center_unitx, new_center_unity);
 
-       if (_center_mode>0)
-               g_idle_add((GSourceFunc)map_update_location_from_gps, NULL);
+/* Draw speed info */
+if (_speed_limit_on)
+       speed_limit();
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+if (_center_mode>0)
+       g_idle_add((GSourceFunc)map_update_location_from_gps, NULL);
 }
 
 /**
@@ -1035,7 +632,8 @@ map_render_segment(GdkGC * gc_norm, GdkGC * gc_alt,
  * is up to the caller to decide which part of the track really needs to be
  * redrawn.
  */
-void map_render_path(Path * path, GdkGC ** gc)
+void 
+map_render_path(Path * path, GdkGC ** gc)
 {
        Point *curr;
        WayPoint *wcurr;
@@ -1069,7 +667,8 @@ void map_render_path(Path * path, GdkGC ** gc)
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-void map_render_paths()
+void 
+map_render_paths()
 {
        printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -1095,7 +694,8 @@ void map_render_paths()
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-static gboolean map_follow_move(GtkWidget * widget, GdkEventMotion * event)
+static 
+gboolean map_follow_move(GtkWidget * widget, GdkEventMotion * event)
 {
        gint xx, yy;
        GdkModifierType state;
@@ -1124,41 +724,38 @@ static gboolean map_follow_move(GtkWidget * widget, GdkEventMotion * event)
        return FALSE;
 }
 
-gboolean map_key_zoom_timeout()
+gboolean 
+map_key_zoom_timeout()
 {
        printf("%s()\n", __PRETTY_FUNCTION__);
        if (_key_zoom_new < _zoom) {
                /* We're currently zooming in (_zoom is decreasing). */
                guint test = _key_zoom_new - _curr_repo->view_zoom_steps;
                if (test < MAX_ZOOM)
-                       /* We can zoom some more.  Hurray! */
                        _key_zoom_new = test;
                else
-                       /* We can't zoom anymore.  Booooo! */
                        return FALSE;
        } else {
                /* We're currently zooming out (_zoom is increasing). */
                guint test = _key_zoom_new + _curr_repo->view_zoom_steps;
                if (test < MAX_ZOOM)
-                       /* We can zoom some more.  Hurray! */
                        _key_zoom_new = test;
                else
-                       /* We can't zoom anymore.  Booooo! */
                        return FALSE;
        }
 
        /* We can zoom more - tell them how much they're zooming. */
        {
                gchar buffer[32];
-               snprintf(buffer, sizeof(buffer),
-                        "%s %d", _("Zoom to Level"), _key_zoom_new);
+               snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), _key_zoom_new);
                MACRO_BANNER_SHOW_INFO(_window, buffer);
        }
        vprintf("%s(): return\n", __PRETTY_FUNCTION__);
        return TRUE;
 }
 
-void map_scale_draw(GdkEventExpose *event)
+void 
+map_scale_draw(GdkEventExpose *event)
 {
        gdk_rectangle_intersect(&event->area, &_scale_rect, &event->area);
 
@@ -1266,43 +863,46 @@ void map_scale_draw(GdkEventExpose *event)
        }
 }
 
-gboolean map_cb_expose(GtkWidget * widget, GdkEventExpose * event)
+gboolean 
+map_cb_expose(GtkWidget * widget, GdkEventExpose * event)
 {
-       printf("%s(%d, %d, %d, %d)\n", __PRETTY_FUNCTION__,
-              event->area.x, event->area.y,
-              event->area.width, event->area.height);
-
-       gdk_draw_drawable(GDK_DRAWABLE(_map_widget->window),
-                         _gc[COLORABLE_MARK],
-                         _map_pixmap,
-                         event->area.x + _offsetx, event->area.y + _offsety,
-                         event->area.x, event->area.y,
-                         event->area.width, event->area.height);
-       map_draw_mark();
-
-       /* Draw scale, if necessary. */
-       if (_show_scale)
-               map_scale_draw(event);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+g_printf("%s(%d, %d, %d, %d)\n", __PRETTY_FUNCTION__,
+       event->area.x, event->area.y,
+       event->area.width, event->area.height);
+
+gdk_draw_drawable(GDK_DRAWABLE(_map_widget->window),
+                 _gc[COLORABLE_MARK],
+                 _map_pixmap,
+                 event->area.x + _offsetx, event->area.y + _offsety,
+                 event->area.x, event->area.y,
+                 event->area.width, event->area.height);
+map_draw_mark();
+
+/* Draw scale, if necessary. */
+if (_show_scale)
+       map_scale_draw(event);
+
+if (_home.valid)
+       map_draw_position_icon(&_home);
+
+return TRUE;
 }
 
-int map_zoom(gint zdir)
+int 
+map_zoom(gint zdir)
 {
-       gchar buffer[80];
-       gint nzoom;
+gchar buffer[80];
+gint nzoom;
 
-       nzoom = _zoom + zdir;
+nzoom = _zoom + zdir;
 
-       if ((nzoom > 0) && (nzoom < MAX_ZOOM - 1)) {
-               snprintf(buffer, sizeof(buffer), "%s %d",
-                        _("Zoom to Level"), nzoom);
-               MACRO_BANNER_SHOW_INFO(_window, buffer);
-               map_set_zoom(nzoom);
-       }
+if ((nzoom > 0) && (nzoom < MAX_ZOOM - 1)) {
+       snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), nzoom);
+       MACRO_BANNER_SHOW_INFO(_window, buffer);
+       map_set_zoom(nzoom);
+}
 
-       return nzoom;
+return nzoom;
 }
 
 static gboolean
@@ -1312,7 +912,7 @@ static gfloat z=5.0;
 static gint last=5;
 gint iz;
 
-if (_zoom_timeout_sid==0)
+if (zoom_timeout_sid==0)
        return FALSE;
 
 z=(z+_gps.speed+1)/5;
@@ -1336,12 +936,12 @@ map_set_autozoom(gboolean az)
 {
 if (az==TRUE) {
        MACRO_BANNER_SHOW_INFO(_window, "Autozoom enabled");
-       _zoom_timeout_sid=g_timeout_add(_gps.speed<5 ? 2000 : 5000, (GSourceFunc) map_autozoomer, NULL);
+       zoom_timeout_sid=g_timeout_add(_gps.speed<5 ? 2000 : 5000, (GSourceFunc) map_autozoomer, NULL);
        return;
 } else {
-       if (_zoom_timeout_sid) {
-               g_source_remove(_zoom_timeout_sid);
-               _zoom_timeout_sid=0;
+       if (zoom_timeout_sid) {
+               g_source_remove(zoom_timeout_sid);
+               zoom_timeout_sid=0;
                MACRO_BANNER_SHOW_INFO(_window, "Autozoom disabled");
        }
        return;
@@ -1364,7 +964,7 @@ unit2latlon(_pos.unitx, _pos.unity, _gps.lat, _gps.lon);
 _gps.speed = 20.f;
 integerize_data();
 track_add(time(NULL), FALSE);
-refresh_mark();
+map_refresh_mark();
 }
 
 static void
@@ -1439,23 +1039,21 @@ map_update_destination(lat, lon);
 inp=FALSE;
 }
 
-gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event)
+gboolean 
+map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event)
 {
-
-       if (event->direction == GDK_SCROLL_UP) {
-               map_center_unit(x2unit((gint) (event->x + 0.5)),
-                               y2unit((gint) (event->y + 0.5)));
-               map_set_zoom(_zoom - 1);
-       } else if (event->direction == GDK_SCROLL_DOWN) {
-               map_center_unit(x2unit((gint) (event->x + 0.5)),
-                               y2unit((gint) (event->y + 0.5)));
-               map_set_zoom(_zoom + 1);
-       }
-
-       return FALSE;
+if (event->direction == GDK_SCROLL_UP) {
+       map_center_unit(x2unit((gint) (event->x + 0.5)), y2unit((gint) (event->y + 0.5)));
+       map_set_zoom(_zoom - 1);
+} else if (event->direction == GDK_SCROLL_DOWN) {
+       map_center_unit(x2unit((gint) (event->x + 0.5)), y2unit((gint) (event->y + 0.5)));
+       map_set_zoom(_zoom + 1);
+}
+return FALSE;
 }
 
-gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event)
+gboolean 
+map_cb_button_press(GtkWidget * widget, GdkEventButton * event)
 {
        printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -1494,16 +1092,15 @@ gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event)
        return FALSE;
 }
 
-gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event)
+gboolean 
+map_cb_button_release(GtkWidget * widget, GdkEventButton * event)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       switch (event->button) {
+switch (event->button) {
        case 1:
                if (_center_mode > 0)
-                       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_none_item), TRUE);
+                       set_action_activate("autocenter_none", TRUE);
 
-               switch (_map_mode) {
+               switch (map_mode) {
                case MAP_MODE_DRAW_TRACK:
                        map_draw_track(event->x, event->y);
                break;
@@ -1543,9 +1140,8 @@ gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event)
                break;
        case 3:
                break;
-       }
+}
 
-       /* Return FALSE to avoid context menu (if it hasn't popped up already). */
-       vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
-       return FALSE;
+/* Return FALSE to avoid context menu (if it hasn't popped up already). */
+return FALSE;
 }
index de3cc4f01a43436255fce0152ea450ebb96e7a84..74afd1e2d897ab5da66d91dbbf947c4c2d2c3127 100644 (file)
--- a/src/map.h
+++ b/src/map.h
@@ -22,9 +22,9 @@
 #include "mapper-types.h"
 
 typedef enum {
-        MAP_MODE_NORMAL=0,
+       MAP_MODE_NORMAL=0,
        MAP_MODE_DRAW_TRACK,
-        MAP_MODE_DRAW_ROUTE,
+       MAP_MODE_DRAW_ROUTE,
        MAP_MODE_SET_ROUTE_FROM,
        MAP_MODE_SET_ROUTE_POINT,
        MAP_MODE_SET_ROUTE_TO,
@@ -62,25 +62,6 @@ guint _focus_unitwidth;
 guint _focus_unitheight;
 guint _world_size_tiles;
 
-/** VARIABLES FOR ACCESSING THE LOCATION/BOUNDS OF THE CURRENT MARK. */
-gint _mark_x1;
-gint _mark_x2;
-gint _mark_y1;
-gint _mark_y2;
-gint _mark_minx;
-gint _mark_miny;
-gint _mark_width;
-gint _mark_height;
-
-/** DOWNLOAD PROGRESS. */
-CURLM *_curl_multi;
-GQueue *_curl_easy_queue;
-guint _num_downloads;
-guint _curr_download;
-GTree *_pui_tree;
-GTree *_downloading_tree;
-GHashTable *_pui_by_easy;
-
 guint _key_zoom_new;
 guint _key_zoom_timeout_sid;
 
@@ -98,4 +79,10 @@ void map_center_unit(guint new_center_unitx, guint new_center_unity);
 void map_pan(gint delta_unitx, gint delta_unity);
 void map_set_mark();
 
+gboolean map_cb_configure(GtkWidget * widget, GdkEventConfigure * event);
+gboolean map_cb_expose(GtkWidget * widget, GdkEventExpose * event);
+gboolean map_cb_button_press(GtkWidget * widget, GdkEventButton * event);
+gboolean map_cb_button_release(GtkWidget * widget, GdkEventButton * event);
+gboolean map_cb_scroll_event(GtkWidget * widget, GdkEventScroll * event);
+
 #endif
index ba2ec775f0d80e0f631de4ae0398d2f855b95096..919f4afe977f4a429bddebe02fb3edc02e790da5 100644 (file)
@@ -120,7 +120,6 @@ typedef enum {
        CUSTOM_ACTION_TOGGLE_GPS,
        CUSTOM_ACTION_TOGGLE_GPSINFO,
        CUSTOM_ACTION_TOGGLE_SPEEDLIMIT,
-       CUSTOM_ACTION_RESET_BLUETOOTH,
        CUSTOM_ACTION_ENUM_COUNT
 } CustomAction;
 gchar *CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ENUM_COUNT];
index 6a7520d5ebb57e95b9e78d86a746ada2da86f837..291143ccec0efaa925c09ad5c64a7e04a01c3a0a 100644 (file)
@@ -1,6 +1,7 @@
 /*
- * This file is part of maemo-mapper
+ * This file is part of mapper
  *
+ * Copyright (C) 2007 Kaj-Michael Lang
  * Copyright (C) 2006-2007 John Costigan.
  *
  * POI and GPS-Info code originally written by Cezary Jackiewicz.
@@ -41,6 +42,7 @@
 #include <gtk/gtk.h>
 #include <fcntl.h>
 #include <gdk/gdkkeysyms.h>
+#include <dbus/dbus.h>
 #include <dbus/dbus-glib.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <curl/multi.h>
@@ -66,6 +68,8 @@
 #include "gpx.h"
 #include "config-gconf.h"
 
+DBusConnection *dbus_conn;
+
 gfloat UNITS_CONVERT[] = {1.85200,1.15077945,1.f,};
 
 GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT] = {
@@ -90,7 +94,6 @@ GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT] = {
        {0, 0xa000, 0x0000, 0xa000}     /* COLORABLE_POI */
 };
 
-
 /**
  * Save state and destroy all non-UI elements created by this program in
  * preparation for exiting.
@@ -98,64 +101,22 @@ GdkColor COLORABLE_DEFAULT[COLORABLE_ENUM_COUNT] = {
 static void 
 mapper_destroy(void)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (_curl_sid) {
-               g_source_remove(_curl_sid);
-               _curl_sid = 0;
-       }
-       config_save();
-       config_save_repo();
-       rcvr_disconnect();
-       /* _program and widgets have already been destroyed. */
-
-       osm_deinit();
-       db_close(&_db);
-
-       MACRO_PATH_FREE(_track);
-       MACRO_PATH_FREE(_route);
-
-       /* Clean up CURL. */
-       if (_curl_multi) {
-               CURL *curr;
-               CURLMsg *msg;
-               gint num_transfers, num_msgs;
-
-               /* First, remove all downloads from _pui_tree. */
-               g_tree_destroy(_pui_tree);
-
-               /* Finish up all downloads. */
-               while (CURLM_CALL_MULTI_PERFORM == curl_multi_perform(_curl_multi, &num_transfers) || num_transfers) {
-                       /* XXX: should inform the user why it's taking so damn long... */
-               }
-
-               /* Close all finished files. */
-               while ((msg = curl_multi_info_read(_curl_multi, &num_msgs))) {
-                       if (msg->msg == CURLMSG_DONE) {
-                               /* This is a map download. */
-                               ProgressUpdateInfo *pui = g_hash_table_lookup(_pui_by_easy, msg->easy_handle);
-                               g_queue_push_head(_curl_easy_queue, msg->easy_handle);
-                               g_hash_table_remove(_pui_by_easy, msg->easy_handle);
-                               fclose(pui->file);
-                               curl_multi_remove_handle(_curl_multi, msg->easy_handle);
-                       }
-               }
-
-               while ((curr = g_queue_pop_tail(_curl_easy_queue)))
-                       curl_easy_cleanup(curr);
-
-               curl_multi_cleanup(_curl_multi);
-               _curl_multi = NULL;
-
-               g_queue_free(_curl_easy_queue);
-               g_tree_destroy(_downloading_tree);
-               g_hash_table_destroy(_pui_by_easy);
-       }
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+config_save();
+config_save_repo();
+rcvr_disconnect();
+map_download_deinit();
+if (_curl_sid) {
+       g_source_remove(_curl_sid);
+       _curl_sid = 0;
+}
+osm_deinit();
+db_close(&_db);
+track_deinit();
+route_deinit();
 }
 
-void set_var_defaults(void)
+static void 
+set_var_defaults(void)
 {
 _conn_state = RCVR_OFF;
 }
@@ -178,10 +139,22 @@ static gint
 mapper_osso_cb_init(void)
 {
 #ifdef WITH_OSSO
+gchar *filter_string;
+
 if (OSSO_OK != osso_rpc_set_default_cb_f(_osso, dbus_cb_default, NULL)) {
        g_printerr("osso_rpc_set_default_cb_f failed.\n");
        return 1;
 }
+
+filter_string = g_strdup_printf("interface=%s", ICD_DBUS_INTERFACE);
+/* add match */
+dbus_bus_add_match(dbus_conn, filter_string, NULL);
+g_free(filter_string);
+/* add the callback */
+dbus_connection_add_filter(dbus_conn, get_connection_status_signal_cb, NULL, NULL);
+
+osso_iap_cb(iap_callback);
+
 #endif
 return 0;
 }
@@ -197,6 +170,40 @@ localtime_r(&time1, &time2);
 _gmtoffset = time2.tm_gmtoff;
 }
 
+static void 
+mapper_init(gint argc, gchar ** argv)
+{
+DBusGConnection *dbus_conn;
+GError *error = NULL;
+
+g_set_application_name("Mapper");
+
+mapper_init_variables();
+track_init();
+route_init();
+config_init();
+map_download_init();
+osm_init();
+gps_init();
+mapper_ui_init();
+
+#ifdef WITH_OSSO
+osso_hw_set_event_cb(_osso, NULL, osso_cb_hw_state, NULL);
+#endif
+
+/* Initialize D-Bus. */
+if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) {
+       g_printerr("Failed to open connection to D-Bus: %s.\n", error->message);
+       error = NULL;
+}
+#ifdef WITH_HILDON_DBUS_BT
+if (NULL == (_rfcomm_req_proxy = dbus_g_proxy_new_for_name(dbus_conn, BTCOND_SERVICE, BTCOND_REQ_PATH, BTCOND_REQ_INTERFACE))) {
+       g_printerr("Failed to open connection to %s.\n", BTCOND_REQ_INTERFACE);
+}
+#endif
+
+}
+
 gint 
 main(gint argc, gchar * argv[])
 {
@@ -215,7 +222,7 @@ main(gint argc, gchar * argv[])
        set_var_defaults();     
 #ifdef WITH_GST
        gst_init(&argc, &argv);
-       speak_init();
+       speak_init(120,50);
 #endif
        gtk_init(&argc, &argv);
        gconf_init(argc, argv, NULL);
index b87c13cc3aa5686c6b037ede0f5bb310301f516c..6c73732976d8597dd54af6076d89a8c25ccc701f 100644 (file)
@@ -30,6 +30,7 @@ struct sql_select_stmt {
 
        sqlite3_stmt *select_way_nodes;
        sqlite3_stmt *select_way_name;
+       sqlite3_stmt *select_way_name_nls;
        sqlite3_stmt *select_way_ref;
        sqlite3_stmt *select_place;
        sqlite3_stmt *select_near_place;
@@ -149,6 +150,11 @@ if (sqlite3_prepare_v2(db, "select f,lat,lon from way_s2s,nodes where wsid=? and
 if (sqlite3_prepare_v2(db, "select name from way_names where wid=?",
                    -1, &sql.select_way_name, NULL)!=SQLITE_OK)
        return FALSE;
+#if 0
+if (sqlite3_prepare_v2(db, "select name from way_names_nls where wid=? and lang=?",
+                   -1, &sql.select_way_name, NULL)!=SQLITE_OK)
+       return FALSE;
+#endif
 
 /* Way ref and int_ref */
 if (sqlite3_prepare_v2(db, "select ref,int_ref from way_ref where rid=?",
@@ -679,7 +685,7 @@ return (w->nodes==NULL) ? FALSE : TRUE;
 }
 
 /**
- * Get way name (primary name only for now)
+ * Get way name
  */
 gboolean
 osm_way_get_name(osm_way *w)
@@ -700,6 +706,28 @@ if (SQLITE_ROW == sqlite3_step(sql.select_way_name)) {
 return FALSE;
 }
 
+#if 0
+gboolean
+osm_way_get_name_nls(osm_way *w)
+{
+sqlite3_reset(sql.select_way_name_nls);
+sqlite3_clear_bindings(sql.select_way_name_nls);
+
+if (SQLITE_OK != sqlite3_bind_int(sql.select_way_name_nls, 1, w->id) ||
+       SQLITE_OK != sqlite3_bind_) {
+       g_printerr("Failed to bind values for way name nls\n");
+       return FALSE;
+}
+
+if (SQLITE_ROW == sqlite3_step(sql.select_way_name_nls)) {
+       const gchar *place;
+       place=sqlite3_column_text(sql.select_way_name_nls, 0);
+       w->name=g_strdup(place);
+}
+return FALSE;
+}
+#endif
+
 
 /**
  * Get Way ref and int_ref
index 074a90450bad85aaee59e447e6682d8859c818bc..6d78125e528a3f4a7620a2e2ead6bbc67d59d8dd 100644 (file)
--- a/src/osm.h
+++ b/src/osm.h
@@ -16,6 +16,7 @@
  * by 100 and the result is the importance/priority of the poi.
  * This can be used by the client program to discard 
  * unimportant poi at different zoom levels.
+ * It limits the categories to 100/priority but... I think that's fine :)
  */
 typedef enum {
        NODE_PLAIN=0,
index 2104cb3a44af4d59128799508d291681b6112587..ed706c58811c6116476f32441ed873ce8a73e02f 100644 (file)
 #include "mapper-types.h"
 #include "ui-common.h"
 #include "settings.h"
+#include "poi-gui.h"
 
 #define POI_QUICK_BUTTONS (9)
 
-guint _poi_zoom = 6;
+static GtkWidget *dialog_qp;
 
-gboolean select_poi(guint unitx, guint unity, poi_info *poi);
-
-gboolean category_delete(GtkWidget * widget, delete_poi *dpoi)
+static gboolean 
+category_delete(GtkWidget *widget, delete_poi *dpoi)
 {
        GtkWidget *dialog;
        guint i;
        gchar *buffer;
        printf("%s()\n", __PRETTY_FUNCTION__);
 
-       buffer = g_strdup_printf("%s\n\t%s\n%s",
-                                _("Delete category?"),
-                                dpoi->txt_label,
-                                _("WARNING: All POIs in that category will also be deleted!"));
+       buffer = g_strdup_printf("%s\n\t%s\n%s", _("Delete category?"),
+                                dpoi->txt_label, _("WARNING: All POIs in that category will also be deleted!"));
        dialog = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
        g_free(buffer);
        i = gtk_dialog_run(GTK_DIALOG(dialog));
@@ -58,7 +56,8 @@ gboolean category_delete(GtkWidget * widget, delete_poi *dpoi)
        return TRUE;
 }
 
-gboolean category_dialog(guint cat_id)
+gboolean 
+category_dialog(guint cat_id)
 {
        GtkWidget *dialog;
        GtkWidget *table;
@@ -190,7 +189,8 @@ gboolean category_dialog(guint cat_id)
        return results;
 }
 
-void category_toggled(GtkCellRendererToggle * cell, gchar * path, gpointer data)
+static void 
+category_toggled(GtkCellRendererToggle * cell, gchar * path, gpointer data)
 {
        GtkTreeIter iter;
        gboolean cat_enabled;
@@ -215,7 +215,7 @@ void category_toggled(GtkCellRendererToggle * cell, gchar * path, gpointer data)
        vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
 }
 
-gboolean 
+static gboolean 
 category_add(GtkWidget * widget, GtkWidget * tree_view)
 {
        GtkListStore *store;
@@ -231,7 +231,8 @@ category_add(GtkWidget * widget, GtkWidget * tree_view)
        return TRUE;
 }
 
-gboolean category_edit(GtkWidget * widget, GtkWidget * tree_view)
+static gboolean 
+category_edit(GtkWidget * widget, GtkWidget * tree_view)
 {
        GtkTreeIter iter;
        GtkTreeModel *store;
@@ -255,7 +256,8 @@ gboolean category_edit(GtkWidget * widget, GtkWidget * tree_view)
        return TRUE;
 }
 
-gboolean category_list()
+gboolean 
+category_list()
 {
        GtkWidget *dialog;
        GtkWidget *tree_view;
@@ -310,11 +312,9 @@ gboolean category_list()
        gtk_tree_view_column_set_max_width(column, 1);
 
        renderer = gtk_cell_renderer_toggle_new();
-       g_signal_connect(renderer, "toggled",
-                        G_CALLBACK(category_toggled), store);
+       g_signal_connect(renderer, "toggled", G_CALLBACK(category_toggled), store);
        column = gtk_tree_view_column_new_with_attributes(_("Enabled"), renderer,
-                                                    "active", CAT_ENABLED,
-                                                    NULL);
+                                                    "active", CAT_ENABLED, NULL);
        gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
        gtk_tree_view_column_set_sort_column_id (column, CAT_ENABLED);
 
@@ -339,11 +339,8 @@ gboolean category_list()
 
        gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
 
-       g_signal_connect(G_OBJECT(btn_edit), "clicked",
-                        G_CALLBACK(category_edit), tree_view);
-
-       g_signal_connect(G_OBJECT(btn_add), "clicked",
-                        G_CALLBACK(category_add), tree_view);
+       g_signal_connect(G_OBJECT(btn_edit), "clicked", G_CALLBACK(category_edit), tree_view);
+       g_signal_connect(G_OBJECT(btn_add), "clicked", G_CALLBACK(category_add), tree_view);
 
        gtk_widget_show_all(dialog);
        while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
@@ -355,7 +352,8 @@ gboolean category_list()
        return TRUE;
 }
 
-gboolean menu_cb_category(GtkAction * action)
+gboolean 
+menu_cb_category(GtkAction * action)
 {
        printf("%s()\n", __PRETTY_FUNCTION__);
 
@@ -500,7 +498,8 @@ select_poi(guint unitx, guint unity, poi_info *poi)
        return selected;
 }
 
-void poi_populate_cat_combo(GtkWidget * cmb_category, guint cat_id)
+static void 
+poi_populate_cat_combo(GtkWidget * cmb_category, guint cat_id)
 {
        GtkTreeIter active;
        GtkListStore *store;
@@ -514,10 +513,7 @@ void poi_populate_cat_combo(GtkWidget * cmb_category, guint cat_id)
                GtkTreeIter iter;
                guint cid = sqlite3_column_int(poisql.selall_cat, 0);
                gtk_list_store_append(store, &iter);
-               gtk_list_store_set(store, &iter,
-                                  0, cid,
-                                  1, sqlite3_column_text(poisql.selall_cat, 1),
-                                  -1);
+               gtk_list_store_set(store, &iter, 0, cid, 1, sqlite3_column_text(poisql.selall_cat, 1), -1);
                if (cid == cat_id) {
                        active = iter;
                        has_active = TRUE;
@@ -539,16 +535,18 @@ struct _PoiCategoryEditInfo {
        guint cat_id;
 };
 
-gboolean poi_edit_cat(GtkWidget * widget, PoiCategoryEditInfo * data)
+gboolean 
+poi_edit_cat(GtkWidget * widget, PoiCategoryEditInfo * data)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       if (category_list())
-               poi_populate_cat_combo(data->cmb_category, data->cat_id);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return TRUE;
+printf("%s()\n", __PRETTY_FUNCTION__);
+if (category_list())
+       poi_populate_cat_combo(data->cmb_category, data->cat_id);
+vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+return TRUE;
 }
 
-gboolean poi_dialog(POIAction action, guint unitx, guint unity)
+gboolean 
+poi_dialog(POIAction action, guint unitx, guint unity)
 {
        poi_info poi;
        gchar slat1[10], slon1[10];
@@ -663,8 +661,7 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity)
        }
 
        gtk_box_pack_start(GTK_BOX(hbox),
-                          btn_catedit =
-                          gtk_button_new_with_label(_("Edit Categories...")),
+                          btn_catedit = gtk_button_new_with_label(_("Edit Categories...")),
                           FALSE, FALSE, 4);
 
        gtk_table_attach(GTK_TABLE(table),
@@ -675,8 +672,7 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity)
        txt_scroll = gtk_scrolled_window_new(NULL, NULL);
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(txt_scroll),
                                            GTK_SHADOW_IN);
-       gtk_table_attach(GTK_TABLE(table),
-                        txt_scroll,
+       gtk_table_attach(GTK_TABLE(table), txt_scroll,
                         1, 2, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 4);
 
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll),
@@ -703,8 +699,7 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity)
        /* Connect Signals */
        pcedit.cmb_category = cmb_category;
        pcedit.cat_id = poi.cat_id;
-       g_signal_connect(G_OBJECT(btn_catedit), "clicked",
-                        G_CALLBACK(poi_edit_cat), &pcedit);
+       g_signal_connect(G_OBJECT(btn_catedit), "clicked", G_CALLBACK(poi_edit_cat), &pcedit);
        gtk_widget_show_all(dialog);
 
        while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
@@ -736,7 +731,7 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity)
                        if (poi_update(poi.poi_id, poi.cat_id, poi_label, poi_desc)==FALSE) {
                                MACRO_BANNER_SHOW_INFO(_window, _("Problem updating POI"));
                        } else {
-                               MACRO_MAP_RENDER_DATA();
+                               map_render_data();
                        }
                } else {
                        /* add poi */
@@ -745,12 +740,11 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity)
                        if (poi_add(poi.lat, poi.lon, poi.cat_id, poi_label, poi_desc)==FALSE) {
                                MACRO_BANNER_SHOW_INFO(_window, _("Problem adding POI"));
                        } else {
-                               MACRO_MAP_RENDER_DATA();
+                               map_render_data();
                        }
                }
                break;
        }
-
        g_free(dpoi.txt_label);
 
        g_free(poi.label);
@@ -763,25 +757,36 @@ gboolean poi_dialog(POIAction action, guint unitx, guint unity)
        return TRUE;
 }
 
+static gboolean
+poi_quick_button_cb(GtkWidget *w, gpointer data)
+{
+gtk_widget_destroy(dialog_qp);
+return TRUE;
+}
+
 gboolean
-poi_quick_dialog(gdouble lat, gdouble lon)
+poi_quick_dialog(guint unitx, guint unity)
 {
-GtkWidget *dialog;
 GtkWidget *table;
 GtkWidget *buttons[POI_QUICK_BUTTONS];
 guint x,y;
+poi_info poi;
+
+unit2latlon(unitx, unity, poi.lat, poi.lon);
 
-dialog = gtk_dialog_new_with_buttons(_("Quick POI"),
+dialog_qp = gtk_dialog_new_with_buttons(_("Quick POI"),
                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(3, 3, FALSE), TRUE, TRUE, 0);
+#ifdef WITH_OSSO_NOTYET
+       /* Enable the help button. */
+       ossohelp_dialog_help_enable(GTK_DIALOG(dialog_qp), HELP_ID_POIQUICK, _osso);
+#endif
+
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_qp)->vbox), table = gtk_table_new(3, 3, FALSE), TRUE, TRUE, 0);
 
 for (x=0;x<3;x++) {
        for (y=0;y<3;y++) {
@@ -789,18 +794,17 @@ for (x=0;x<3;x++) {
 
                btnlabel=g_strdup_printf("(%d)", (x+y));
                buttons[x+y]=gtk_button_new_with_label(btnlabel);
-               gtk_table_attach(GTK_TABLE(table),
-                       buttons[x+y], x, x+1, y, y+1, GTK_FILL, 0, 2, 4);
+               gtk_table_attach(GTK_TABLE(table), buttons[x+y], x, x+1, y, y+1, GTK_FILL, 0, 2, 4);
                g_free(btnlabel);
+               g_signal_connect(G_OBJECT(buttons[x+y]), "clicked", G_CALLBACK(poi_quick_button_cb), NULL);
        }
 }
 
-gtk_widget_show_all(dialog);
+gtk_widget_show_all(dialog_qp);
 
-if (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-       g_printf("Wee!");
+if (GTK_RESPONSE_REJECT == gtk_dialog_run(GTK_DIALOG(dialog_qp))) {
+       gtk_widget_destroy(dialog_qp);
 }
-gtk_widget_destroy(dialog);
 
 return TRUE;
 }
index febf84ac71892e9d84ac16e34ca138124b6d7196..e5f2cd2876d36d2e2a00fb5e8107ff7e9e976521 100644 (file)
--- a/src/poi.h
+++ b/src/poi.h
@@ -7,6 +7,7 @@
 #ifndef _MAPPER_POI_H
 #define _MAPPER_POI_H
 
+#include <glib.h>
 #include <sqlite3.h>
 
 typedef enum {
index 6247d3d89383000650911bc7a9404d5bf69878b4..a7e4e0c6945e170612949d2cb046eebbd7c330ed 100644 (file)
@@ -27,6 +27,8 @@
 #include "map.h"
 #include "file.h"
 #include "latlon.h"
+#include "map.h"
+#include "map-download.h"
 
 void route_find_nearest_point();
 void cancel_autoroute(gboolean temporary);
@@ -41,6 +43,19 @@ struct _OriginToggleInfo {
        GtkWidget *txt_to;
 };
 
+void
+route_init(void)
+{
+memset(&_route, 0, sizeof(_route));
+MACRO_PATH_INIT(_route);
+}
+
+void
+route_deinit(void)
+{
+MACRO_PATH_FREE(_route);
+}
+
 void
 route_clear(void)
 {
@@ -59,7 +74,7 @@ gtk_widget_destroy(confirm);
 }
 
 gboolean 
-route_open_file()
+route_open_file(void)
 {
 gchar *buffer;
 gint size;
@@ -150,35 +165,30 @@ origin_type_selected(GtkWidget * toggle, OriginToggleInfo * oti)
 void 
 cancel_autoroute(gboolean temporary)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (_autoroute_data.enabled) {
-               if (!temporary) {
-                       _autoroute_data.enabled = FALSE;
-
-                       g_free(_autoroute_data.dest);
-                       _autoroute_data.dest = NULL;
-
-                       g_free(_autoroute_data.src_str);
-                       _autoroute_data.src_str = NULL;
-               }
+if (_autoroute_data.enabled) {
+       if (!temporary) {
+               _autoroute_data.enabled = FALSE;
 
-               if (_autoroute_data.curl_easy) {
-                       if (_curl_multi)
-                               curl_multi_remove_handle(_curl_multi,
-                                                        _autoroute_data.curl_easy);
-                       curl_easy_cleanup(_autoroute_data.curl_easy);
-                       _autoroute_data.curl_easy = NULL;
-               }
+               g_free(_autoroute_data.dest);
+               _autoroute_data.dest = NULL;
 
-               g_free(_autoroute_data.rdl_data.bytes);
-               _autoroute_data.rdl_data.bytes = NULL;
-               _autoroute_data.rdl_data.bytes_read = 0;
+               g_free(_autoroute_data.src_str);
+               _autoroute_data.src_str = NULL;
+       }
 
-               _autoroute_data.in_progress = FALSE;
+       if (_autoroute_data.curl_easy) {
+               if (_curl_multi)
+                       curl_multi_remove_handle(_curl_multi, _autoroute_data.curl_easy);
+               curl_easy_cleanup(_autoroute_data.curl_easy);
+               _autoroute_data.curl_easy = NULL;
        }
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+       g_free(_autoroute_data.rdl_data.bytes);
+       _autoroute_data.rdl_data.bytes = NULL;
+       _autoroute_data.rdl_data.bytes_read = 0;
+
+       _autoroute_data.in_progress = FALSE;
+}
 }
 
 /**
@@ -186,61 +196,53 @@ cancel_autoroute(gboolean temporary)
  * auto-route with that data.
  */
 size_t
-route_dl_cb_read(void *ptr, size_t size, size_t nmemb,
-                RouteDownloadData * rdl_data)
+route_dl_cb_read(void *ptr, size_t size, size_t nmemb, RouteDownloadData * rdl_data)
 {
-       size_t old_size = rdl_data->bytes_read;
-       vprintf("%s()\n", __PRETTY_FUNCTION__);
+size_t old_size = rdl_data->bytes_read;
 
-       rdl_data->bytes_read += size * nmemb;
-       rdl_data->bytes = g_renew(gchar, rdl_data->bytes, rdl_data->bytes_read);
-       g_memmove(rdl_data->bytes + old_size, ptr, size * nmemb);
+rdl_data->bytes_read += size * nmemb;
+rdl_data->bytes = g_renew(gchar, rdl_data->bytes, rdl_data->bytes_read);
+g_memmove(rdl_data->bytes + old_size, ptr, size * nmemb);
 
-       vprintf("%s(): return %d\n", __PRETTY_FUNCTION__, size * nmemb);
-       return (size * nmemb);
+return (size * nmemb);
 }
 
 gboolean 
 auto_route_dl_idle()
 {
-       gchar latstr[32], lonstr[32], *latlonstr;
-       printf("%s(%f, %f, %s)\n", __PRETTY_FUNCTION__,
-              _gps.lat, _gps.lon, _autoroute_data.dest);
-
-       g_ascii_dtostr(latstr, 32, _gps.lat);
-       g_ascii_dtostr(lonstr, 32, _gps.lon);
-       latlonstr = g_strdup_printf("%s,%s", latstr, lonstr);
-       _autoroute_data.src_str =
-           g_strdup_printf(_route_dl_url, latlonstr, _autoroute_data.dest);
-       g_free(latlonstr);
-
-       MACRO_CURL_EASY_INIT(_autoroute_data.curl_easy);
-       curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_URL,
-                        _autoroute_data.src_str);
-       curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEFUNCTION,
-                        route_dl_cb_read);
-       curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEDATA,
-                        &_autoroute_data.rdl_data);
-       if (!_curl_multi) {
-               /* Initialize CURL. */
-               _curl_multi = curl_multi_init();
-               /*curl_multi_setopt(_curl_multi, CURLMOPT_PIPELINING, 1); */
-       }
-       curl_multi_add_handle(_curl_multi, _autoroute_data.curl_easy);
+gchar latstr[32], lonstr[32], *latlonstr;
+
+g_ascii_dtostr(latstr, 32, _gps.lat);
+g_ascii_dtostr(lonstr, 32, _gps.lon);
+latlonstr = g_strdup_printf("%s,%s", latstr, lonstr);
+_autoroute_data.src_str =
+    g_strdup_printf(_route_dl_url, latlonstr, _autoroute_data.dest);
+g_free(latlonstr);
+
+MACRO_CURL_EASY_INIT(_autoroute_data.curl_easy);
+curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_URL,
+                _autoroute_data.src_str);
+curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEFUNCTION,
+                route_dl_cb_read);
+curl_easy_setopt(_autoroute_data.curl_easy, CURLOPT_WRITEDATA,
+                &_autoroute_data.rdl_data);
+if (!_curl_multi) {
+       /* Initialize CURL. */
+       _curl_multi = curl_multi_init();
+       /*curl_multi_setopt(_curl_multi, CURLMOPT_PIPELINING, 1); */
+}
+curl_multi_add_handle(_curl_multi, _autoroute_data.curl_easy);
 
 #ifdef WITH_OSSO
-       if (iap_is_connected() && !_curl_sid)
+if (iap_is_connected() && !_curl_sid)
 #else
-       if (!_curl_sid)
+if (!_curl_sid)
 #endif
-               _curl_sid = g_timeout_add(100,
-                                         (GSourceFunc) curl_download_timeout,
-                                         NULL);
+       _curl_sid = g_timeout_add(100, (GSourceFunc) map_download_timeout, NULL);
 
-       _autoroute_data.in_progress = TRUE;
+_autoroute_data.in_progress = TRUE;
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return FALSE;
+return FALSE;
 }
 
 /**
@@ -256,256 +258,234 @@ auto_route_dl_idle()
 gboolean 
 route_download(gchar * to)
 {
-       GtkWidget *dialog;
-       GtkWidget *table;
-       GtkWidget *label;
-       GtkWidget *txt_source_url;
-       GtkWidget *hbox;
-       OriginToggleInfo oti;
-       GtkEntryCompletion *from_comp;
-       GtkEntryCompletion *to_comp;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GtkWidget *dialog;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *txt_source_url;
+GtkWidget *hbox;
+OriginToggleInfo oti;
+GtkEntryCompletion *from_comp;
+GtkEntryCompletion *to_comp;
 
 #ifdef WITH_OSSO
-       iap_connect();
+iap_connect();
 #endif
 
-       dialog = gtk_dialog_new_with_buttons(_("Download Route"),
-                                            GTK_WINDOW(_window),
-                                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                            GTK_RESPONSE_ACCEPT,
-                                            GTK_STOCK_CANCEL,
-                                            GTK_RESPONSE_REJECT, NULL);
+dialog = gtk_dialog_new_with_buttons(_("Download Route"),
+                            GTK_WINDOW(_window),
+                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
+                            GTK_RESPONSE_ACCEPT,
+                            GTK_STOCK_CANCEL,
+                            GTK_RESPONSE_REJECT, NULL);
 
 #ifdef WITH_OSSO
-       /* Enable the help button. */
-       ossohelp_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_DOWNROUTE,
-                                   _osso);
+/* Enable the help button. */
+ossohelp_dialog_help_enable(GTK_DIALOG(dialog), HELP_ID_DOWNROUTE, _osso);
 #endif
 
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                          table = gtk_table_new(2, 5, FALSE), TRUE, TRUE, 0);
-
-       from_comp = gtk_entry_completion_new();
-       gtk_entry_completion_set_model(from_comp, GTK_TREE_MODEL(_loc_model));
-       gtk_entry_completion_set_text_column(from_comp, 0);
-       to_comp = gtk_entry_completion_new();
-       gtk_entry_completion_set_model(to_comp, GTK_TREE_MODEL(_loc_model));
-       gtk_entry_completion_set_text_column(to_comp, 0);
-
-       /* Source URL. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Source URL")),
-                        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_source_url = gtk_entry_new(),
-                        1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-       gtk_entry_set_width_chars(GTK_ENTRY(txt_source_url), 25);
-
-       /* Auto. */
-       gtk_table_attach(GTK_TABLE(table),
-                        hbox = gtk_hbox_new(FALSE, 6),
-                        0, 2, 1, 2, GTK_FILL, 0, 2, 4);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          oti.rad_use_gps =
-                          gtk_radio_button_new_with_label(NULL,
-                                                          _
-                                                          ("Use GPS Location")),
-                          TRUE, TRUE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox), oti.chk_auto =
-                          gtk_check_button_new_with_label(_("Auto-Update")),
-                          TRUE, TRUE, 0);
-       gtk_widget_set_sensitive(oti.chk_auto, FALSE);
-
-       /* Use End of Route. */
-       gtk_table_attach(GTK_TABLE(table),
-                        hbox = gtk_hbox_new(FALSE, 6),
-                        0, 2, 2, 3, GTK_FILL, 0, 2, 4);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          oti.rad_use_route =
-                          gtk_radio_button_new_with_label_from_widget
-                          (GTK_RADIO_BUTTON(oti.rad_use_gps),
-                           _("Use End of Route")), TRUE, TRUE, 0);
-       gtk_widget_set_sensitive(oti.rad_use_route, _route.head != _route.tail);
-
-       /* Origin. */
-       gtk_table_attach(GTK_TABLE(table),
-                        oti.rad_use_text =
-                        gtk_radio_button_new_with_label_from_widget
-                        (GTK_RADIO_BUTTON(oti.rad_use_gps), _("Origin")), 0, 1,
-                        3, 4, GTK_FILL, 0, 2, 4);
-       gtk_table_attach(GTK_TABLE(table), oti.txt_from =
-                        gtk_entry_new(), 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0,
-                        2, 4);
-       gtk_entry_set_completion(GTK_ENTRY(oti.txt_from), from_comp);
-       gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_from), 25);
-
-       /* Destination. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Destination")),
-                        0, 1, 4, 5, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-       gtk_table_attach(GTK_TABLE(table),
-                        oti.txt_to = gtk_entry_new(),
-                        1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-       gtk_entry_set_completion(GTK_ENTRY(oti.txt_to), to_comp);
-       gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_to), 25);
-
-       g_signal_connect(G_OBJECT(oti.rad_use_gps), "toggled",
-                        G_CALLBACK(origin_type_selected), &oti);
-       g_signal_connect(G_OBJECT(oti.rad_use_route), "toggled",
-                        G_CALLBACK(origin_type_selected), &oti);
-       g_signal_connect(G_OBJECT(oti.rad_use_text), "toggled",
-                        G_CALLBACK(origin_type_selected), &oti);
-
-#if 0
-       g_object_set(G_OBJECT(oti.txt_from), HILDON_AUTOCAP, FALSE, NULL);
-       g_object_set(G_OBJECT(oti.txt_to), HILDON_AUTOCAP, FALSE, NULL);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+          table = gtk_table_new(2, 5, FALSE), TRUE, TRUE, 0);
+
+from_comp = gtk_entry_completion_new();
+gtk_entry_completion_set_model(from_comp, GTK_TREE_MODEL(_loc_model));
+gtk_entry_completion_set_text_column(from_comp, 0);
+to_comp = gtk_entry_completion_new();
+gtk_entry_completion_set_model(to_comp, GTK_TREE_MODEL(_loc_model));
+gtk_entry_completion_set_text_column(to_comp, 0);
+
+/* Source URL. */
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Source URL")), 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_source_url = gtk_entry_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_entry_set_width_chars(GTK_ENTRY(txt_source_url), 25);
+
+/* Auto. */
+gtk_table_attach(GTK_TABLE(table),
+                hbox = gtk_hbox_new(FALSE, 6),
+                0, 2, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_box_pack_start(GTK_BOX(hbox),
+                  oti.rad_use_gps = gtk_radio_button_new_with_label(NULL, _("Use GPS Location")),
+                  TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(hbox), oti.chk_auto =
+                  gtk_check_button_new_with_label(_("Auto-Update")),
+                  TRUE, TRUE, 0);
+gtk_widget_set_sensitive(oti.chk_auto, FALSE);
+
+/* Use End of Route. */
+gtk_table_attach(GTK_TABLE(table),
+                hbox = gtk_hbox_new(FALSE, 6),
+                0, 2, 2, 3, GTK_FILL, 0, 2, 4);
+gtk_box_pack_start(GTK_BOX(hbox),
+                  oti.rad_use_route =
+                  gtk_radio_button_new_with_label_from_widget
+                  (GTK_RADIO_BUTTON(oti.rad_use_gps),
+                   _("Use End of Route")), TRUE, TRUE, 0);
+gtk_widget_set_sensitive(oti.rad_use_route, _route.head != _route.tail);
+
+/* Origin. */
+gtk_table_attach(GTK_TABLE(table),
+                oti.rad_use_text =
+                gtk_radio_button_new_with_label_from_widget
+                (GTK_RADIO_BUTTON(oti.rad_use_gps), _("Origin")), 0, 1,
+                3, 4, GTK_FILL, 0, 2, 4);
+gtk_table_attach(GTK_TABLE(table), oti.txt_from =
+                gtk_entry_new(), 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0,
+                2, 4);
+gtk_entry_set_completion(GTK_ENTRY(oti.txt_from), from_comp);
+gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_from), 25);
+
+/* Destination. */
+gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Destination")),
+                0, 1, 4, 5, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+gtk_table_attach(GTK_TABLE(table),
+        oti.txt_to = gtk_entry_new(), 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_entry_set_completion(GTK_ENTRY(oti.txt_to), to_comp);
+gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_to), 25);
+
+g_signal_connect(G_OBJECT(oti.rad_use_gps), "toggled", G_CALLBACK(origin_type_selected), &oti);
+g_signal_connect(G_OBJECT(oti.rad_use_route), "toggled", G_CALLBACK(origin_type_selected), &oti);
+g_signal_connect(G_OBJECT(oti.rad_use_text), "toggled", G_CALLBACK(origin_type_selected), &oti);
+
+#if WITH_HILDON
+g_object_set(G_OBJECT(oti.txt_from), HILDON_AUTOCAP, FALSE, NULL);
+g_object_set(G_OBJECT(oti.txt_to), HILDON_AUTOCAP, FALSE, NULL);
 #endif
 
-       /* Initialize fields. */
-       gtk_entry_set_text(GTK_ENTRY(txt_source_url), _route_dl_url);
-       gtk_entry_set_text(GTK_ENTRY(oti.txt_to), (to ? to : ""));
+/* Initialize fields. */
+gtk_entry_set_text(GTK_ENTRY(txt_source_url), _route_dl_url);
+gtk_entry_set_text(GTK_ENTRY(oti.txt_to), (to ? to : ""));
+
+gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_text), TRUE);
 
+/* Use "End of Route" by default if they have a route. */
+if (_route.head != _route.tail) {
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_route), TRUE);
+       gtk_widget_grab_focus(oti.rad_use_route);
+}
+/* Else use "GPS Location" if they have GPS enabled. */
+else if (_enable_gps) {
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps), TRUE);
+       gtk_widget_grab_focus(oti.rad_use_gps);
+}
+/* Else use text. */
+else {
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_text), TRUE);
+       gtk_widget_grab_focus(oti.txt_from);
+}
 
-       /* Use "End of Route" by default if they have a route. */
-       if (_route.head != _route.tail) {
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                            (oti.rad_use_route), TRUE);
-               gtk_widget_grab_focus(oti.rad_use_route);
+gtk_widget_show_all(dialog);
+
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+       CURL *curl_easy;
+       RouteDownloadData rdl_data = { 0, 0 };
+       gchar buffer[BUFFER_SIZE];
+       const gchar *source_url, *from, *to;
+       gchar *from_escaped, *to_escaped;
+
+       source_url = gtk_entry_get_text(GTK_ENTRY(txt_source_url));
+       if (!strlen(source_url)) {
+               popup_error(dialog, _("Please specify a source URL."));
+               continue;
+       } else {
+               g_free(_route_dl_url);
+               _route_dl_url = g_strdup(source_url);
        }
-       /* Else use "GPS Location" if they have GPS enabled. */
-       else if (_enable_gps) {
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps),
-                                            TRUE);
-               gtk_widget_grab_focus(oti.rad_use_gps);
+
+       from = gtk_entry_get_text(GTK_ENTRY(oti.txt_from));
+       if (!strlen(from)) {
+               popup_error(dialog, _("Please specify a start location."));
+               continue;
        }
-       /* Else use text. */
-       else {
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                            (oti.rad_use_text), TRUE);
-               gtk_widget_grab_focus(oti.txt_from);
+
+       to = gtk_entry_get_text(GTK_ENTRY(oti.txt_to));
+       if (!strlen(to)) {
+               popup_error(dialog, _("Please specify an end location."));
+               continue;
        }
 
-       gtk_widget_show_all(dialog);
-
-       while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               CURL *curl_easy;
-               RouteDownloadData rdl_data = { 0, 0 };
-               gchar buffer[BUFFER_SIZE];
-               const gchar *source_url, *from, *to;
-               gchar *from_escaped, *to_escaped;
-
-               source_url = gtk_entry_get_text(GTK_ENTRY(txt_source_url));
-               if (!strlen(source_url)) {
-                       popup_error(dialog, _("Please specify a source URL."));
-                       continue;
-               } else {
-                       g_free(_route_dl_url);
-                       _route_dl_url = g_strdup(source_url);
-               }
+       from_escaped = gnome_vfs_escape_string(from);
+       to_escaped = gnome_vfs_escape_string(to);
+       snprintf(buffer, sizeof(buffer), source_url, from_escaped, to_escaped);
+       g_free(from_escaped);
+       g_free(to_escaped);
+
+       /* Attempt to download the route from the server. */
+       MACRO_CURL_EASY_INIT(curl_easy);
+       curl_easy_setopt(curl_easy, CURLOPT_URL, buffer);
+       curl_easy_setopt(curl_easy, CURLOPT_WRITEFUNCTION, route_dl_cb_read);
+       curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, &rdl_data);
+       if (CURLE_OK != curl_easy_perform(curl_easy)) {
+               popup_error(dialog, _("Failed to connect to GPX Directions server"));
+               curl_easy_cleanup(curl_easy);
+               g_free(rdl_data.bytes);
+               /* Let them try again */
+               continue;
+       }
+       curl_easy_cleanup(curl_easy);
+
+       if (strncmp(rdl_data.bytes, "<?xml", strlen("<?xml"))) {
+               /* Not an XML document - must be bad locations. */
+               popup_error(dialog,
+                           _("Could not generate directions. Make sure your "
+                            "source and destination are valid."));
+               g_free(rdl_data.bytes);
+               /* Let them try again. */
+       }
+       /* Else, if GPS is enabled, replace the route, otherwise append it. */
+       else if (parse_gpx(&_route, rdl_data.bytes, rdl_data.bytes_read,
+                          (gtk_toggle_button_get_active
+                           (GTK_TOGGLE_BUTTON(oti.rad_use_gps)) ? 0 : 1))) {
+               GtkTreeIter iter;
 
-               from = gtk_entry_get_text(GTK_ENTRY(oti.txt_from));
-               if (!strlen(from)) {
-                       popup_error(dialog,
-                                   _("Please specify a start location."));
-                       continue;
-               }
+               /* Find the nearest route point, if we're connected. */
+               route_find_nearest_point();
 
-               to = gtk_entry_get_text(GTK_ENTRY(oti.txt_to));
-               if (!strlen(to)) {
-                       popup_error(dialog,
-                                   _("Please specify an end location."));
-                       continue;
-               }
+               /* Cancel any autoroute that might be occurring. */
+               cancel_autoroute(FALSE);
 
-               from_escaped = gnome_vfs_escape_string(from);
-               to_escaped = gnome_vfs_escape_string(to);
-               snprintf(buffer, sizeof(buffer), source_url, from_escaped,
-                        to_escaped);
-               g_free(from_escaped);
-               g_free(to_escaped);
-
-               /* Attempt to download the route from the server. */
-               MACRO_CURL_EASY_INIT(curl_easy);
-               curl_easy_setopt(curl_easy, CURLOPT_URL, buffer);
-               curl_easy_setopt(curl_easy, CURLOPT_WRITEFUNCTION, route_dl_cb_read);
-               curl_easy_setopt(curl_easy, CURLOPT_WRITEDATA, &rdl_data);
-               if (CURLE_OK != curl_easy_perform(curl_easy)) {
-                       popup_error(dialog,
-                                   _("Failed to connect to GPX Directions server"));
-                       curl_easy_cleanup(curl_easy);
-                       g_free(rdl_data.bytes);
-                       /* Let them try again */
-                       continue;
-               }
-               curl_easy_cleanup(curl_easy);
+               map_force_redraw();
 
-               if (strncmp(rdl_data.bytes, "<?xml", strlen("<?xml"))) {
-                       /* Not an XML document - must be bad locations. */
-                       popup_error(dialog,
-                                   _("Could not generate directions. Make sure your "
-                                    "source and destination are valid."));
-                       g_free(rdl_data.bytes);
-                       /* Let them try again. */
+               if (gtk_toggle_button_get_active
+                   (GTK_TOGGLE_BUTTON(oti.chk_auto))) {
+                       /* Kick off a timeout to start the first update. */
+                       _autoroute_data.dest = gnome_vfs_escape_string(to);
+                       _autoroute_data.enabled = TRUE;
                }
-               /* Else, if GPS is enabled, replace the route, otherwise append it. */
-               else if (parse_gpx(&_route, rdl_data.bytes, rdl_data.bytes_read,
-                                  (gtk_toggle_button_get_active
-                                   (GTK_TOGGLE_BUTTON(oti.rad_use_gps))
-                                   ? 0 : 1))) {
-                       GtkTreeIter iter;
-
-                       /* Find the nearest route point, if we're connected. */
-                       route_find_nearest_point();
-
-                       /* Cancel any autoroute that might be occurring. */
-                       cancel_autoroute(FALSE);
-
-                       map_force_redraw();
-
-                       if (gtk_toggle_button_get_active
-                           (GTK_TOGGLE_BUTTON(oti.chk_auto))) {
-                               /* Kick off a timeout to start the first update. */
-                               _autoroute_data.dest = gnome_vfs_escape_string(to);
-                               _autoroute_data.enabled = TRUE;
-                       }
 
-                       /* Save Origin in Route Locations list if not from GPS. */
-                       if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps))
-                           && !g_slist_find_custom(_loc_list, from, (GCompareFunc) strcmp)) {
-                               _loc_list = g_slist_prepend(_loc_list, g_strdup(from));
-                               gtk_list_store_insert_with_values(_loc_model,
-                                                                 &iter, INT_MAX, 0, from, -1);
-                       }
+               /* Save Origin in Route Locations list if not from GPS. */
+               if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(oti.rad_use_gps))
+                   && !g_slist_find_custom(_loc_list, from, (GCompareFunc) strcmp)) {
+                       _loc_list = g_slist_prepend(_loc_list, g_strdup(from));
+                       gtk_list_store_insert_with_values(_loc_model,
+                                                         &iter, INT_MAX, 0, from, -1);
+               }
 
-                       /* Save Destination in Route Locations list. */
-                       if (!g_slist_find_custom(_loc_list, to, (GCompareFunc) strcmp)) {
-                               _loc_list = g_slist_prepend(_loc_list, g_strdup(to));
-                               gtk_list_store_insert_with_values(_loc_model,
-                                                                 &iter,
-                                                                 INT_MAX, 0,
-                                                                 to, -1);
-                       }
+               /* Save Destination in Route Locations list. */
+               if (!g_slist_find_custom(_loc_list, to, (GCompareFunc) strcmp)) {
+                       _loc_list = g_slist_prepend(_loc_list, g_strdup(to));
+                       gtk_list_store_insert_with_values(_loc_model,
+                                                         &iter,
+                                                         INT_MAX, 0,
+                                                         to, -1);
+               }
 
-                       MACRO_BANNER_SHOW_INFO(_window, _("Route Downloaded"));
-                       g_free(rdl_data.bytes);
+               MACRO_BANNER_SHOW_INFO(_window, _("Route Downloaded"));
+               g_free(rdl_data.bytes);
 
-                       /* Success! Get out of the while loop. */
-                       break;
-               } else {
-                       popup_error(dialog, _("Error parsing GPX file."));
-                       g_free(rdl_data.bytes);
-                       /* Let them try again. */
-               }
+               /* Success! Get out of the while loop. */
+               break;
+       } else {
+               popup_error(dialog, _("Error parsing GPX file."));
+               g_free(rdl_data.bytes);
+               /* Let them try again. */
        }
+}
 
-       gtk_widget_hide(dialog);        /* Destroying causes a crash (!?!?!??!) */
+gtk_widget_hide(dialog);       /* Destroying causes a crash (!?!?!??!) */
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
 WayPoint *
index fb4082f561878e70f1039dcde1314b054be1e713..616597343592e15b6af2b3b4604487f09fd665e6 100644 (file)
@@ -43,7 +43,7 @@ guint64 _next_wpt_dist_squared;
 /** The singleton auto-route-download data. */
 AutoRouteDownloadData _autoroute_data;
 
-gboolean route_open_file();
+gboolean route_open_file(void);
 gboolean route_save(void);
 void route_clear(void);
 gboolean auto_route_dl_idle();
index 3faf5138d0cda5681724ea8a3bcb35eeb5c35147..10d18fa903c42e42f05aa7a2a758dc1ae7bbc5f2 100644 (file)
@@ -2,16 +2,15 @@
 #define CONFIG_FILE_ROUTE "route.gpx"
 #define CONFIG_FILE_TRACK "track.gpx"
 
-/* Default OSM Repository */
+#define GCONF_KEY_PREFIX "/apps/maemo/mapper"
+
 #define REPO_DEFAULT_NAME "OpenStreet"
 #define REPO_DEFAULT_CACHE_BASE "~/MyDocs/.documents/Maps/"
 #define REPO_DEFAULT_CACHE_DIR REPO_DEFAULT_CACHE_BASE"OpenStreet"
 #define REPO_DEFAULT_MAP_URI "http://tile.openstreetmap.org/%0d/%d/%d.png"
-#define REPO_DEFAULT_DL_ZOOM_STEPS (2)
+#define REPO_DEFAULT_DL_ZOOM_STEPS (1)
 #define REPO_DEFAULT_VIEW_ZOOM_STEPS (1)
 
-#define GCONF_KEY_PREFIX "/apps/maemo/mapper"
-
 /* GPS */
 #define GCONF_KEY_RCVR_MAC GCONF_KEY_PREFIX"/receiver_mac"
 #define GCONF_KEY_RCVR_CHAN GCONF_KEY_PREFIX"/receiver_channel"
index 7b018d840c192504de6198f32537f7b21594211e..c66ddc709e29ed0f93fbdeb44c8d60735425f002 100644 (file)
 
 #include "hildon-wrappers.h"
 
-gboolean
+#define UPDATE_GC(gc) \
+    gdk_gc_set_line_attributes(gc, _draw_width, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
+void 
+update_gcs(void)
+{
+       gint i;
+       printf("%s()\n", __PRETTY_FUNCTION__);
+
+       for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
+               gdk_color_alloc(gtk_widget_get_colormap(_map_widget),
+                               &_color[i]);
+               if (_gc[i])
+                       g_object_unref(_gc[i]);
+               _gc[i] = gdk_gc_new(_map_pixmap);
+               gdk_gc_set_foreground(_gc[i], &_color[i]);
+               gdk_gc_set_line_attributes(_gc[i],
+                                          _draw_width, GDK_LINE_SOLID,
+                                          GDK_CAP_ROUND, GDK_JOIN_ROUND);
+       }
+
+       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+}
+
+static gboolean
 settings_dialog_browse_forfile(GtkWidget * widget, BrowseInfo * browse_info)
 {
        GtkWidget *dialog;
        gint res;
        printf("%s()\n", __PRETTY_FUNCTION__);
 
-       dialog =
-           GTK_WIDGET(hildon_file_chooser_dialog_new
-                      (GTK_WINDOW(browse_info->dialog),
+       dialog = GTK_WIDGET(hildon_file_chooser_dialog_new(GTK_WINDOW(browse_info->dialog),
                        GTK_FILE_CHOOSER_ACTION_OPEN));
 
        gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
-                                           gtk_entry_get_text(GTK_ENTRY
-                                                              (browse_info->
-                                                               txt)));
+                                           gtk_entry_get_text(GTK_ENTRY(browse_info->txt)));
 
        res=gtk_dialog_run(GTK_DIALOG(dialog));
        if (res==GTK_RESPONSE_OK || res==GTK_RESPONSE_ACCEPT) {
-               gchar *filename =
-                   gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+               gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
                gtk_entry_set_text(GTK_ENTRY(browse_info->txt), filename);
                g_free(filename);
        }
@@ -73,7 +91,7 @@ struct _KeysDialogInfo {
        GtkWidget *cmb[CUSTOM_KEY_ENUM_COUNT];
 };
 
-gboolean
+static gboolean
 settings_dialog_hardkeys_reset(GtkWidget * widget, KeysDialogInfo * cdi)
 {
        GtkWidget *confirm;
@@ -94,7 +112,7 @@ settings_dialog_hardkeys_reset(GtkWidget * widget, KeysDialogInfo * cdi)
        return TRUE;
 }
 
-gboolean 
+static gboolean 
 settings_dialog_hardkeys(GtkWidget * widget, GtkWidget * parent)
 {
        gint i;
@@ -195,8 +213,7 @@ settings_dialog_colors_reset(GtkWidget * widget, ColorsDialogInfo * cdi)
        printf("%s()\n", __PRETTY_FUNCTION__);
 
        confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
-                                              _
-                                              ("Reset all colors to their original defaults?"));
+                                              _("Reset all colors to their original defaults?"));
 
        if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
                gint i;
@@ -401,8 +418,7 @@ settings_dialog(void)
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
                          btn_colors = gtk_button_new_with_label(_("Colors...")));
 
-       gtk_dialog_add_button(GTK_DIALOG(dialog),
-                             GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+       gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
 
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
                           notebook = gtk_notebook_new(), TRUE, TRUE, 0);
@@ -466,12 +482,9 @@ settings_dialog(void)
                                 label = gtk_label_new(_("Announce")));
 
        /* Announcement Advance Notice. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Advance Notice")),
-                        0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Advance Notice")), 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), num_announce_notice = hildon_controlbar_new(),
-                        1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), num_announce_notice = hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
        hildon_controlbar_set_range(HILDON_CONTROLBAR(num_announce_notice), 1, 20);
        force_min_visible_bars(HILDON_CONTROLBAR(num_announce_notice), 1);
 
@@ -479,162 +492,90 @@ settings_dialog(void)
        gtk_table_attach(GTK_TABLE(table),
                         chk_enable_voice = gtk_check_button_new_with_label(_("Enable Voice Synthesis")),
                         0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_enable_voice),
-                                    _enable_voice);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_enable_voice), _enable_voice);
 
        /* Voice Speed and Pitch. */
-       gtk_table_attach(GTK_TABLE(table),
-                        hbox = gtk_hbox_new(FALSE, 12),
-                        0, 2, 2, 3, 0, 0, 2, 6);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          hbox2 = gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4);
-       gtk_box_pack_start(GTK_BOX(hbox2),
-                          lbl_voice_speed = gtk_label_new(_("Speed")),
-                          TRUE, TRUE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox2),
-                          num_voice_speed = hildon_controlbar_new(),
-                          TRUE, TRUE, 0);
-       hildon_controlbar_set_range(HILDON_CONTROLBAR(num_voice_speed), 1, 10);
-       force_min_visible_bars(HILDON_CONTROLBAR(num_voice_speed), 1);
+       gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 12), 0, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 6);
+       gtk_box_pack_start(GTK_BOX(hbox), hbox2 = gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4);
+       gtk_box_pack_start(GTK_BOX(hbox2), lbl_voice_speed = gtk_label_new(_("Speed (words/minute)")), TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox2), num_voice_speed = hildon_number_editor_new(80, 370), TRUE, TRUE, 0);
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          hbox2 = gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4);
-       gtk_box_pack_start(GTK_BOX(hbox2),
-                          lbl_voice_pitch = gtk_label_new(_("Pitch")),
-                          TRUE, TRUE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox2),
-                          num_voice_pitch = hildon_controlbar_new(),
-                          TRUE, TRUE, 0);
-       hildon_controlbar_set_range(HILDON_CONTROLBAR(num_voice_pitch), -2, 8);
-       force_min_visible_bars(HILDON_CONTROLBAR(num_voice_pitch), 1);
+       gtk_box_pack_start(GTK_BOX(hbox), hbox2 = gtk_hbox_new(FALSE, 4), TRUE, TRUE, 4);
+       gtk_box_pack_start(GTK_BOX(hbox2), lbl_voice_pitch = gtk_label_new(_("Pitch")), TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox2), num_voice_pitch = hildon_number_editor_new(1, 99), TRUE, TRUE, 0);
 
        /* Display settings page. */
-       gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
-                                table = gtk_table_new(2, 3, FALSE),
-                                label = gtk_label_new(_("Display")));
+       gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Display")));
 
        /* Line Width. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Line Width")),
-                        0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Line Width")), 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),
-                        num_draw_width = hildon_controlbar_new(),
-                        1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), num_draw_width = hildon_controlbar_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
        hildon_controlbar_set_range(HILDON_CONTROLBAR(num_draw_width), 1, 20);
        force_min_visible_bars(HILDON_CONTROLBAR(num_draw_width), 1);
 
        /* Keep Display On Only When Fullscreen. */
        gtk_table_attach(GTK_TABLE(table),
-                        chk_always_keep_on =
-                        gtk_check_button_new_with_label(_("Keep Display On Only in Fullscreen Mode")),
+                        chk_always_keep_on = gtk_check_button_new_with_label(_("Keep Display On Only in Fullscreen Mode")),
                         0, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
 
        /* Information Font Size. */
-       gtk_table_attach(GTK_TABLE(table),
-                        hbox = gtk_hbox_new(FALSE, 4),
-                        0, 2, 2, 3, GTK_FILL, 0, 2, 4);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          label = gtk_label_new(_("Information Font Size")),
-                          FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          cmb_info_font_size = gtk_combo_box_new_text(),
-                          FALSE, FALSE, 0);
+       gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 0, 2, 2, 3, GTK_FILL, 0, 2, 4);
+       gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Information Font Size")), FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), cmb_info_font_size = gtk_combo_box_new_text(), FALSE, FALSE, 0);
        for (i = 0; i < INFO_FONT_ENUM_COUNT; i++)
-               gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_info_font_size),
-                                         INFO_FONT_TEXT[i]);
+               gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_info_font_size), INFO_FONT_TEXT[i]);
 
        /* Units page. */
-       gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
-                                table = gtk_table_new(2, 3, FALSE),
-                                label = gtk_label_new(_("Units")));
+       gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Units")));
 
        /* Units. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Units")),
-                        0, 1, 0, 1, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Units")), 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),
-                        cmb_units = gtk_combo_box_new_text(),
-                        1, 2, 0, 1, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), cmb_units = gtk_combo_box_new_text(), 1, 2, 0, 1, GTK_FILL, 0, 2, 4);
        for (i = 0; i < UNITS_ENUM_COUNT; i++)
-               gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_units),
-                                         UNITS_TEXT[i]);
+               gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_units), UNITS_TEXT[i]);
 
        /* Degrees format */
-       gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Degrees Format")),
-                        0, 1, 1, 2, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Degrees Format")), 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), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f),
-                        1, 2, 1, 2, GTK_FILL, 0, 2, 4);
-       gtk_container_add(GTK_CONTAINER(label),
-                         cmb_degformat = gtk_combo_box_new_text());
+       gtk_table_attach(GTK_TABLE(table), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), 1, 2, 1, 2, GTK_FILL, 0, 2, 4);
+       gtk_container_add(GTK_CONTAINER(label), cmb_degformat = gtk_combo_box_new_text());
        for (i = 0; i < DEG_FORMAT_ENUM_COUNT; i++)
-               gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_degformat),
-                                         DEG_FORMAT_TEXT[i]);
+               gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_degformat), DEG_FORMAT_TEXT[i]);
 
-       gtk_table_attach(GTK_TABLE(table),
-                        gtk_label_new(""),
-                        2, 3, 0, 2, GTK_FILL | GTK_EXPAND, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), gtk_label_new(""), 2, 3, 0, 2, GTK_FILL | GTK_EXPAND, 0, 2, 4);
 
        /* Speed warner. */
-       gtk_table_attach(GTK_TABLE(table),
-                        hbox = gtk_hbox_new(FALSE, 4),
-                        0, 3, 2, 3, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 0, 3, 2, 3, GTK_FILL, 0, 2, 4);
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          chk_speed_limit_on =
-                          gtk_check_button_new_with_label(_("Speed Limit")),
-                          FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), chk_speed_limit_on = gtk_check_button_new_with_label(_("Speed Limit")), FALSE, FALSE, 0);
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f),
-                          FALSE, FALSE, 0);
-       gtk_container_add(GTK_CONTAINER(label),
-                         num_speed = hildon_number_editor_new(0, 999));
+       gtk_box_pack_start(GTK_BOX(hbox), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE, 0);
+       gtk_container_add(GTK_CONTAINER(label), num_speed = hildon_number_editor_new(0, 999));
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          label = gtk_label_new(_("Location")),
-                          FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f),
-                          FALSE, FALSE, 0);
-       gtk_container_add(GTK_CONTAINER(label),
-                         cmb_speed_location = gtk_combo_box_new_text());
+       gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Location")), FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE, 0);
+       gtk_container_add(GTK_CONTAINER(label), cmb_speed_location = gtk_combo_box_new_text());
        for (i = 0; i < SPEED_LOCATION_ENUM_COUNT; i++)
                gtk_combo_box_append_text(GTK_COMBO_BOX(cmb_speed_location),
                                          SPEED_LOCATION_TEXT[i]);
 
        /* Database page */
-       gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
-                                table = gtk_table_new(2, 3, FALSE),
-                                label = gtk_label_new(_("Database")));
+       gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table = gtk_table_new(2, 3, FALSE), label = gtk_label_new(_("Database")));
 
        /* Database. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Database")),
-                        0, 1, 1, 2, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Database")), 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),
-                        hbox = gtk_hbox_new(FALSE, 4),
-                        1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          txt_mapper_db = gtk_entry_new(), TRUE, TRUE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          btn_browsedb =
-                          gtk_button_new_with_label(_("Browse...")), FALSE,
-                          FALSE, 0);
+       gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+       gtk_box_pack_start(GTK_BOX(hbox), txt_mapper_db = gtk_entry_new(), TRUE, TRUE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), btn_browsedb = gtk_button_new_with_label(_("Browse...")), FALSE, FALSE, 0);
 
        /* Show POI below zoom. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Show POI below zoom")),
-                        0, 1, 2, 3, GTK_FILL, 0, 2, 4);
+       gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Show POI below zoom")), 0, 1, 2, 3, GTK_FILL, 0, 2, 4);
        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f),
-                        1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-       gtk_container_add(GTK_CONTAINER(label),
-                         num_poi_zoom = hildon_number_editor_new(0, MAX_ZOOM));
+       gtk_table_attach(GTK_TABLE(table), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+       gtk_container_add(GTK_CONTAINER(label), num_poi_zoom = hildon_number_editor_new(0, MAX_ZOOM));
 
        /* Connect signals. */
        scan_info.settings_dialog = dialog;
@@ -653,26 +594,17 @@ settings_dialog(void)
        if (_mapper_db)
                gtk_entry_set_text(GTK_ENTRY(txt_mapper_db), _mapper_db);
 
-       hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_poi_zoom),
-                                      _poi_zoom);
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_center_ratio),
-                                   _center_ratio);
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_lead_ratio),
-                                   _lead_ratio);
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_announce_notice),
-                                   _announce_notice_ratio);
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_voice_speed),
-                                   (gint) (_voice_speed * 3 + 0.5));
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_voice_pitch),
-                                   _voice_pitch);
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_draw_width),
-                                   _draw_width);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_always_keep_on),
-                                    !_always_keep_on);
+       hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_poi_zoom), _poi_zoom);
+       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_center_ratio), _center_ratio);
+       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_lead_ratio), _lead_ratio);
+       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_announce_notice), _announce_notice_ratio);
+       hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_voice_speed), _voice_speed);
+       hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_voice_pitch), _voice_pitch);
+       hildon_controlbar_set_value(HILDON_CONTROLBAR(num_draw_width), _draw_width);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_always_keep_on), !_always_keep_on);
        gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_units), _units);
        gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_degformat), _degformat);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_speed_limit_on),
-                                    _speed_limit_on);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chk_speed_limit_on), _speed_limit_on);
        hildon_number_editor_set_range(HILDON_NUMBER_EDITOR(num_speed), 1, 300);
        hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(num_speed), _speed_limit);
        gtk_combo_box_set_active(GTK_COMBO_BOX(cmb_speed_location), _speed_location);
@@ -681,13 +613,6 @@ settings_dialog(void)
        gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 300);
        gtk_widget_show_all(dialog);
 
-       /* TODO: Uncomment the following hide function calls if moimart ever
-        * releases his dbus-based flite software. */
-       gtk_widget_hide(lbl_voice_speed);
-       gtk_widget_hide(num_voice_speed);
-       gtk_widget_hide(lbl_voice_pitch);
-       gtk_widget_hide(num_voice_pitch);
-
        if (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
                /* Set _rcvr_mac if necessary. */
                if (!*gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac))) {
@@ -696,21 +621,16 @@ settings_dialog(void)
                                g_free(_rcvr_mac);
                                _rcvr_mac = NULL;
                                rcvr_changed = TRUE;
-                               gtk_widget_set_sensitive(GTK_WIDGET
-                                                        (_menu_gps_details_item),
-                                                        FALSE);
+                               gtk_widget_set_sensitive(GTK_WIDGET(_menu_gps_details_item), FALSE);
                        }
                        if (_enable_gps) {
                                gtk_check_menu_item_set_active
                                    (GTK_CHECK_MENU_ITEM(_menu_enable_gps_item),
                                     FALSE);
-                               popup_error(dialog,
-                                           _("No GPS Receiver MAC provided.\n"
+                               popup_error(dialog, _("No GPS Receiver MAC provided.\n"
                                              "GPS will be disabled."));
                                rcvr_changed = TRUE;
-                               gtk_widget_set_sensitive(GTK_WIDGET
-                                                        (_menu_gps_details_item),
-                                                        FALSE);
+                               gtk_widget_set_sensitive(GTK_WIDGET(_menu_gps_details_item), FALSE);
                        }
                } else if (!_rcvr_mac || strcmp(_rcvr_mac, gtk_entry_get_text(GTK_ENTRY(txt_rcvr_mac)))) {
                        /* User specified a new rcvr mac. */
@@ -732,8 +652,8 @@ settings_dialog(void)
 
                _announce_notice_ratio = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_announce_notice));
 
-               _voice_speed = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_voice_speed)) / 3.0;
-               _voice_pitch = hildon_controlbar_get_value(HILDON_CONTROLBAR(num_voice_pitch));
+               _voice_speed = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_voice_speed));
+               _voice_pitch = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(num_voice_pitch));
                _enable_voice = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_enable_voice));
 
 
index a7fa41f1c96563a361829618d77c229c1e80d6c9..c20705a3c674a1882809ae43cd09968c70a363f6 100644 (file)
@@ -2,5 +2,6 @@
 #define _SETTINGS_GUI_H
 
 gboolean settings_dialog(void);
+void update_gcs(void);
 
 #endif
index 014fcae9229e55488133f63f3f3e9ebf898bb67b..bf8e36a23f8f53f43522c3534ca974d4294317eb 100644 (file)
@@ -41,8 +41,8 @@ guint _draw_width;
 
 gboolean _enable_voice;
 guint _announce_notice_ratio;
-gdouble _voice_speed;
-gint _voice_pitch;
+guint _voice_speed;
+guint _voice_pitch;
 
 gboolean _speed_limit_on;
 gboolean _speed_excess;
index f3c7d004a1c1d6546d780362894126c0d684040e..e565e1dfaf94a6bb4d11fd9b5d222514030b0c59 100644 (file)
@@ -37,6 +37,7 @@ static gst_espeak ge;
 static gint erate;
 static GstBus *bus;
 static gboolean speaking=FALSE;
+static gboolean speak_ok;
 
 static gboolean
 bus_call (GstBus *bus, GstMessage *msg, gpointer data)
@@ -48,6 +49,7 @@ switch (GST_MESSAGE_TYPE (msg)) {
        case GST_MESSAGE_EOS:
        g_print ("EOS\n");
                speaking=FALSE;
+               speak_ok=TRUE;
                speak_stop();
        break;
        case GST_MESSAGE_ERROR:
@@ -59,12 +61,13 @@ switch (GST_MESSAGE_TYPE (msg)) {
 
                speak_stop();
                speaking=FALSE;
+               speak_ok=FALSE;
        break;
        case GST_MESSAGE_STATE_CHANGED:
 
        break;
     default:
-               g_print("HUH: %s\n", gst_message_type_get_name(GST_MESSAGE_TYPE(msg)));
+               g_printf("GST: %s\n", gst_message_type_get_name(GST_MESSAGE_TYPE(msg)));
        break;
        }
 return TRUE;
@@ -135,7 +138,7 @@ return 0;
 }
 
 gboolean
-speak_init(void)
+speak_init(guint speed, guint pitch)
 {
 erate=espeak_Initialize(AUDIO_OUTPUT_RETRIEVAL, 100, NULL, 0);
 if (erate==-1) 
@@ -143,8 +146,9 @@ if (erate==-1)
 
 espeak_SetSynthCallback(espeak_cb);
 espeak_SetVoiceByName("en");
-espeak_SetParameter(espeakRATE,125,0);
-espeak_SetParameter(espeakVOLUME,100,0);
+espeak_SetParameter(espeakRATE, speed,0);
+espeak_SetParameter(espeakPITCH, pitch,0);
+espeak_SetParameter(espeakVOLUME, 100,0);
 if (speak_create_pipeline()==FALSE)
        return FALSE;
 
@@ -198,7 +202,7 @@ return TRUE;
 
 #else
 
-gboolean speak_init(void) {return TRUE;}
+gboolean speak_init(guint speed, guint pitch) {return TRUE;}
 void speak_deinit(void) {}
 gboolean speak_stop(void) {return TRUE;}
 gboolean speak_speaking(void) {return FALSE;}
index 7bb4b46d7ee1678fdb7528ef6f44e67e1455fd74..1ef1817ced5d6cc0b4cef0c301e82528edfaa017 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <glib.h>
 
-gboolean speak_init(void);
+gboolean speak_init(guint speed, guint pitch);
 void speak_deinit(void);
 gboolean speak_stop(void);
 gboolean speak_speaking(void);
index 55aa0214a0931b11d2118ee3f02098245534bf11..9c464f2c8a2c6340babeb06f7c7973133ecade00 100644 (file)
@@ -1,4 +1,4 @@
-#include <config.h>
+#include "config.h"
 
 #define _GNU_SOURCE
 
@@ -6,14 +6,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
-#include <stddef.h>
-#include <math.h>
-#include <errno.h>
 #include <glib/gstdio.h>
 #include <gtk/gtk.h>
-#include <fcntl.h>
-#include <libintl.h>
-#include <locale.h>
 
 #include "utils.h"
 #include "mapper-types.h"
 #include "gps.h"
 #include "settings.h"
 #include "ui-common.h"
+#include "speak.h"
 
 gchar *SPEED_LOCATION_TEXT[SPEED_LOCATION_ENUM_COUNT];
 
-gboolean speed_excess(void)
+static gboolean 
+speed_excess(void)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       if (!_speed_excess)
-               return FALSE;
+if (!_speed_excess)
+       return FALSE;
 
-#if 0
-       hildon_play_system_sound("/usr/share/sounds/ui-information_note.wav");
-#endif
+speak_text("Warning, you are over speed limit!");
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-void speed_limit(void)
+void
+speed_limit(void)
 {
-       GdkGC *gc;
-       gfloat cur_speed;
-       gchar *buffer;
-       static guint x = 0, y = 0, width = 0, height = 0;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GdkGC *gc;
+gfloat cur_speed;
+gchar *buffer;
+static guint x = 0, y = 0, width = 0, height = 0;
 
-       cur_speed = _gps.speed * UNITS_CONVERT[_units];
+cur_speed = _gps.speed * UNITS_CONVERT[_units];
 
-       if (cur_speed > _speed_limit) {
-               gc = _speed_limit_gc1;
-               if (!_speed_excess) {
-                       _speed_excess = TRUE;
-                       g_timeout_add(5000, (GSourceFunc) speed_excess, NULL);
-               }
-       } else {
-               gc = _speed_limit_gc2;
-               _speed_excess = FALSE;
+if (cur_speed > _speed_limit) {
+       gc = _speed_limit_gc1;
+       if (!_speed_excess) {
+               _speed_excess = TRUE;
+               g_timeout_add(5000, (GSourceFunc) speed_excess, NULL);
        }
+} else {
+       gc = _speed_limit_gc2;
+       _speed_excess = FALSE;
+}
 
-       buffer = g_strdup_printf("%0.0f", cur_speed);
-       pango_layout_set_text(_speed_limit_layout, buffer, -1);
-       pango_layout_get_pixel_size(_speed_limit_layout, &width, &height);
+buffer = g_strdup_printf("%0.0f", cur_speed);
+pango_layout_set_text(_speed_limit_layout, buffer, -1);
+pango_layout_get_pixel_size(_speed_limit_layout, &width, &height);
 
-       gtk_widget_queue_draw_area(_map_widget, x - 5, y - 5, width + 15, height + 5);
-       gdk_window_process_all_updates();
+gtk_widget_queue_draw_area(_map_widget, x - 5, y - 5, width + 15, height + 5);
+gdk_window_process_all_updates();
 
-       switch (_speed_location) {
+switch (_speed_location) {
        case SPEED_LOCATION_TOP_RIGHT:
                x = _map_widget->allocation.width - 10 - width;
                y = 5;
-               break;
+       break;
        case SPEED_LOCATION_BOTTOM_RIGHT:
                x = _map_widget->allocation.width - 10 - width;
                y = _map_widget->allocation.height - 10 - height;
-               break;
+       break;
        case SPEED_LOCATION_BOTTOM_LEFT:
                x = 10;
                y = _map_widget->allocation.height - 10 - height;
-               break;
+       break;
        default:
                x = 10;
                y = 10;
-               break;
-       }
-
-       gdk_draw_layout(_map_widget->window, gc, x, y, _speed_limit_layout);
-       g_free(buffer);
+       break;
+}
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+gdk_draw_layout(_map_widget->window, gc, x, y, _speed_limit_layout);
+g_free(buffer);
 }
index c667f7603036a6bd2e639aa309371cb242bbccfe..c4294d76d708c32f2b754e66fff33a2ce9a347e4 100644 (file)
@@ -23,19 +23,31 @@ struct sql_select_stmt {
 };
 static struct sql_select_stmt sql;
 
+void
+track_init(void)
+{
+memset(&_track, 0, sizeof(_track));
+MACRO_PATH_INIT(_track);
+}
+
+void
+track_deinit(void)
+{
+MACRO_PATH_FREE(_track);
+}
+
 void 
 track_clear(void)
 {
-       GtkWidget *confirm;
-
-       confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Really clear the track?"));
+GtkWidget *confirm;
 
-       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
-               _track.tail = _track.head;
-               map_force_redraw();
-       }
+confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), _("Really clear the track?"));
 
-       gtk_widget_destroy(confirm);
+if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+       _track.tail = _track.head;
+       map_force_redraw();
+}
+gtk_widget_destroy(confirm);
 }
 
 gfloat 
@@ -74,35 +86,28 @@ track_show_distance_from(Point * point)
 void 
 track_show_distance_from_last()
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
+/* Find last zero point. */
+if (_track.head != _track.tail) {
+       Point *point;
        /* Find last zero point. */
-       if (_track.head != _track.tail) {
-               Point *point;
-               /* Find last zero point. */
-               for (point = _track.tail; point->unity; point--) {
-               }
-               track_show_distance_from(point);
-       } else {
-               MACRO_BANNER_SHOW_INFO(_window,
-                                      _("The current track is empty."));
+       for (point = _track.tail; point->unity; point--) {
        }
-       printf("%s(): return\n", __PRETTY_FUNCTION__);
+       track_show_distance_from(point);
+} else {
+       MACRO_BANNER_SHOW_INFO(_window, _("The current track is empty."));
+}
 }
 
 void 
 track_show_distance_from_first()
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       /* Find last zero point. */
-       if (_track.head != _track.tail) {
-               track_show_distance_from(_track.head);
-       } else {
-               MACRO_BANNER_SHOW_INFO(_window,
-                                      _("The current track is empty."));
-       }
-       printf("%s(): return\n", __PRETTY_FUNCTION__);
+/* Find last zero point. */
+if (_track.head != _track.tail) {
+       track_show_distance_from(_track.head);
+} else {
+       MACRO_BANNER_SHOW_INFO(_window, _("The current track is empty."));
+}
+printf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
 /**
@@ -119,84 +124,76 @@ track_show_distance_from_first()
 void 
 track_add(time_t time, gboolean newly_fixed)
 {
-       gboolean show_directions = TRUE;
-       gint announce_thres_unsquared;
-       printf("%s(%u, %u)\n", __PRETTY_FUNCTION__, _pos.unitx, _pos.unity);
-
-       if (abs((gint) _pos.unitx - _track.tail->unitx) > _draw_width
-           || abs((gint) _pos.unity - _track.tail->unity) > _draw_width) {
-
-               /* If time != 0, update the nearest-waypoint data. */
-               if (time && _route.head != _route.tail && 
-                       (newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
-                       /* Nearest waypoint has changed - re-render paths. */
-                       map_render_paths();
-                       MACRO_QUEUE_DRAW_AREA();
-               }
+gboolean show_directions = TRUE;
+gint announce_thres_unsquared;
+
+if (abs((gint) _pos.unitx - _track.tail->unitx) > _draw_width || abs((gint) _pos.unity - _track.tail->unity) > _draw_width) {
+       /* If time != 0, update the nearest-waypoint data. */
+       if (time && _route.head != _route.tail && 
+               (newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
+               /* Nearest waypoint has changed - re-render paths. */
+               map_render_paths();
+               MACRO_QUEUE_DRAW_AREA();
+       }
 
-               if (_show_tracks & TRACKS_MASK) {
-                       gint tx1, ty1, tx2, ty2;
-
-                       /* Instead of calling map_render_paths(), we'll draw the new line
-                        * ourselves and call gtk_widget_queue_draw_area(). */
-                       map_render_segment(_gc[COLORABLE_TRACK],
-                                          _gc[COLORABLE_TRACK_BREAK],
-                                          _track.tail->unitx,
-                                          _track.tail->unity, _pos.unitx,
-                                          _pos.unity);
-
-                       if (time && _track.tail->unity) {
-                               tx1 = unit2x(_track.tail->unitx);
-                               ty1 = unit2y(_track.tail->unity);
-                               tx2 = unit2x(_pos.unitx);
-                               ty2 = unit2y(_pos.unity);
-                               gtk_widget_queue_draw_area(_map_widget,
-                                                          MIN(tx1, tx2) - _draw_width, 
-                                                          MIN(ty1, ty2) - _draw_width,
-                                                          abs(tx1 - tx2) + (2 * _draw_width),
-                                                          abs(ty1 - ty2) + (2 * _draw_width));
-                       }
+       if (_show_tracks & TRACKS_MASK) {
+               gint tx1, ty1, tx2, ty2;
+
+               /* Instead of calling map_render_paths(), we'll draw the new line
+                * ourselves and call gtk_widget_queue_draw_area(). */
+               map_render_segment(_gc[COLORABLE_TRACK],
+                                  _gc[COLORABLE_TRACK_BREAK],
+                                  _track.tail->unitx,
+                                  _track.tail->unity, _pos.unitx,
+                                  _pos.unity);
+
+               if (time && _track.tail->unity) {
+                       tx1 = unit2x(_track.tail->unitx);
+                       ty1 = unit2y(_track.tail->unity);
+                       tx2 = unit2x(_pos.unitx);
+                       ty2 = unit2y(_pos.unity);
+                       gtk_widget_queue_draw_area(_map_widget,
+                                          MIN(tx1, tx2) - _draw_width, 
+                                          MIN(ty1, ty2) - _draw_width,
+                                          abs(tx1 - tx2) + (2 * _draw_width),
+                                          abs(ty1 - ty2) + (2 * _draw_width));
                }
+       }
 
-               MACRO_PATH_INCREMENT_TAIL(_track);
-
-               if (time)
-                       *_track.tail = _pos;
-               else
-                       *_track.tail = _point_null;
+       MACRO_PATH_INCREMENT_TAIL(_track);
 
-               if (_autoroute_data.enabled && !_autoroute_data.in_progress && _near_point_dist_squared > 400) {
-                       MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
-                       _autoroute_data.in_progress = TRUE;
-                       show_directions = FALSE;
-                       g_idle_add((GSourceFunc) auto_route_dl_idle, NULL);
-               }
+       if (time)
+               *_track.tail = _pos;
+       else
+               *_track.tail = _point_null;
 
-               /* Keep the display on. */
-               KEEP_DISPLAY_ON();
+       if (_autoroute_data.enabled && !_autoroute_data.in_progress && _near_point_dist_squared > 400) {
+               MACRO_BANNER_SHOW_INFO(_window, _("Recalculating directions..."));
+               _autoroute_data.in_progress = TRUE;
+               show_directions = FALSE;
+               g_idle_add((GSourceFunc) auto_route_dl_idle, NULL);
        }
 
-       announce_thres_unsquared = (20 + (guint) _gps.speed) * _announce_notice_ratio * 3;
+       /* Keep the display on. */
+       KEEP_DISPLAY_ON();
+}
 
-       /* Check if we should announce upcoming waypoints. */
-       if (show_directions && time && _next_way_dist_squared
-           < (announce_thres_unsquared * announce_thres_unsquared)) {
-               if (_enable_voice && strcmp(_next_way->desc, _last_spoken_phrase)) {
-                       g_free(_last_spoken_phrase);
-                       _last_spoken_phrase = g_strdup(_next_way->desc);
-                       speak_text(_last_spoken_phrase);
-               }
-               MACRO_BANNER_SHOW_INFO(_window, _next_way->desc);
-       }
+announce_thres_unsquared = (20 + (guint) _gps.speed) * _announce_notice_ratio * 3;
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+/* Check if we should announce upcoming waypoints. */
+if (show_directions && time && _next_way_dist_squared < (announce_thres_unsquared * announce_thres_unsquared)) {
+       if (_enable_voice && strcmp(_next_way->desc, _last_spoken_phrase)) {
+               g_free(_last_spoken_phrase);
+               _last_spoken_phrase = g_strdup(_next_way->desc);
+               speak_text(_last_spoken_phrase);
+       }
+       MACRO_BANNER_SHOW_INFO(_window, _next_way->desc);
+}
 }
 
 void 
 track_insert_break(void)
 {
-printf("%s()\n", __PRETTY_FUNCTION__);
-
 if (_track.tail->unity) {
        guint x1, y1;
 
@@ -219,8 +216,6 @@ if ((x1 < BUF_WIDTH_PIXELS) && ((unsigned)y1 < BUF_HEIGHT_PIXELS))
 } else {
        MACRO_BANNER_SHOW_INFO(_window, _("Break already inserted."));
 }
-
-vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
 gboolean 
index 871843946320c6f0aee7e7a72f7679f44e4fe276..dc9846384de09461821742b42d8f20f586e3e5c5 100644 (file)
 #include <fcntl.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <curl/multi.h>
-#include <gconf/gconf-client.h>
-#include <libxml/parser.h>
-#include <libintl.h>
-#include <locale.h>
-#include <sqlite3.h>
+#include <glib/gi18n.h>
 
 #include "hildon-mapper.h"
 
 #define WINDOW_SIZE_X 800
 #define WINDOW_SIZE_Y 600
 
-GtkWidget *_menu_bar;
-GtkWidget *_toolbar;
+static GtkWidget *menu_bar;
+static GtkWidget *toolbar;
 GtkWidget *_fix_banner=NULL;
 
+static GtkActionGroup *actions;
+static GtkUIManager *ui;
+
 /**
- * Update all GdkGC objects to reflect the current _draw_width.
+ * Action groups and UI
  */
-#define UPDATE_GC(gc) \
-    gdk_gc_set_line_attributes(gc, \
-            _draw_width, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);
-void update_gcs()
-{
-       gint i;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
-               gdk_color_alloc(gtk_widget_get_colormap(_map_widget),
-                               &_color[i]);
-               if (_gc[i])
-                       g_object_unref(_gc[i]);
-               _gc[i] = gdk_gc_new(_map_pixmap);
-               gdk_gc_set_foreground(_gc[i], &_color[i]);
-               gdk_gc_set_line_attributes(_gc[i],
-                                          _draw_width, GDK_LINE_SOLID,
-                                          GDK_CAP_ROUND, GDK_JOIN_ROUND);
-       }
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
+static const gchar *mapper_ui =
+"<ui>"
+"  <menubar name='MenuBar'>"
+"    <menu action='file'>"
+"      <menuitem action='file_settings'/>"
+"      <menuitem action='file_help'/>"
+"      <menuitem action='file_about'/>"
+"      <separator/>"
+"      <menuitem action='file_quit'/>"
+"    </menu>"
+"    <menu action='map' name='map'>"
+"      <menu action='map_maps' name='map_maps'>"
+"         <placeholder />"
+"      </menu>"
+"      <separator/>"
+"      <menuitem action='map_manager'/>"
+"      <menuitem action='map_repositories'/>"
+"      <separator/>"
+"      <menuitem action='map_auto_download'/>"
+"      <separator/>"
+"     <menu action='autocenter'>"
+"      <menuitem action='autocenter_latlon'/>"
+"      <menuitem action='autocenter_lead'/>"
+"      <menuitem action='autocenter_none'/>"
+"     </menu>"
+"    </menu>"
+"    <menu action='track'>"
+"      <menuitem action='track_open'/>"
+"      <menuitem action='track_save'/>"
+"      <menuitem action='track_clear'/>"
+"      <separator/>"
+"      <menuitem action='track_insert_break'/>"
+"      <menuitem action='track_insert_mark'/>"
+"      <separator/>"
+"      <menuitem action='track_dist_last_mark'/>"
+"      <menuitem action='track_dist_first'/>"
+"      <separator/>"
+"      <menuitem action='track_filter'/>"
+"    </menu>"
+"    <menu action='route'>"
+"      <menuitem action='route_open'/>"
+"      <menuitem action='route_save'/>"
+"      <menuitem action='route_download'/>"
+"      <separator/>"
+"      <menuitem action='route_dist_next'/>"
+"      <menuitem action='route_dist_last'/>"
+"      <separator/>"
+"      <menuitem action='route_reset'/>"
+"      <menuitem action='route_clear'/>"
+"    </menu>"
+"    <menu action='poi'>"
+"      <menuitem action='poi_categories'/>"
+"      <separator/>"
+"      <menuitem action='poi_settings'/>"
+"    </menu>"
+"    <menu action='view'>"
+"      <menuitem action='view_zoom_in'/>"
+"      <menuitem action='view_zoom_out'/>"
+"      <menuitem action='view_zoom_normal'/>"
+"      <menuitem action='view_zoom_auto'/>"
+"      <separator/>"
+"      <menuitem action='view_fullscreen'/>"
+"      <separator/>"
+"      <menu action='view_items'>"
+"       <menuitem action='view_scale'/>"
+"       <menuitem action='view_route'/>"
+"       <menuitem action='view_track'/>"
+"       <menuitem action='view_vector'/>"
+"       <menuitem action='view_poi'/>"
+"      </menu>"
+"    </menu>"
+"    <menu action='goto'>"
+"      <menuitem action='goto_home'/>"
+"      <menuitem action='goto_destination'/>"
+"      <menuitem action='goto_gps'/>"
+"      <menuitem action='goto_address'/>"
+"      <menuitem action='goto_latlon'/>"
+"      <menuitem action='goto_nextway'/>"
+"      <menuitem action='goto_nearpoi'/>"
+"      <separator/>"
+"    </menu>"
+"    <menu action='gps'>"
+"      <menuitem action='gps_enabled'/>"
+"      <menuitem action='gps_information'/>"
+"      <separator/>"
+"      <menuitem action='gps_details'/>"
+"      <separator/>"
+"      <menuitem action='gps_settings'/>"
+"    </menu>"
+"  </menubar>"
+"  <toolbar name='ToolBar'>"
+"    <toolitem action='goto_home'/>"
+"    <toolitem action='goto_destination'/>"
+"    <toolitem action='goto_gps'/>"
+"    <separator/>"
+"    <toolitem action='poi_add'/>"
+"    <toolitem action='poi_quick_add'/>"
+"    <toolitem action='poi_search'/>"
+"    <separator/>"
+"    <toolitem action='view_fullscreen'/>"
+"    <separator/>"
+"    <toolitem action='view_zoom_in'/>"
+"    <toolitem action='view_zoom_out'/>"
+"    <toolitem action='view_zoom_normal'/>"
+"    <toolitem action='view_zoom_auto'/>"
+"    <separator/>"
+"  </toolbar>"
+"</ui>";
+
+static GtkActionEntry ui_entries[] = {
+       {"file", NULL, N_("_File"), NULL, NULL, NULL },
+       {"file_settings", GTK_STOCK_PREFERENCES, N_("_Settings..."), NULL, NULL, G_CALLBACK(menu_cb_settings) },
+       {"file_help", GTK_STOCK_HELP, N_("_Help"), NULL, NULL, G_CALLBACK(menu_cb_help) },
+       {"file_about", GTK_STOCK_ABOUT, N_("_About"), "<control>A", NULL, G_CALLBACK(menu_cb_about) },
+       {"file_quit", GTK_STOCK_QUIT, N_("_Quit"), "<control>Q", NULL, G_CALLBACK(gtk_main_quit) },
+
+       {"track", NULL, N_("_Track"), NULL, NULL, NULL },
+       {"track_open", GTK_STOCK_OPEN, N_("_Open..."), NULL, NULL, G_CALLBACK(menu_cb_track_open) },
+       {"track_save", GTK_STOCK_SAVE, N_("_Save..."), NULL, NULL, G_CALLBACK(menu_cb_track_save) },
+       {"track_clear", GTK_STOCK_CLEAR, N_("_Clear"), NULL, NULL, G_CALLBACK(menu_cb_track_clear) },
+       {"track_insert_break", NULL, N_("Insert Break"), NULL, NULL, G_CALLBACK(menu_cb_track_insert_break) },
+       {"track_insert_mark", NULL, N_("Insert Mark..."), NULL, NULL, G_CALLBACK(menu_cb_track_insert_mark) },
+       {"track_dist_last_mark", NULL, N_("Distance to last mark"), NULL, NULL, G_CALLBACK(menu_cb_track_distlast) },
+       {"track_dist_first", NULL, N_("Distance from first"), NULL, NULL, G_CALLBACK(menu_cb_track_distfirst) },
+       {"track_filter", NULL, N_("_Filter..."), NULL, NULL, G_CALLBACK(menu_cb_track_filter) },
+
+       {"route", NULL, N_("_Route"), NULL, NULL, NULL },
+       {"route_open", GTK_STOCK_OPEN, N_("Open..."), NULL, NULL, G_CALLBACK(menu_cb_route_open) },
+       {"route_save", GTK_STOCK_SAVE, N_("Save..."), NULL, NULL, G_CALLBACK(menu_cb_route_save) },
+       {"route_download", NULL, N_("Do_wnload..."), NULL, NULL, G_CALLBACK(menu_cb_route_download)},
+       {"route_reset", NULL, N_("Reset"), NULL, NULL, G_CALLBACK(menu_cb_route_reset) },
+       {"route_clear", GTK_STOCK_CLEAR, N_("Clear"), NULL, NULL, G_CALLBACK(menu_cb_route_clear) },
+       {"route_dist_next", NULL, N_("Show Distance to Next Waypoint"), NULL, NULL, G_CALLBACK(menu_cb_route_distnext) },
+       {"route_dist_last", NULL, N_("Show Distance to End of Route"), NULL, NULL, G_CALLBACK(menu_cb_route_distlast) },
+
+       {"poi", NULL, N_("_Poi"), NULL, NULL, NULL },
+       {"poi_categories", GTK_STOCK_INDEX, N_("_Categories"), NULL, NULL, G_CALLBACK(menu_cb_category) },
+       {"poi_settings", GTK_STOCK_PREFERENCES, N_("_Settings..."), NULL, NULL, NULL },
+       {"poi_add", GTK_STOCK_ADD, N_("Add"), NULL, NULL, G_CALLBACK(cb_add_poi) },
+       {"poi_quick_add", GTK_STOCK_ABOUT, N_("Quick Add"), NULL, NULL, G_CALLBACK(cb_add_poi) },
+       {"poi_search", GTK_STOCK_FIND, N_("Search"), NULL, NULL, NULL },
+
+       {"map", NULL, N_("_Map"), NULL, NULL, NULL },
+       {"map_maps", NULL, N_("_Maps"), NULL, NULL, NULL },
+       {"map_manager", NULL, N_("Manager..."), NULL, NULL, G_CALLBACK(menu_cb_mapman) },
+       {"map_repositories", NULL, N_("Repositories..."), NULL, NULL, G_CALLBACK(menu_cb_maps_repoman) },
+       {"autocenter", NULL, N_("Autocenter"), NULL, NULL, NULL },
+
+       {"view", NULL, N_("_View"), NULL, NULL, NULL },
+       {"view_zoom_in", GTK_STOCK_ZOOM_IN, N_("Zoom in"), NULL, NULL, G_CALLBACK(cb_zoomin) },
+       {"view_zoom_out", GTK_STOCK_ZOOM_OUT, N_("Zoom out"), NULL, NULL, G_CALLBACK(cb_zoomout) },
+       {"view_zoom_normal", GTK_STOCK_ZOOM_100, N_("Zoom normal"), NULL, NULL, G_CALLBACK(cb_zoom_base) },
+
+       {"view_items", NULL, N_("Features"), NULL, NULL, NULL },
+
+       {"goto", NULL, N_("_Go to"), NULL, NULL, NULL },
+       {"goto_home", GTK_STOCK_HOME, N_("_Home"), NULL, NULL, G_CALLBACK(menu_cb_goto_home) },
+       {"goto_destination", GTK_STOCK_JUMP_TO, N_("_Destination"), NULL, NULL, G_CALLBACK(menu_cb_goto_destination) },
+       {"goto_gps", NULL, N_("_GPS"), NULL, NULL, G_CALLBACK(menu_cb_goto_gps) },
+       {"goto_address", GTK_STOCK_FIND, N_("Address..."), NULL, NULL, NULL },
+       {"goto_latlon", NULL, N_("Lat/Lon"), NULL, NULL, G_CALLBACK(menu_cb_goto_latlon) },
+       {"goto_nextway", NULL, N_("Next Waypoint"), NULL, NULL, G_CALLBACK(menu_cb_goto_nextway) },
+       {"goto_nearpoi", NULL, N_("Near POI"), NULL, NULL, G_CALLBACK(menu_cb_goto_nearpoi) },
+
+       {"gps", NULL, N_("_GPS"), NULL, NULL, NULL },
+       {"gps_details", GTK_STOCK_INFO, N_("_Details..."), NULL, NULL, G_CALLBACK(menu_cb_gps_details) },
+       {"gps_settings", NULL, N_("Settings..."), NULL, NULL, NULL },
+};
+static guint n_ui_entries = G_N_ELEMENTS (ui_entries);
+
+static GtkToggleActionEntry ui_toggle_entries[] = {
+       {"map_auto_download", NULL, N_("Auto download"), NULL, NULL, G_CALLBACK(menu_cb_auto_download), FALSE},
+       {"view_zoom_auto", GTK_STOCK_ZOOM_FIT, N_("AutoZoom"), NULL, NULL, G_CALLBACK(cb_zoom_auto), FALSE},
+       {"gps_enabled", GTK_STOCK_CONNECT, N_("Enabled"), NULL, NULL, G_CALLBACK(menu_cb_enable_gps), FALSE},
+       {"gps_information", GTK_STOCK_INFO, N_("Panel"), NULL, NULL, G_CALLBACK (menu_cb_gps_show_info), FALSE},
+       {"view_fullscreen", GTK_STOCK_FULLSCREEN, N_("Fullscreen"), NULL, NULL, G_CALLBACK(cb_fullscreen), FALSE },
+       {"view_scale", NULL, N_("Scale"), NULL, NULL, G_CALLBACK(menu_cb_show_scale) , TRUE },
+       {"view_route", NULL, N_("Route"), NULL, NULL, G_CALLBACK(menu_cb_show_routes), TRUE },
+       {"view_track", NULL, N_("Track"), NULL, NULL, G_CALLBACK(menu_cb_show_tracks), TRUE },
+       {"view_vector", NULL, N_("Vector"), NULL, NULL, G_CALLBACK(menu_cb_show_velvec), TRUE },
+       {"view_poi", NULL, N_("POIs"), NULL, NULL, G_CALLBACK(menu_cb_show_poi), TRUE },
+};
+static guint n_ui_toggle_entries = G_N_ELEMENTS (ui_toggle_entries);
+
+static GtkRadioActionEntry ui_autocenter_entries[] = {
+  { "autocenter_latlon", NULL, "Lat/Lon", NULL, NULL, CENTER_LATLON },
+  { "autocenter_lead", NULL, "Lead", NULL, NULL, CENTER_LEAD },
+  { "autocenter_none", NULL, "None", NULL, NULL, CENTER_MANUAL },
+};
+static guint n_ui_autocenter_entries = G_N_ELEMENTS (ui_autocenter_entries);
+
+/************************************************************************************/
 
 #ifdef WITH_HILDON
 void force_min_visible_bars(HildonControlbar * control_bar, gint num_bars)
 {
-       GValue val;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       memset(&val, 0, sizeof(val));
-       g_value_init(&val, G_TYPE_INT);
-       g_value_set_int(&val, num_bars);
-       g_object_set_property(G_OBJECT(control_bar), "minimum-visible-bars",
-                             &val);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+GValue val;
+memset(&val, 0, sizeof(val));
+g_value_init(&val, G_TYPE_INT);
+g_value_set_int(&val, num_bars);
+g_object_set_property(G_OBJECT(control_bar), "minimum-visible-bars", &val);
 }
 #else
 void force_min_visible_bars(void *a, gint b)
@@ -95,90 +261,62 @@ void force_min_visible_bars(void *a, gint b)
 /**
  * Pop up a modal dialog box with simple error information in it.
  */
-void popup_error(GtkWidget * window, const gchar * error)
+void 
+popup_error(GtkWidget * window, const gchar * error)
 {
-       GtkWidget *dialog;
-       printf("%s(\"%s\")\n", __PRETTY_FUNCTION__, error);
-
-       dialog = hildon_note_new_information(GTK_WINDOW(window), error);
+GtkWidget *dialog;
 
-       gtk_dialog_run(GTK_DIALOG(dialog));
-       gtk_widget_destroy(dialog);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+#ifdef WITH_HILDON
+dialog = hildon_note_new_information(GTK_WINDOW(window), error);
+#else
+dialog = gtk_message_dialog_new (GTK_WINDOW(window),
+       GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+       GTK_MESSAGE_INFO, GTK_BUTTONS_OK, error);
+#endif
+gtk_dialog_run(GTK_DIALOG(dialog));
+gtk_widget_destroy(dialog);
 }
 
-void menu_maps_remove_repos()
+void
+menu_maps_remove_repos()
 {
-       GList *curr;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GList *curr;
 
-       /* Delete one menu item for each repo. */
-       for (curr = _repo_list; curr; curr = curr->next) {
-               gtk_widget_destroy(gtk_container_get_children
-                                  (GTK_CONTAINER(_menu_maps_submenu))->data);
-       }
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+/* Delete one menu item for each repo. */
+for (curr = _repo_list; curr; curr = curr->next) {
+       gtk_widget_destroy(gtk_container_get_children(GTK_CONTAINER(_menu_maps_submenu))->data);
+}
 }
 
-void menu_maps_add_repos()
+void 
+menu_maps_add_repos(GtkWidget *map_menu)
 {
-       GList *curr;
-       GtkWidget *last_repo = NULL;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       for (curr = g_list_last(_repo_list); curr; curr = curr->prev) {
-               RepoData *rd = (RepoData *) curr->data;
-               GtkWidget *menu_item;
-               if (last_repo)
-                       gtk_menu_prepend(_menu_maps_submenu, menu_item
-                                        =
-                                        gtk_radio_menu_item_new_with_label_from_widget
-                                        (GTK_RADIO_MENU_ITEM(last_repo),
-                                         rd->name));
-               else {
-                       gtk_menu_prepend(_menu_maps_submenu, menu_item
-                                        =
-                                        gtk_radio_menu_item_new_with_label
-                                        (NULL, rd->name));
-                       last_repo = menu_item;
-               }
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item),
-                                              rd == _curr_repo);
-               rd->menu_item = menu_item;
-       }
+GList *curr;
+GtkWidget *last_repo = NULL;
 
-       /* Add signals (must be after entire menu is built). */
-       {
-               GList *currmi =
-                   gtk_container_get_children(GTK_CONTAINER
-                                              (_menu_maps_submenu));
-               for (curr = _repo_list; curr;
-                    curr = curr->next, currmi = currmi->next) {
-                       g_signal_connect(G_OBJECT(currmi->data), "activate",
-                                        G_CALLBACK(menu_cb_maps_select),
-                                        curr->data);
-               }
-       }
+for (curr = g_list_last(_repo_list); curr; curr = curr->prev) {
+       RepoData *rd = (RepoData *) curr->data;
+       GtkWidget *menu_item;
 
-       gtk_widget_show_all(_menu_maps_submenu);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+       if (last_repo) {
+               gtk_menu_prepend(map_menu, menu_item = gtk_radio_menu_item_new_with_label_from_widget(GTK_RADIO_MENU_ITEM(last_repo), rd->name));
+       } else {
+               gtk_menu_prepend(map_menu, menu_item = gtk_radio_menu_item_new_with_label(NULL, rd->name));
+               last_repo = menu_item;
+       }
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), rd == _curr_repo);
+       rd->menu_item = menu_item;
 }
 
-/**
- * Free a ProgressUpdateInfo data structure that was allocated during the
- * auto-map-download process.
- */
-void progress_update_info_free(ProgressUpdateInfo * pui)
+/* Add signals (must be after entire menu is built). */
 {
-       vprintf("%s()\n", __PRETTY_FUNCTION__);
-
-       g_free(pui->src_str);
-       g_free(pui->dest_str);
-
-       g_slice_free(ProgressUpdateInfo, pui);
+       GList *currmi = gtk_container_get_children(GTK_CONTAINER(_menu_maps_submenu));
+       for (curr = _repo_list; curr; curr = curr->next, currmi = currmi->next) {
+               g_signal_connect(G_OBJECT(currmi->data), "activate", G_CALLBACK(menu_cb_maps_select), curr->data);
+       }
+}
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+gtk_widget_show_all(map_menu);
 }
 
 /**
@@ -186,1008 +324,530 @@ void progress_update_info_free(ProgressUpdateInfo * pui)
  * configuration and brings up the Settings dialog if the GPS Receiver is
  * not set up, the first time it is called.
  */
-gboolean window_present()
+gboolean 
+window_present()
 {
-       static gint been_here = 0;
-       static gint done_here = 0;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (!been_here++) {
-               /* Set connection state first, to avoid going into this if twice. */
-               if (!_rcvr_mac && _enable_gps) {
-                       GtkWidget *confirm;
-
-                       gtk_window_present(GTK_WINDOW(_window));
-
-                       popup_error(_window, _("It looks like this is your first time running "
-                                                         "Mapper. Press OK to continue."));
-
-                       if (settings_dialog()) {
-                               popup_error(_window,
-                                           _("OpenStreetMap.org provides public, free-to-use maps.  "
-                                            "You can also download a sample set of repositories from "
-                                            " the internet by using the \"Download...\" button."));
-                               repoman_dialog();
-                               if (_curr_repo->type != REPOTYPE_NONE) {
-                                       confirm = hildon_note_new_confirmation
-                                           (GTK_WINDOW(_window),
+static gint been_here = 0;
+static gint done_here = 0;
+
+if (!been_here++) {
+       /* Set connection state first, to avoid going into this if twice. */
+       if (!_rcvr_mac && _enable_gps) {
+               GtkWidget *confirm;
+
+               gtk_window_present(GTK_WINDOW(_window));
+               popup_error(_window, _("It looks like this is your first time running "
+                                                 "Mapper. Press OK to continue."));
+
+               if (settings_dialog()) {
+                       popup_error(_window,
+                                  _("OpenStreetMap.org provides public, free-to-use maps.  "
+                                    "You can also download a sample set of repositories from "
+                                    " the internet by using the \"Download...\" button."));
+                       repoman_dialog();
+                       if (_curr_repo->type != REPOTYPE_NONE) {
+                               confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
                                             _("You will now see a blank screen.  You can download"
                                              " maps using the \"Manage Maps\" menu item in the"
                                              " \"Maps\" menu.  Or, press OK to enable"
                                              " Auto-Download."));
-                                       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
-                                               gtk_check_menu_item_set_active
-                                                   (GTK_CHECK_MENU_ITEM
-                                                    (_menu_auto_download_item),
-                                                    TRUE);
-                                       }
-                                       gtk_widget_destroy(confirm);
+                               if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+                                       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_auto_download_item), TRUE);
                                }
-                       } else
-                               gtk_main_quit();
+                               gtk_widget_destroy(confirm);
+                       }
+               } else {
+                       gtk_main_quit();
                }
-               /* Connect to receiver. */
-               if (_enable_gps)
-                       rcvr_connect_now();
-
-               done_here++;    /* Don't ask... */
        }
-       if (done_here) {
-               gtk_window_present(GTK_WINDOW(_window));
+       /* Connect to receiver. */
+       if (_enable_gps)
+               rcvr_connect_now();
 
-               /* Re-enable any banners that might have been up. */
-               {
-                       ConnState old_state = _conn_state;
-                       set_conn_state(RCVR_OFF);
-                       set_conn_state(old_state);
-               }
+       done_here++;    /* Don't ask... */
+}
+if (done_here) {
+       gtk_window_present(GTK_WINDOW(_window));
+
+       /* Re-enable any banners that might have been up. */
+       {
+               ConnState old_state = _conn_state;
+               set_conn_state(RCVR_OFF);
+               set_conn_state(old_state);
        }
+}
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return FALSE;
+return FALSE;
 }
 
-/**
- * Create the menu items needed for the drop down menu.
- */
-static void menu_init()
+static void 
+menu_init_cmenu()
 {
-       /* Create needed handles. */
-       GtkMenu *menu;
-       GtkWidget *submenu_routes;
-       GtkWidget *submenu_track;
-       GtkWidget *submenu;
-       GtkWidget *menu_item;
-       GtkWidget *file_item;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       /* Get the menu of our view. */
-       menu = GTK_MENU(gtk_menu_new());
-
-#ifdef WITH_HILDON
-       hildon_window_set_menu(HILDON_WINDOW(_window), menu);
-#else
-       file_item = gtk_menu_item_new_with_label("File");
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), GTK_WIDGET(menu));
-       gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(file_item));
-#endif
-
-       /* Create the menu items. */
-
-       /* The "Routes" submenu. */
-       menu_item = gtk_menu_item_new_with_label(_("Route"));
-#ifdef WITH_HILDON
-       gtk_menu_append(menu, menu_item);
-#else
-       gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(menu_item));
-#endif
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item),  submenu = gtk_menu_new());
-       gtk_menu_append(submenu, _menu_route_open_item = gtk_menu_item_new_with_label(_("Open...")));
-       gtk_menu_append(submenu, _menu_route_download_item = gtk_menu_item_new_with_label(_("Download...")));
-       gtk_menu_append(submenu, _menu_route_save_item = gtk_menu_item_new_with_label(_("Save...")));
-       gtk_menu_append(submenu, _menu_route_distnext_item = gtk_menu_item_new_with_label(_("Show Distance to Next Waypoint")));
-       gtk_menu_append(submenu, _menu_route_distlast_item = gtk_menu_item_new_with_label(_("Show Distance to End of Route")));
-       gtk_menu_append(submenu, _menu_route_reset_item = gtk_menu_item_new_with_label(_("Reset")));
-       gtk_menu_append(submenu, _menu_route_clear_item = gtk_menu_item_new_with_label(_("Clear")));
-
-       /* The "Track" submenu. */
-       menu_item = gtk_menu_item_new_with_label(_("Track"));
-#ifdef WITH_HILDON
-       gtk_menu_append(menu, menu_item);
-#else
-       gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(menu_item));
-#endif
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
-       gtk_menu_append(submenu, _menu_track_open_item = gtk_menu_item_new_with_label(_("Open...")));
-       gtk_menu_append(submenu, _menu_track_save_item = gtk_menu_item_new_with_label(_("Save...")));
-       gtk_menu_append(submenu, _menu_track_insert_break_item = gtk_menu_item_new_with_label(_("Insert Break")));
-       gtk_menu_append(submenu, _menu_track_insert_mark_item = gtk_menu_item_new_with_label(_("Insert Mark...")));
-       gtk_menu_append(submenu, _menu_track_distlast_item = gtk_menu_item_new_with_label(_("Show Distance from Last Mark")));
-       gtk_menu_append(submenu, _menu_track_distfirst_item = gtk_menu_item_new_with_label(_("Show Distance from Beginning")));
-       gtk_menu_append(submenu, _menu_track_clear_item = gtk_menu_item_new_with_label(_("Clear")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _menu_track_filter = gtk_menu_item_new_with_label(_("Filter...")));
-
-       /* The "Maps" submenu. */
-       menu_item = gtk_menu_item_new_with_label(_("Maps"));
-#ifdef WITH_HILDON
-       gtk_menu_append(menu, menu_item);
-#else
-       gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(menu_item));
-#endif
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), _menu_maps_submenu = gtk_menu_new());
-       gtk_menu_append(_menu_maps_submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(_menu_maps_submenu, _menu_maps_mapman_item = gtk_menu_item_new_with_label(_("Manage Maps...")));
-       gtk_menu_append(_menu_maps_submenu, _menu_maps_repoman_item     = gtk_menu_item_new_with_label(_("Manage Repositories...")));
-       gtk_menu_append(_menu_maps_submenu, _menu_auto_download_item = gtk_check_menu_item_new_with_label(_("Auto-Download")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_auto_download_item), _auto_download);
-       menu_maps_add_repos(_curr_repo);
-
-       gtk_menu_append(menu, gtk_separator_menu_item_new());
-
-       /* The "View" submenu. */
-       menu_item = gtk_menu_item_new_with_label(_("View"));
-#ifdef WITH_HILDON
-       gtk_menu_append(menu, menu_item);
-#else
-       gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(menu_item));
-#endif
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
-       gtk_menu_append(submenu, _menu_zoomin_item = gtk_menu_item_new_with_label(_("Zoom In")));
-       gtk_menu_append(submenu, _menu_zoomout_item     = gtk_menu_item_new_with_label(_("Zoom Out")));
-       gtk_menu_append(submenu, _menu_fullscreen_item = gtk_check_menu_item_new_with_label(_("Full Screen")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_fullscreen_item), _fullscreen);
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _menu_show_scale_item = gtk_check_menu_item_new_with_label(_("Scale")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_show_scale_item), _show_scale);
-       gtk_menu_append(submenu, _menu_show_routes_item = gtk_check_menu_item_new_with_label(_("Route")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_show_routes_item), _show_tracks & ROUTES_MASK);
-       gtk_menu_append(submenu, _menu_show_tracks_item = gtk_check_menu_item_new_with_label(_("Track")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_show_tracks_item), _show_tracks & TRACKS_MASK);
-       gtk_menu_append(submenu, _menu_show_velvec_item = gtk_check_menu_item_new_with_label(_("Velocity Vector")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_show_velvec_item), _show_velvec);
-       gtk_menu_append(submenu, _menu_show_poi_item = gtk_check_menu_item_new_with_label(_("POIs")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_show_poi_item), _show_poi);
-       gtk_menu_append(submenu, _menu_poi_item = gtk_menu_item_new_with_label(_("POI Categories...")));
-       gtk_widget_set_sensitive(_menu_poi_item, _db != NULL);
-
-       /* The "Auto-Center" submenu. */
-       gtk_menu_append(menu, menu_item = gtk_menu_item_new_with_label(_("Auto-Center")));
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
-       gtk_menu_append(submenu, _menu_ac_latlon_item = gtk_radio_menu_item_new_with_label(NULL, _("Lat/Lon")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_latlon_item), _center_mode == CENTER_LATLON);
-       gtk_menu_append(submenu, _menu_ac_lead_item = gtk_radio_menu_item_new_with_label_from_widget
-                       (GTK_RADIO_MENU_ITEM(_menu_ac_latlon_item), _("Lead")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_lead_item), _center_mode == CENTER_LEAD);
-       gtk_menu_append(submenu, _menu_ac_none_item = gtk_radio_menu_item_new_with_label_from_widget
-                       (GTK_RADIO_MENU_ITEM(_menu_ac_latlon_item), _("None")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_ac_none_item), _center_mode < 0);
-
-       /* The "Go to" submenu. */
-       menu_item = gtk_menu_item_new_with_label(_("Go to"));
-#ifdef WITH_HILDON
-       gtk_menu_append(menu, menu_item);
-#else
-       gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(menu_item));
-#endif
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
-       gtk_menu_append(submenu, _menu_goto_home = gtk_menu_item_new_with_label(_("Home")));
-       gtk_menu_append(submenu, _menu_goto_destination = gtk_menu_item_new_with_label(_("Destination")));
-       gtk_menu_append(submenu, _menu_goto_address = gtk_menu_item_new_with_label(_("Address...")));
-       gtk_menu_append(submenu, _menu_goto_latlon = gtk_menu_item_new_with_label(_("Lat/Lon...")));
-       gtk_menu_append(submenu, _menu_goto_gps = gtk_menu_item_new_with_label(_("GPS Location")));
-       gtk_menu_append(submenu, _menu_goto_nextway     = gtk_menu_item_new_with_label(_("Next Waypoint")));
-       gtk_menu_append(submenu, _menu_goto_nearpoi     = gtk_menu_item_new_with_label(_("Nearest POI")));
-
-       /* The "GPS" submenu. */
-       menu_item = gtk_menu_item_new_with_label(_("GPS"));
-#ifdef WITH_HILDON
-       gtk_menu_append(menu, menu_item);
-#else
-       gtk_menu_bar_append(GTK_MENU_BAR(_menu_bar), GTK_WIDGET(menu_item));
-#endif
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
-       gtk_menu_append(submenu, _menu_enable_gps_item = gtk_check_menu_item_new_with_label(_("Enable GPS")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_enable_gps_item), _enable_gps);
-       gtk_menu_append(submenu, _menu_gps_show_info_item =     gtk_check_menu_item_new_with_label(_("Show Information")));
-       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_menu_gps_show_info_item), _gps_info);
-       gtk_menu_append(submenu, _menu_gps_details_item = gtk_menu_item_new_with_label(_("Details...")));
-       gtk_widget_set_sensitive(GTK_WIDGET(_menu_gps_details_item), _enable_gps);
-       gtk_menu_append(menu, gtk_separator_menu_item_new());
-
-       /* The other menu items. */
-       gtk_menu_append(menu, _menu_settings_item = gtk_menu_item_new_with_label(_("Settings...")));
-       gtk_menu_append(menu, gtk_separator_menu_item_new());
-       gtk_menu_append(menu, _menu_help_item = gtk_menu_item_new_with_label(_("Help...")));
-       gtk_menu_append(menu, _menu_about_item = gtk_menu_item_new_with_label(_("About...")));
-       gtk_menu_append(menu, _menu_close_item = gtk_menu_item_new_with_label(_("Quit")));
-
-       /* We need to show menu items. */
-
-       /* Connect the "Route" signals. */
-       g_signal_connect(G_OBJECT(_menu_route_open_item), "activate",
-                        G_CALLBACK(menu_cb_route_open), NULL);
-       g_signal_connect(G_OBJECT(_menu_route_download_item), "activate",
-                        G_CALLBACK(menu_cb_route_download), NULL);
-       g_signal_connect(G_OBJECT(_menu_route_save_item), "activate",
-                        G_CALLBACK(menu_cb_route_save), NULL);
-       g_signal_connect(G_OBJECT(_menu_route_distnext_item), "activate",
-                        G_CALLBACK(menu_cb_route_distnext), NULL);
-       g_signal_connect(G_OBJECT(_menu_route_distlast_item), "activate",
-                        G_CALLBACK(menu_cb_route_distlast), NULL);
-       g_signal_connect(G_OBJECT(_menu_route_reset_item), "activate",
-                        G_CALLBACK(menu_cb_route_reset), NULL);
-       g_signal_connect(G_OBJECT(_menu_route_clear_item), "activate",
-                        G_CALLBACK(menu_cb_route_clear), NULL);
-
-       /* Connect the "Track" signals. */
-       g_signal_connect(G_OBJECT(_menu_track_open_item), "activate",
-                        G_CALLBACK(menu_cb_track_open), NULL);
-       g_signal_connect(G_OBJECT(_menu_track_save_item), "activate",
-                        G_CALLBACK(menu_cb_track_save), NULL);
-       g_signal_connect(G_OBJECT(_menu_track_insert_break_item), "activate",
-                        G_CALLBACK(menu_cb_track_insert_break), NULL);
-       g_signal_connect(G_OBJECT(_menu_track_insert_mark_item), "activate",
-                        G_CALLBACK(menu_cb_track_insert_mark), NULL);
-       g_signal_connect(G_OBJECT(_menu_track_distlast_item), "activate",
-                        G_CALLBACK(menu_cb_track_distlast), NULL);
-       g_signal_connect(G_OBJECT(_menu_track_distfirst_item), "activate",
-                        G_CALLBACK(menu_cb_track_distfirst), NULL);
-       g_signal_connect(G_OBJECT(_menu_track_clear_item), "activate",
-                        G_CALLBACK(menu_cb_track_clear), NULL);
-       g_signal_connect(G_OBJECT(_menu_track_filter), "activate",
-                        G_CALLBACK(menu_cb_track_filter), NULL);
-
-       /* Connect the "Maps" signals. */
-       g_signal_connect(G_OBJECT(_menu_maps_repoman_item), "activate",
-                        G_CALLBACK(menu_cb_maps_repoman), NULL);
-       g_signal_connect(G_OBJECT(_menu_maps_mapman_item), "activate",
-                        G_CALLBACK(menu_cb_mapman), NULL);
-
-       /* Connect the "View" signals. */
-       g_signal_connect(G_OBJECT(_menu_zoomin_item), "activate",
-                        G_CALLBACK(cb_zoomin), NULL);
-       g_signal_connect(G_OBJECT(_menu_zoomout_item), "activate",
-                        G_CALLBACK(cb_zoomout), NULL);
-       g_signal_connect(G_OBJECT(_menu_fullscreen_item), "toggled",
-                        G_CALLBACK(cb_fullscreen), NULL);
-       g_signal_connect(G_OBJECT(_menu_show_tracks_item), "toggled",
-                        G_CALLBACK(menu_cb_show_tracks), NULL);
-       g_signal_connect(G_OBJECT(_menu_show_scale_item), "toggled",
-                        G_CALLBACK(menu_cb_show_scale), NULL);
-       g_signal_connect(G_OBJECT(_menu_show_routes_item), "toggled",
-                        G_CALLBACK(menu_cb_show_routes), NULL);
-       g_signal_connect(G_OBJECT(_menu_show_velvec_item), "toggled",
-                        G_CALLBACK(menu_cb_show_velvec), NULL);
-       g_signal_connect(G_OBJECT(_menu_show_poi_item), "toggled",
-                        G_CALLBACK(menu_cb_show_poi), NULL);
-       g_signal_connect(G_OBJECT(_menu_poi_item), "activate",
-                        G_CALLBACK(menu_cb_category), NULL);
-
-       /* Connect the "Auto-Center" signals. */
-       g_signal_connect(G_OBJECT(_menu_ac_latlon_item), "toggled",
-                        G_CALLBACK(menu_cb_ac_latlon), NULL);
-       g_signal_connect(G_OBJECT(_menu_ac_lead_item), "toggled",
-                        G_CALLBACK(menu_cb_ac_lead), NULL);
-       g_signal_connect(G_OBJECT(_menu_ac_none_item), "toggled",
-                        G_CALLBACK(menu_cb_ac_none), NULL);
-
-       /* Connect the "Go to" signals. */
-       g_signal_connect(G_OBJECT(_menu_goto_home), "activate",
-                        G_CALLBACK(menu_cb_goto_home), NULL);
-       g_signal_connect(G_OBJECT(_menu_goto_destination), "activate",
-                        G_CALLBACK(menu_cb_goto_destination), NULL);
-       g_signal_connect(G_OBJECT(_menu_goto_latlon), "activate",
-                        G_CALLBACK(menu_cb_goto_latlon), NULL);
-       g_signal_connect(G_OBJECT(_menu_goto_gps), "activate",
-                        G_CALLBACK(menu_cb_goto_gps), NULL);
-       g_signal_connect(G_OBJECT(_menu_goto_nextway), "activate",
-                        G_CALLBACK(menu_cb_goto_nextway), NULL);
-       g_signal_connect(G_OBJECT(_menu_goto_nearpoi), "activate",
-                        G_CALLBACK(menu_cb_goto_nearpoi), NULL);
-
-       /* Connect the "GPS" signals. */
-       g_signal_connect(G_OBJECT(_menu_enable_gps_item), "toggled",
-                        G_CALLBACK(menu_cb_enable_gps), NULL);
-       g_signal_connect(G_OBJECT(_menu_gps_show_info_item), "toggled",
-                        G_CALLBACK(menu_cb_gps_show_info), NULL);
-       g_signal_connect(G_OBJECT(_menu_gps_details_item), "activate",
-                        G_CALLBACK(menu_cb_gps_details), NULL);
-       g_signal_connect(G_OBJECT(_menu_auto_download_item), "toggled",
-                        G_CALLBACK(menu_cb_auto_download), NULL);
-
-       /* Connect the other menu item signals. */
-       g_signal_connect(G_OBJECT(_menu_settings_item), "activate",
-                        G_CALLBACK(menu_cb_settings), NULL);
-       g_signal_connect(G_OBJECT(_menu_help_item), "activate",
-                        G_CALLBACK(menu_cb_help), NULL);
-       g_signal_connect(G_OBJECT(_menu_about_item), "activate",
-                        G_CALLBACK(menu_cb_about), NULL);
-       g_signal_connect(G_OBJECT(_menu_close_item), "activate",
-                        G_CALLBACK(gtk_main_quit), NULL);
-
-       gtk_widget_show_all(GTK_WIDGET(menu));
-#ifndef WITH_HILDON
-       gtk_widget_show_all(GTK_WIDGET(_menu_bar));
-#endif
-
-       /* Setup the context menu. */
-       menu = GTK_MENU(gtk_menu_new());
-
-       /* Setup the map context menu. */
-       gtk_menu_append(menu, menu_item = gtk_menu_item_new_with_label(_("Location")));
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
-
-       /* Setup the map context menu. */
-       gtk_menu_append(submenu, _cmenu_loc_show_latlon_item
-                       = gtk_menu_item_new_with_label(_("Show Lat/Lon")));
-       gtk_menu_append(submenu, _cmenu_loc_clip_latlon_item
-                       = gtk_menu_item_new_with_label(_("Copy Lat/Lon")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_loc_set_destination
-                       = gtk_menu_item_new_with_label(_("Set destination")));
-       gtk_menu_append(submenu, _cmenu_loc_distance_to_item
-                       = gtk_menu_item_new_with_label(_("Show Distance to")));
-       gtk_menu_append(submenu, _cmenu_loc_route_to_item
-                       = gtk_menu_item_new_with_label(_("Download Route to...")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_loc_add_route
-                       = gtk_menu_item_new_with_label(_("Add Route Point")));
-       gtk_menu_append(submenu, _cmenu_loc_add_way
-                       = gtk_menu_item_new_with_label(_("Add Waypoint...")));
-       gtk_menu_append(submenu, _cmenu_loc_add_poi
-                       = gtk_menu_item_new_with_label(_("Add POI...")));
-       gtk_widget_set_sensitive(_cmenu_loc_add_poi, _db != NULL);
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_loc_set_gps =
-                       gtk_menu_item_new_with_label(_("Set as GPS Location")));
-       gtk_menu_append(submenu, _cmenu_loc_set_home =
-                       gtk_menu_item_new_with_label(_("Set as Home Location")));
-
-       /* Setup the waypoint context menu. */
-       gtk_menu_append(menu, menu_item
-                       = gtk_menu_item_new_with_label(_("Waypoint")));
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item),
-                                 submenu = gtk_menu_new());
-
-       gtk_menu_append(submenu, _cmenu_way_show_latlon_item
-                       = gtk_menu_item_new_with_label(_("Show Lat/Lon")));
-       gtk_menu_append(submenu, _cmenu_way_show_desc_item
-                       = gtk_menu_item_new_with_label(_("Show Description")));
-       gtk_menu_append(submenu, _cmenu_way_clip_latlon_item
-                       = gtk_menu_item_new_with_label(_("Copy Lat/Lon")));
-       gtk_menu_append(submenu, _cmenu_way_clip_desc_item
-                       = gtk_menu_item_new_with_label(_("Copy Description")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_way_distance_to_item
-                       = gtk_menu_item_new_with_label(_("Show Distance to")));
-       gtk_menu_append(submenu, _cmenu_way_route_to_item
-                       = gtk_menu_item_new_with_label(_("Download Route to...")));
-       gtk_menu_append(submenu, _cmenu_way_delete_item 
-                       = gtk_menu_item_new_with_label(_("Delete...")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_way_add_poi = gtk_menu_item_new_with_label(_("Add POI...")));
-       gtk_widget_set_sensitive(_cmenu_way_add_poi, _db != NULL);
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_way_goto_nextway = gtk_menu_item_new_with_label(_("Go to Next")));
-
-       /* Setup the POI context menu. */
-       gtk_menu_append(menu, _cmenu_poi = gtk_menu_item_new_with_label(_("POI")));
-       gtk_widget_set_sensitive(_cmenu_poi, _db != NULL);
-       gtk_menu_item_set_submenu(GTK_MENU_ITEM(_cmenu_poi), submenu = gtk_menu_new());
-
-       gtk_menu_append(submenu, _cmenu_poi_edit_poi
-                       = gtk_menu_item_new_with_label(_("View/Edit...")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_poi_distance_to_item
-                       = gtk_menu_item_new_with_label(_("Show Distance to")));
-       gtk_menu_append(submenu, _cmenu_poi_route_to_item
-                       = gtk_menu_item_new_with_label(_("Download Route to...")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_poi_add_route
-                       = gtk_menu_item_new_with_label(_("Add Route Point")));
-       gtk_menu_append(submenu, _cmenu_poi_add_way
-                       = gtk_menu_item_new_with_label(_("Add Waypoint...")));
-       gtk_menu_append(submenu, gtk_separator_menu_item_new());
-       gtk_menu_append(submenu, _cmenu_poi_goto_nearpoi
-                       = gtk_menu_item_new_with_label(_("Go to Nearest")));
-
-       /* Connect signals for context menu. */
-       g_signal_connect(G_OBJECT(_cmenu_loc_show_latlon_item), "activate",
-                        G_CALLBACK(cmenu_cb_loc_show_latlon), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_clip_latlon_item), "activate",
-                        G_CALLBACK(cmenu_cb_loc_clip_latlon), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_route_to_item), "activate",
-                        G_CALLBACK(cmenu_cb_loc_route_to), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_distance_to_item), "activate",
-                        G_CALLBACK(cmenu_cb_loc_distance_to), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_add_route), "activate",
-                        G_CALLBACK(cmenu_cb_loc_add_route), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_add_way), "activate",
-                        G_CALLBACK(cmenu_cb_loc_add_way), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_add_poi), "activate",
-                        G_CALLBACK(cmenu_cb_loc_add_poi), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_set_gps), "activate",
-                        G_CALLBACK(cmenu_cb_loc_set_gps), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_set_home), "activate",
-                        G_CALLBACK(cmenu_cb_loc_set_home), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_loc_set_destination), "activate",
-                        G_CALLBACK(cmenu_cb_loc_set_destination), NULL);
-
-       g_signal_connect(G_OBJECT(_cmenu_way_show_latlon_item), "activate",
-                        G_CALLBACK(cmenu_cb_way_show_latlon), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_show_desc_item), "activate",
-                        G_CALLBACK(cmenu_cb_way_show_desc), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_clip_latlon_item), "activate",
-                        G_CALLBACK(cmenu_cb_way_clip_latlon), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_clip_desc_item), "activate",
-                        G_CALLBACK(cmenu_cb_way_clip_desc), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_route_to_item), "activate",
-                        G_CALLBACK(cmenu_cb_way_route_to), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_distance_to_item), "activate",
-                        G_CALLBACK(cmenu_cb_way_distance_to), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_delete_item), "activate",
-                        G_CALLBACK(cmenu_cb_way_delete), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_add_poi), "activate",
-                        G_CALLBACK(cmenu_cb_way_add_poi), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_way_goto_nextway), "activate",
-                        G_CALLBACK(menu_cb_goto_nextway), NULL);
-
-       g_signal_connect(G_OBJECT(_cmenu_poi_edit_poi), "activate",
-                        G_CALLBACK(cmenu_cb_poi_edit_poi), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_poi_route_to_item), "activate",
-                        G_CALLBACK(cmenu_cb_poi_route_to), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_poi_distance_to_item), "activate",
-                        G_CALLBACK(cmenu_cb_poi_distance_to), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_poi_add_route), "activate",
-                        G_CALLBACK(cmenu_cb_poi_add_route), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_poi_add_way), "activate",
-                        G_CALLBACK(cmenu_cb_poi_add_way), NULL);
-       g_signal_connect(G_OBJECT(_cmenu_poi_goto_nearpoi), "activate",
-                        G_CALLBACK(menu_cb_goto_nearpoi), NULL);
-
-       gtk_widget_show_all(GTK_WIDGET(menu));
+/* Create needed handles. */
+GtkMenu *menu;
+GtkWidget *submenu;
+GtkWidget *menu_item;
+
+/* Setup the context menu. */
+menu = GTK_MENU(gtk_menu_new());
+
+/* Setup the map context menu. */
+gtk_menu_append(menu, menu_item        = gtk_menu_item_new_with_label(_("Location")));
+gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
+
+/* Setup the map context menu. */
+gtk_menu_append(submenu, _cmenu_loc_show_latlon_item= gtk_menu_item_new_with_label(_("Show Lat/Lon")));
+gtk_menu_append(submenu, _cmenu_loc_clip_latlon_item = gtk_menu_item_new_with_label(_("Copy Lat/Lon")));
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_loc_distance_to_item = gtk_menu_item_new_with_label(_("Show Distance to")));
+gtk_menu_append(submenu, _cmenu_loc_route_to_item= gtk_menu_item_new_with_label(_("Download Route to...")));
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_loc_add_route= gtk_menu_item_new_with_label(_("Add Route Point")));
+gtk_menu_append(submenu, _cmenu_loc_add_way    = gtk_menu_item_new_with_label(_("Add Waypoint...")));
+gtk_widget_set_sensitive(_cmenu_loc_add_poi, _db != NULL);
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_loc_set_gps = gtk_menu_item_new_with_label(_("Set as GPS Location")));
+gtk_menu_append(submenu, _cmenu_loc_set_home = gtk_menu_item_new_with_label(_("Set as Home Location")));
+gtk_menu_append(submenu, _cmenu_loc_set_destination    = gtk_menu_item_new_with_label(_("Set as Destination")));
+
+/* Setup the waypoint context menu. */
+gtk_menu_append(menu, menu_item = gtk_menu_item_new_with_label(_("Waypoint")));
+gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_item), submenu = gtk_menu_new());
+
+gtk_menu_append(submenu, _cmenu_way_show_latlon_item = gtk_menu_item_new_with_label(_("Show Lat/Lon")));
+gtk_menu_append(submenu, _cmenu_way_show_desc_item = gtk_menu_item_new_with_label(_("Show Description")));
+gtk_menu_append(submenu, _cmenu_way_clip_latlon_item = gtk_menu_item_new_with_label(_("Copy Lat/Lon")));
+gtk_menu_append(submenu, _cmenu_way_clip_desc_item = gtk_menu_item_new_with_label(_("Copy Description")));
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_way_distance_to_item = gtk_menu_item_new_with_label(_("Show Distance to")));
+gtk_menu_append(submenu, _cmenu_way_route_to_item = gtk_menu_item_new_with_label(_("Download Route to...")));
+gtk_menu_append(submenu, _cmenu_way_delete_item = gtk_menu_item_new_with_label(_("Delete...")));
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_way_add_poi = gtk_menu_item_new_with_label(_("Add POI...")));
+gtk_widget_set_sensitive(_cmenu_way_add_poi, _db != NULL);
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_way_goto_nextway = gtk_menu_item_new_with_label(_("Go to Next")));
+
+/* Setup the POI context menu. */
+gtk_menu_append(menu, _cmenu_poi = gtk_menu_item_new_with_label(_("POI")));
+gtk_widget_set_sensitive(_cmenu_poi, _db != NULL);
+gtk_menu_item_set_submenu(GTK_MENU_ITEM(_cmenu_poi), submenu = gtk_menu_new());
+
+gtk_menu_append(submenu, _cmenu_loc_add_poi    = gtk_menu_item_new_with_label(_("Add POI...")));
+gtk_menu_append(submenu, _cmenu_poi_edit_poi = gtk_menu_item_new_with_label(_("View/Edit...")));
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_poi_distance_to_item = gtk_menu_item_new_with_label(_("Show Distance to")));
+gtk_menu_append(submenu, _cmenu_poi_route_to_item = gtk_menu_item_new_with_label(_("Download Route to...")));
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_poi_add_route = gtk_menu_item_new_with_label(_("Add Route Point")));
+gtk_menu_append(submenu, _cmenu_poi_add_way    = gtk_menu_item_new_with_label(_("Add Waypoint...")));
+gtk_menu_append(submenu, gtk_separator_menu_item_new());
+gtk_menu_append(submenu, _cmenu_poi_goto_nearpoi = gtk_menu_item_new_with_label(_("Go to Nearest")));
+
+/* Connect signals for context menu. */
+g_signal_connect(G_OBJECT(_cmenu_loc_show_latlon_item), "activate", G_CALLBACK(cmenu_cb_loc_show_latlon), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_clip_latlon_item), "activate", G_CALLBACK(cmenu_cb_loc_clip_latlon), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_route_to_item), "activate", G_CALLBACK(cmenu_cb_loc_route_to), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_distance_to_item), "activate", G_CALLBACK(cmenu_cb_loc_distance_to), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_add_route), "activate", G_CALLBACK(cmenu_cb_loc_add_route), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_add_way), "activate", G_CALLBACK(cmenu_cb_loc_add_way), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_add_poi), "activate", G_CALLBACK(cmenu_cb_loc_add_poi), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_set_gps), "activate", G_CALLBACK(cmenu_cb_loc_set_gps), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_set_home), "activate", G_CALLBACK(cmenu_cb_loc_set_home), NULL);
+g_signal_connect(G_OBJECT(_cmenu_loc_set_destination), "activate", G_CALLBACK(cmenu_cb_loc_set_destination), NULL);
+
+g_signal_connect(G_OBJECT(_cmenu_way_show_latlon_item), "activate", G_CALLBACK(cmenu_cb_way_show_latlon), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_show_desc_item), "activate", G_CALLBACK(cmenu_cb_way_show_desc), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_clip_latlon_item), "activate", G_CALLBACK(cmenu_cb_way_clip_latlon), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_clip_desc_item), "activate", G_CALLBACK(cmenu_cb_way_clip_desc), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_route_to_item), "activate", G_CALLBACK(cmenu_cb_way_route_to), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_distance_to_item), "activate", G_CALLBACK(cmenu_cb_way_distance_to), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_delete_item), "activate", G_CALLBACK(cmenu_cb_way_delete), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_add_poi), "activate", G_CALLBACK(cmenu_cb_way_add_poi), NULL);
+g_signal_connect(G_OBJECT(_cmenu_way_goto_nextway), "activate", G_CALLBACK(menu_cb_goto_nextway), NULL);
+
+g_signal_connect(G_OBJECT(_cmenu_poi_edit_poi), "activate", G_CALLBACK(cmenu_cb_poi_edit_poi), NULL);
+g_signal_connect(G_OBJECT(_cmenu_poi_route_to_item), "activate", G_CALLBACK(cmenu_cb_poi_route_to), NULL);
+g_signal_connect(G_OBJECT(_cmenu_poi_distance_to_item), "activate", G_CALLBACK(cmenu_cb_poi_distance_to), NULL);
+g_signal_connect(G_OBJECT(_cmenu_poi_add_route), "activate", G_CALLBACK(cmenu_cb_poi_add_route), NULL);
+g_signal_connect(G_OBJECT(_cmenu_poi_add_way), "activate", G_CALLBACK(cmenu_cb_poi_add_way), NULL);
+g_signal_connect(G_OBJECT(_cmenu_poi_goto_nearpoi), "activate", G_CALLBACK(menu_cb_goto_nearpoi), NULL);
+
+gtk_widget_show_all(GTK_WIDGET(menu));
 
 #ifdef WITH_DEVICE_770
-       gtk_widget_tap_and_hold_setup(_map_widget, GTK_WIDGET(menu), NULL, 0);
+gtk_widget_tap_and_hold_setup(_map_widget, GTK_WIDGET(menu), NULL, 0);
 #else
-       _menu_map = menu;
+_menu_map = menu;
 #endif
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
 }
 
-static void toolbar_init(void)
+static void 
+toolbar_progress_init(void)
 {
 GtkToolItem *item;
 
-item = gtk_tool_button_new_from_stock (GTK_STOCK_HOME);
-g_signal_connect (item, "clicked", G_CALLBACK (menu_cb_goto_home), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_JUMP_TO);
-g_signal_connect (item, "clicked", G_CALLBACK (menu_cb_goto_gps), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD);
-g_signal_connect (item, "clicked", G_CALLBACK (menu_cb_goto_nextway), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_separator_tool_item_new();
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_ADD);
-g_signal_connect (item, "clicked", G_CALLBACK (cb_add_poi), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-#ifndef GTK_STOCK_INFO
-#define GTK_STOCK_INFO GTK_STOCK_PROPERTIES
-#endif
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_INFO);
-g_signal_connect (item, "clicked", G_CALLBACK (menu_cb_gps_details), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_separator_tool_item_new();
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_IN);
-g_signal_connect (item, "clicked", G_CALLBACK (cb_zoomin), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
-g_signal_connect (item, "clicked", G_CALLBACK (cb_zoomout), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_100);
-g_signal_connect (item, "clicked", G_CALLBACK (cb_zoom_base), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_tool_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
-g_signal_connect (item, "clicked", G_CALLBACK (cb_zoom_autozoom), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-item = gtk_separator_tool_item_new();
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
-#ifndef WITH_HILDON
-_toolbar_fullscreen_item = gtk_toggle_tool_button_new_from_stock (GTK_STOCK_FULLSCREEN);
-g_signal_connect (_toolbar_fullscreen_item, "clicked", G_CALLBACK (cb_fullscreen_click), NULL);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), _toolbar_fullscreen_item, -1);
-#endif
-
-item=gtk_separator_tool_item_new();
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
-
 item=gtk_tool_item_new();
 _progress_item=gtk_progress_bar_new();
 gtk_container_add(item, _progress_item);
-gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
+gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
 }
 
-void mapper_init_variables(void)
+void 
+mapper_init_variables(void)
 {
-       /* Set enum-based constants. */
-       UNITS_TEXT[UNITS_KM] = _("km");
-       UNITS_TEXT[UNITS_MI] = _("mi.");
-       UNITS_TEXT[UNITS_NM] = _("n.m.");
-
-       INFO_FONT_TEXT[INFO_FONT_XXSMALL] = "xx-small";
-       INFO_FONT_TEXT[INFO_FONT_XSMALL] = "x-small";
-       INFO_FONT_TEXT[INFO_FONT_SMALL] = "small";
-       INFO_FONT_TEXT[INFO_FONT_MEDIUM] = "medium";
-       INFO_FONT_TEXT[INFO_FONT_LARGE] = "large";
-       INFO_FONT_TEXT[INFO_FONT_XLARGE] = "x-large";
-       INFO_FONT_TEXT[INFO_FONT_XXLARGE] = "xx-large";
-
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_UP] = GCONF_KEY_PREFIX "/key_up";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_DOWN] = GCONF_KEY_PREFIX "/key_down";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_LEFT] = GCONF_KEY_PREFIX "/key_left";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_RIGHT] = GCONF_KEY_PREFIX "/key_right";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_SELECT] = GCONF_KEY_PREFIX "/key_select";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_INCREASE] = GCONF_KEY_PREFIX "/key_increase";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_DECREASE] = GCONF_KEY_PREFIX "/key_decrease";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_FULLSCREEN] = GCONF_KEY_PREFIX "/key_fullscreen";
-       CUSTOM_KEY_GCONF[CUSTOM_KEY_ESC] = GCONF_KEY_PREFIX "/key_esc";
-
-       CUSTOM_KEY_ICON[CUSTOM_KEY_UP] = HWK_BUTTON_UP;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_LEFT] = HWK_BUTTON_LEFT;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_DOWN] = HWK_BUTTON_DOWN;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_RIGHT] = HWK_BUTTON_RIGHT;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_SELECT] = HWK_BUTTON_SELECT;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_INCREASE] = HWK_BUTTON_INCREASE;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_DECREASE] = HWK_BUTTON_DECREASE;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_FULLSCREEN] = HWK_BUTTON_VIEW;
-       CUSTOM_KEY_ICON[CUSTOM_KEY_ESC] = HWK_BUTTON_CANCEL;
-
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_UP] = CUSTOM_ACTION_PAN_NORTH;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_LEFT] = CUSTOM_ACTION_PAN_WEST;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_DOWN] = CUSTOM_ACTION_PAN_SOUTH;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_RIGHT] = CUSTOM_ACTION_PAN_EAST;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_SELECT] = CUSTOM_ACTION_TOGGLE_AUTOCENTER;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_INCREASE] = CUSTOM_ACTION_ZOOM_IN;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_DECREASE] = CUSTOM_ACTION_ZOOM_OUT;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_FULLSCREEN] = CUSTOM_ACTION_TOGGLE_FULLSCREEN;
-       CUSTOM_KEY_DEFAULT[CUSTOM_KEY_ESC] = CUSTOM_ACTION_TOGGLE_TRACKS;
-
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_NORTH] = _("Pan North");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_WEST] = _("Pan West");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_SOUTH] = _("Pan South");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_EAST] = _("Pan East");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_AUTOCENTER] = _("Toggle Auto-Center");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_FULLSCREEN] = _("Toggle Fullscreen");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ZOOM_IN] = _("Zoom In");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ZOOM_OUT] = _("Zoom Out");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_TRACKS] = _("Toggle Tracks");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_SCALE] = _("Toggle Scale");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_POI] = _("Toggle POIs");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_CHANGE_REPO] = _("Select Next Repository");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ROUTE_DISTNEXT] = _("Show Distance to Next Waypoint");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ROUTE_DISTLAST] = _("Show Distance to End of Route");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TRACK_BREAK] = _("Insert Track Break");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TRACK_DISTLAST] = _("Show Distance from Last Break");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TRACK_DISTFIRST] = _("Show Distance from Beginning");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_GPS] = _("Toggle GPS");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_GPSINFO] = _("Toggle GPS Info");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_SPEEDLIMIT] = _("Toggle Speed Limit");
-       CUSTOM_ACTION_TEXT[CUSTOM_ACTION_RESET_BLUETOOTH] = _("Reset Bluetooth");
-
-       COLORABLE_GCONF[COLORABLE_MARK] = GCONF_KEY_PREFIX "/color_mark";
-       COLORABLE_GCONF[COLORABLE_MARK_VELOCITY] = GCONF_KEY_PREFIX "/color_mark_velocity";
-       COLORABLE_GCONF[COLORABLE_MARK_OLD] = GCONF_KEY_PREFIX "/color_mark_old";
-       COLORABLE_GCONF[COLORABLE_TRACK] = GCONF_KEY_PREFIX "/color_track";
-       COLORABLE_GCONF[COLORABLE_TRACK_MARK] = GCONF_KEY_PREFIX "/color_track_mark";
-       COLORABLE_GCONF[COLORABLE_TRACK_BREAK] = GCONF_KEY_PREFIX "/color_track_break";
-       COLORABLE_GCONF[COLORABLE_ROUTE] = GCONF_KEY_PREFIX "/color_route";
-       COLORABLE_GCONF[COLORABLE_ROUTE_WAY] = GCONF_KEY_PREFIX "/color_route_way";
-       COLORABLE_GCONF[COLORABLE_ROUTE_BREAK] = GCONF_KEY_PREFIX "/color_route_break";
-       COLORABLE_GCONF[COLORABLE_POI] = GCONF_KEY_PREFIX "/color_poi";
-
-       DEG_FORMAT_TEXT[DDPDDDDD] = "-dd.ddddd°";
-       DEG_FORMAT_TEXT[DD_MMPMMM] = "-dd°mm.mmm'";
-       DEG_FORMAT_TEXT[DD_MM_SSPS] = "-dd°mm'ss.s\"";
-       DEG_FORMAT_TEXT[DDPDDDDD_NSEW] = "dd.ddddd° S";
-       DEG_FORMAT_TEXT[DD_MMPMMM_NSEW] = "dd°mm.mmm' S";
-       DEG_FORMAT_TEXT[DD_MM_SSPS_NSEW] = "dd°mm'ss.s\" S";
-
-       SPEED_LOCATION_TEXT[SPEED_LOCATION_TOP_LEFT] = _("Top-Left");
-       SPEED_LOCATION_TEXT[SPEED_LOCATION_TOP_RIGHT] = _("Top-Right");
-       SPEED_LOCATION_TEXT[SPEED_LOCATION_BOTTOM_RIGHT] = _("Bottom-Right");
-       SPEED_LOCATION_TEXT[SPEED_LOCATION_BOTTOM_LEFT] = _("Bottom-Left");
+UNITS_TEXT[UNITS_KM] = _("km");
+UNITS_TEXT[UNITS_MI] = _("mi.");
+UNITS_TEXT[UNITS_NM] = _("n.m.");
+
+INFO_FONT_TEXT[INFO_FONT_XXSMALL] = "xx-small";
+INFO_FONT_TEXT[INFO_FONT_XSMALL] = "x-small";
+INFO_FONT_TEXT[INFO_FONT_SMALL] = "small";
+INFO_FONT_TEXT[INFO_FONT_MEDIUM] = "medium";
+INFO_FONT_TEXT[INFO_FONT_LARGE] = "large";
+INFO_FONT_TEXT[INFO_FONT_XLARGE] = "x-large";
+INFO_FONT_TEXT[INFO_FONT_XXLARGE] = "xx-large";
+
+CUSTOM_KEY_GCONF[CUSTOM_KEY_UP] = GCONF_KEY_PREFIX "/key_up";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_DOWN] = GCONF_KEY_PREFIX "/key_down";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_LEFT] = GCONF_KEY_PREFIX "/key_left";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_RIGHT] = GCONF_KEY_PREFIX "/key_right";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_SELECT] = GCONF_KEY_PREFIX "/key_select";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_INCREASE] = GCONF_KEY_PREFIX "/key_increase";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_DECREASE] = GCONF_KEY_PREFIX "/key_decrease";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_FULLSCREEN] = GCONF_KEY_PREFIX "/key_fullscreen";
+CUSTOM_KEY_GCONF[CUSTOM_KEY_ESC] = GCONF_KEY_PREFIX "/key_esc";
+
+CUSTOM_KEY_ICON[CUSTOM_KEY_UP] = HWK_BUTTON_UP;
+CUSTOM_KEY_ICON[CUSTOM_KEY_LEFT] = HWK_BUTTON_LEFT;
+CUSTOM_KEY_ICON[CUSTOM_KEY_DOWN] = HWK_BUTTON_DOWN;
+CUSTOM_KEY_ICON[CUSTOM_KEY_RIGHT] = HWK_BUTTON_RIGHT;
+CUSTOM_KEY_ICON[CUSTOM_KEY_SELECT] = HWK_BUTTON_SELECT;
+CUSTOM_KEY_ICON[CUSTOM_KEY_INCREASE] = HWK_BUTTON_INCREASE;
+CUSTOM_KEY_ICON[CUSTOM_KEY_DECREASE] = HWK_BUTTON_DECREASE;
+CUSTOM_KEY_ICON[CUSTOM_KEY_FULLSCREEN] = HWK_BUTTON_VIEW;
+CUSTOM_KEY_ICON[CUSTOM_KEY_ESC] = HWK_BUTTON_CANCEL;
+
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_UP] = CUSTOM_ACTION_PAN_NORTH;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_LEFT] = CUSTOM_ACTION_PAN_WEST;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_DOWN] = CUSTOM_ACTION_PAN_SOUTH;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_RIGHT] = CUSTOM_ACTION_PAN_EAST;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_SELECT] = CUSTOM_ACTION_TOGGLE_AUTOCENTER;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_INCREASE] = CUSTOM_ACTION_ZOOM_IN;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_DECREASE] = CUSTOM_ACTION_ZOOM_OUT;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_FULLSCREEN] = CUSTOM_ACTION_TOGGLE_FULLSCREEN;
+CUSTOM_KEY_DEFAULT[CUSTOM_KEY_ESC] = CUSTOM_ACTION_TOGGLE_TRACKS;
+
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_NORTH] = _("Pan North");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_WEST] = _("Pan West");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_SOUTH] = _("Pan South");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_PAN_EAST] = _("Pan East");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_AUTOCENTER] = _("Toggle Auto-Center");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_FULLSCREEN] = _("Toggle Fullscreen");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ZOOM_IN] = _("Zoom In");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ZOOM_OUT] = _("Zoom Out");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_TRACKS] = _("Toggle Tracks");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_SCALE] = _("Toggle Scale");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_POI] = _("Toggle POIs");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_CHANGE_REPO] = _("Select Next Repository");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ROUTE_DISTNEXT] = _("Show Distance to Next Waypoint");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_ROUTE_DISTLAST] = _("Show Distance to End of Route");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TRACK_BREAK] = _("Insert Track Break");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TRACK_DISTLAST] = _("Show Distance from Last Break");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TRACK_DISTFIRST] = _("Show Distance from Beginning");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_GPS] = _("Toggle GPS");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_GPSINFO] = _("Toggle GPS Info");
+CUSTOM_ACTION_TEXT[CUSTOM_ACTION_TOGGLE_SPEEDLIMIT] = _("Toggle Speed Limit");
+
+COLORABLE_GCONF[COLORABLE_MARK] = GCONF_KEY_PREFIX "/color_mark";
+COLORABLE_GCONF[COLORABLE_MARK_VELOCITY] = GCONF_KEY_PREFIX "/color_mark_velocity";
+COLORABLE_GCONF[COLORABLE_MARK_OLD] = GCONF_KEY_PREFIX "/color_mark_old";
+COLORABLE_GCONF[COLORABLE_TRACK] = GCONF_KEY_PREFIX "/color_track";
+COLORABLE_GCONF[COLORABLE_TRACK_MARK] = GCONF_KEY_PREFIX "/color_track_mark";
+COLORABLE_GCONF[COLORABLE_TRACK_BREAK] = GCONF_KEY_PREFIX "/color_track_break";
+COLORABLE_GCONF[COLORABLE_ROUTE] = GCONF_KEY_PREFIX "/color_route";
+COLORABLE_GCONF[COLORABLE_ROUTE_WAY] = GCONF_KEY_PREFIX "/color_route_way";
+COLORABLE_GCONF[COLORABLE_ROUTE_BREAK] = GCONF_KEY_PREFIX "/color_route_break";
+COLORABLE_GCONF[COLORABLE_POI] = GCONF_KEY_PREFIX "/color_poi";
+
+DEG_FORMAT_TEXT[DDPDDDDD] = "-dd.ddddd°";
+DEG_FORMAT_TEXT[DD_MMPMMM] = "-dd°mm.mmm'";
+DEG_FORMAT_TEXT[DD_MM_SSPS] = "-dd°mm'ss.s\"";
+DEG_FORMAT_TEXT[DDPDDDDD_NSEW] = "dd.ddddd° S";
+DEG_FORMAT_TEXT[DD_MMPMMM_NSEW] = "dd°mm.mmm' S";
+DEG_FORMAT_TEXT[DD_MM_SSPS_NSEW] = "dd°mm'ss.s\" S";
+
+SPEED_LOCATION_TEXT[SPEED_LOCATION_TOP_LEFT] = _("Top-Left");
+SPEED_LOCATION_TEXT[SPEED_LOCATION_TOP_RIGHT] = _("Top-Right");
+SPEED_LOCATION_TEXT[SPEED_LOCATION_BOTTOM_RIGHT] = _("Bottom-Right");
+SPEED_LOCATION_TEXT[SPEED_LOCATION_BOTTOM_LEFT] = _("Bottom-Left");
 }
 
-/**
- * Initialize everything required in preparation for calling gtk_main().
- */
-void mapper_init(gint argc, gchar ** argv)
+void
+set_action_sensitive(const char *name, gboolean sensitive)
 {
-       GtkWidget *hbox, *mapvbox, *label, *vbox, *vbox_main;
-       GtkWidget *notebook, *hbanner;
-       GdkColor color;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       mapper_init_variables();
-
-       /* Set up track array (must be done before config). */
-       memset(&_track, 0, sizeof(_track));
-       memset(&_route, 0, sizeof(_route));
-       MACRO_PATH_INIT(_track);
-       MACRO_PATH_INIT(_route);
-
-       config_init();
-
-       g_set_application_name("Mapper");
+GtkAction *action = gtk_action_group_get_action(actions, name);
+gtk_action_set_sensitive(action, sensitive);
+}
 
-#ifdef WITH_HILDON
-       /* Initialize _program. */
-       _program = HILDON_PROGRAM(hildon_program_get_instance());
+void
+set_action_activate(const char *name, gboolean active)
+{
+GtkAction *action = gtk_action_group_get_action(actions, name);
+gtk_toggle_action_set_active(action, active);
+}
 
-       /* Initialize _window. */
-       _window = GTK_WIDGET(hildon_window_new());
-       hildon_program_add_window(_program, HILDON_WINDOW(_window));
-#else
-       _window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       gtk_window_set_title(GTK_WINDOW(_window), "Mapper");
-       gtk_widget_set_size_request(GTK_WIDGET(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
-       gtk_window_resize(GTK_WINDOW(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
-       gtk_window_set_resizable(GTK_WINDOW(_window), TRUE);
+#if 0
+void
+set_radio_action_value(const char *name, gint value)
+{
+GtkAction *action = gtk_action_group_get_action(actions, name);
+gtk_radio_action_set_current_value(action, value);
+}
 #endif
 
-       _toolbar = gtk_toolbar_new();
-       toolbar_init();
-
-       notebook = gtk_notebook_new();
-       gtk_notebook_set_show_tabs(notebook, TRUE);
-       label = gtk_label_new("Map");
-
-       hbox = gtk_hpaned_new();
-
-       info_banner.container=gtk_hbox_new(FALSE, 0);
-       info_banner.location=gtk_label_new("");
-       info_banner.speed=gtk_label_new("");
-       info_banner.distance=gtk_label_new("");
-       gtk_label_set_max_width_chars(info_banner.speed, 10);
-       gtk_label_set_width_chars(info_banner.speed, 14);
-       gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.speed, FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.location, TRUE, TRUE, 0);
-       gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.distance, FALSE, FALSE, 0);
-
-       mapvbox = gtk_vbox_new(FALSE, 0);
+/**
+ * Initialize everything required in preparation for calling gtk_main().
+ */
+void 
+mapper_ui_init(void)
+{
+GtkWidget *hbox, *mapvbox, *label, *vbox, *vbox_main;
+GtkWidget *notebook;
+GdkColor color;
+GError *error = NULL;
 
 #ifdef WITH_HILDON
-       /* Create and add widgets and supporting data. */
-       gtk_container_add(GTK_CONTAINER(_window), notebook);
-       hildon_program_set_common_toolbar(_program, _toolbar);
+/* Initialize _program. */
+_program = HILDON_PROGRAM(hildon_program_get_instance());
 
-       gtk_widget_show_all(notebook);
-       gtk_widget_show_all(_toolbar);
+/* Initialize _window. */
+_window = GTK_WIDGET(hildon_window_new());
+hildon_program_add_window(_program, HILDON_WINDOW(_window));
 #else
-       vbox_main = gtk_vbox_new(FALSE, 0);
-       gtk_container_add(GTK_CONTAINER(_window), vbox_main);
-
-       _menu_bar = gtk_menu_bar_new();
-       gtk_box_pack_start(GTK_BOX(vbox_main), _menu_bar, FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(vbox_main), _toolbar, FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(vbox_main), notebook, TRUE, TRUE, 0);
-
-       _status_bar = gtk_statusbar_new();
-       gtk_box_pack_start(GTK_BOX(vbox_main), _status_bar, FALSE, FALSE, 0);
-
-       gtk_widget_show_all(vbox_main);
+_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+gtk_window_set_title(GTK_WINDOW(_window), "Mapper");
+gtk_widget_set_size_request(GTK_WIDGET(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
+gtk_window_resize(GTK_WINDOW(_window), WINDOW_SIZE_X, WINDOW_SIZE_Y);
+gtk_window_set_resizable(GTK_WINDOW(_window), TRUE);
 #endif
 
-       /* gtk_widget_hide(_progress_item); */
-
-       gtk_box_pack_start(GTK_BOX(mapvbox), info_banner.container, FALSE, FALSE, 0);
-
-       gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0);
-       gtk_notebook_append_page(GTK_WIDGET(notebook), mapvbox, label);
-       gtk_widget_show_all(mapvbox);
-
-       vbox = gtk_vbox_new(FALSE, 0);
-       _gps_widget = gtk_frame_new("GPS Info");
-       gtk_container_add(GTK_CONTAINER(_gps_widget), vbox);
-       gtk_widget_set_size_request(GTK_WIDGET(_gps_widget), 180, 0);
-       gtk_paned_add1(hbox, _gps_widget);
+gtk_container_set_border_width (GTK_CONTAINER (_window), 0);
 
-       label = gtk_label_new(" ");
-       gtk_widget_set_size_request(GTK_WIDGET(label), -1, 10);
-       gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
+actions = gtk_action_group_new ("Actions");
+ui = gtk_ui_manager_new ();
 
-       _text_lat = gtk_label_new(" --- ");
-       gtk_widget_set_size_request(GTK_WIDGET(_text_lat), -1, 30);
-       gtk_box_pack_start(GTK_BOX(vbox), _text_lat, FALSE, TRUE, 0);
+gtk_action_group_add_actions (actions, ui_entries, n_ui_entries, NULL);
+gtk_action_group_add_toggle_actions (actions, ui_toggle_entries, n_ui_toggle_entries, NULL);
+gtk_action_group_add_radio_actions (actions, ui_autocenter_entries, 
+       n_ui_autocenter_entries, _center_mode, G_CALLBACK(menu_cb_autocenter),  NULL);
 
-       _text_lon = gtk_label_new(" --- ");
-       gtk_widget_set_size_request(GTK_WIDGET(_text_lon), -1, 30);
-       gtk_box_pack_start(GTK_BOX(vbox), _text_lon, FALSE, TRUE, 0);
+gtk_ui_manager_insert_action_group (ui, actions, 0);
+g_object_unref (actions);
 
-       _text_speed = gtk_label_new(" --- ");
-       gtk_widget_set_size_request(GTK_WIDGET(_text_speed), -1, 30);
-       gtk_box_pack_start(GTK_BOX(vbox), _text_speed, FALSE, TRUE, 0);
-
-       _text_alt = gtk_label_new(" --- ");
-       gtk_widget_set_size_request(GTK_WIDGET(_text_alt), -1, 30);
-       gtk_box_pack_start(GTK_BOX(vbox), _text_alt, FALSE, TRUE, 0);
-
-       _text_dop = gtk_label_new(" --- ");
-       gtk_widget_set_size_request(GTK_WIDGET(_text_dop), -1, 30);
-       gtk_box_pack_start(GTK_BOX(vbox), _text_dop, FALSE, TRUE, 0);
-
-       label = gtk_label_new(" ");
-       gtk_widget_set_size_request(GTK_WIDGET(label), -1, 10);
-       gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
-       _sat_panel = gtk_drawing_area_new();
-       gtk_widget_set_size_request(_sat_panel, -1, 100);
-       gtk_box_pack_start(GTK_BOX(vbox), _sat_panel, TRUE, TRUE, 0);
-
-       label = gtk_label_new(" ");
-       gtk_widget_set_size_request(GTK_WIDGET(label), -1, 10);
-       gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, TRUE, 0);
-
-       _text_time = gtk_label_new("--:--:--");
-       gtk_widget_set_size_request(GTK_WIDGET(_text_time), -1, 30);
-       gtk_box_pack_start(GTK_BOX(vbox), _text_time, FALSE, TRUE, 0);
-
-       _heading_panel = gtk_drawing_area_new();
-       gtk_widget_set_size_request(_heading_panel, -1, 100);
-       gtk_box_pack_start(GTK_BOX(vbox), _heading_panel, TRUE, TRUE, 0);
-
-       _map_widget = gtk_drawing_area_new();
-       gtk_paned_add2(hbox, _map_widget);
-
-       gtk_widget_show_all(hbox);
-       gps_show_info();        /* hides info, if necessary. */
-       gtk_widget_realize(_map_widget);
-       map_poi_init(_map_widget);
-
-       /* -1: use bit depth of widget->window. */
-       _map_pixmap = gdk_pixmap_new(_map_widget->window, BUF_WIDTH_PIXELS, BUF_HEIGHT_PIXELS, -1);     
-
-       _curl_easy_queue = g_queue_new();
-
-       _pui_tree = g_tree_new_full((GCompareDataFunc) download_comparefunc,
-                                   NULL,
-                                   (GDestroyNotify) progress_update_info_free,
-                                   NULL);
-       _downloading_tree = g_tree_new_full((GCompareDataFunc) download_comparefunc, NULL,
-                           (GDestroyNotify) progress_update_info_free, NULL);
+#ifndef WITH_HILDON
+gtk_window_add_accel_group (GTK_WINDOW(_window), gtk_ui_manager_get_accel_group (ui));
+#endif
 
-       _pui_by_easy = g_hash_table_new(g_direct_hash, g_direct_equal);
+if (!gtk_ui_manager_add_ui_from_string (ui, mapper_ui, -1, &error)) {
+       g_message ("building menus failed: %s", error->message);
+       g_error_free (error);
+}
 
-       /* Connect signals. */
-       g_signal_connect(G_OBJECT(_sat_panel), "expose_event",
-                        G_CALLBACK(sat_panel_expose), NULL);
-       g_signal_connect(G_OBJECT(_heading_panel), "expose_event",
-                        G_CALLBACK(heading_panel_expose), NULL);
-       g_signal_connect(G_OBJECT(_window), "destroy",
-                        G_CALLBACK(gtk_main_quit), NULL);
+notebook = gtk_notebook_new();
+gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), TRUE);
+label = gtk_label_new("Map");
 
-       g_signal_connect(G_OBJECT(_window), "key_press_event",
-                        G_CALLBACK(window_cb_key_press), NULL);
+hbox = gtk_hpaned_new();
 
-       g_signal_connect(G_OBJECT(_window), "key_release_event",
-                        G_CALLBACK(window_cb_key_release), NULL);
+info_banner.container=gtk_hbox_new(FALSE, 0);
+info_banner.location=gtk_label_new("");
+info_banner.speed=gtk_label_new("");
+info_banner.distance=gtk_label_new("");
+gtk_label_set_max_width_chars(GTK_LABEL(info_banner.speed), 10);
+gtk_label_set_width_chars(GTK_LABEL(info_banner.speed), 14);
+gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.speed, FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.location, TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.distance, FALSE, FALSE, 0);
 
-       g_signal_connect(G_OBJECT(_map_widget), "configure_event",
-                        G_CALLBACK(map_cb_configure), NULL);
+mapvbox = gtk_vbox_new(FALSE, 0);
 
-       g_signal_connect(G_OBJECT(_map_widget), "expose_event",
-                        G_CALLBACK(map_cb_expose), NULL);
+toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar");
+toolbar_progress_init();
 
-       g_signal_connect(G_OBJECT(_map_widget), "button_press_event",
-                        G_CALLBACK(map_cb_button_press), NULL);
+menu_bar = gtk_ui_manager_get_widget (ui, "/MenuBar");
 
-       g_signal_connect(G_OBJECT(_map_widget), "button_release_event",
-                        G_CALLBACK(map_cb_button_release), NULL);
+#ifdef WITH_HILDON
+/* Create and add widgets and supporting data. */
+gtk_container_add(GTK_CONTAINER(_window), notebook);
+hildon_program_set_common_toolbar(_program, toolbar);
 
-       g_signal_connect(G_OBJECT(_map_widget), "scroll_event",
-                        G_CALLBACK(map_cb_scroll_event), NULL);
+gtk_widget_show_all(notebook);
+gtk_widget_show_all(toolbar);
+#else
+vbox_main = gtk_vbox_new(FALSE, 0);
+gtk_container_add(GTK_CONTAINER(_window), vbox_main);
 
-       gtk_widget_add_events(_map_widget,
-                             GDK_EXPOSURE_MASK
-                             | GDK_BUTTON_PRESS_MASK
-                             | GDK_BUTTON_RELEASE_MASK
-                             | GDK_LEAVE_NOTIFY_MASK
-                             | GDK_POINTER_MOTION_MASK
-                             | GDK_POINTER_MOTION_HINT_MASK);
+gtk_box_pack_start(GTK_BOX(vbox_main), menu_bar, FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(vbox_main), toolbar, FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(vbox_main), notebook, TRUE, TRUE, 0);
 
-#ifdef WITH_OSSO
-       osso_hw_set_event_cb(_osso, NULL, osso_cb_hw_state, NULL);
+_status_bar = gtk_statusbar_new();
+gtk_box_pack_start(GTK_BOX(vbox_main), _status_bar, FALSE, FALSE, 0);
+gtk_widget_show_all(vbox_main);
 #endif
 
-       /* Initialize data. */
-
-       /* Cache some pango and GCs for drawing. */
-       _scale_context = gtk_widget_get_pango_context(_map_widget);
-       _scale_layout = pango_layout_new(_scale_context);
-       _scale_font = pango_font_description_new();
-       pango_font_description_set_size(_scale_font, 12 * PANGO_SCALE);
-       pango_layout_set_font_description(_scale_layout, _scale_font);
-
-       /* speed limit */
-       _speed_limit_gc1 = gdk_gc_new(_map_widget->window);
-       color.red = 0xffff;
-       color.green = 0;
-       color.blue = 0;
-       gdk_gc_set_rgb_fg_color(_speed_limit_gc1, &color);
-       color.red = 0;
-       color.green = 0;
-       color.blue = 0;
-       _speed_limit_gc2 = gdk_gc_new(_map_widget->window);
-       gdk_gc_set_rgb_fg_color(_speed_limit_gc2, &color);
-       _speed_limit_context = gtk_widget_get_pango_context(_map_widget);
-       _speed_limit_layout = pango_layout_new(_speed_limit_context);
-       _speed_limit_fontdesc = pango_font_description_new();
-       pango_font_description_set_size(_speed_limit_fontdesc,64 * PANGO_SCALE);
-       pango_layout_set_font_description(_speed_limit_layout, _speed_limit_fontdesc);
-       pango_layout_set_alignment(_speed_limit_layout, PANGO_ALIGN_CENTER);
-
-       /* draw_sat_info() */
-       _sat_info_gc1 = gdk_gc_new(_map_widget->window);
-       color.red = 0;
-       color.green = 0;
-       color.blue = 0;
-       gdk_gc_set_rgb_fg_color(_sat_info_gc1, &color);
-       color.red = 0;
-       color.green = 0;
-       color.blue = 0xffff;
-       _sat_info_gc2 = gdk_gc_new(_map_widget->window);
-       gdk_gc_set_rgb_fg_color(_sat_info_gc2, &color);
-       _sat_info_context = gtk_widget_get_pango_context(_map_widget);
-       _sat_info_layout = pango_layout_new(_sat_info_context);
-       _sat_info_fontdesc = pango_font_description_new();
-       pango_font_description_set_family(_sat_info_fontdesc, "Sans Serif");
-       pango_font_description_set_size(_sat_info_fontdesc, 8 * PANGO_SCALE);
-       pango_layout_set_font_description(_sat_info_layout, _sat_info_fontdesc);
-       pango_layout_set_alignment(_sat_info_layout, PANGO_ALIGN_CENTER);
+gtk_widget_hide(_progress_item);
+
+gtk_box_pack_start(GTK_BOX(mapvbox), info_banner.container, FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0);
+gtk_notebook_append_page(GTK_WIDGET(notebook), mapvbox, label);
+gtk_widget_show_all(mapvbox);
+
+_gps_widget = gps_info_panel();
+gtk_widget_set_size_request(GTK_WIDGET(_gps_widget), 180, 0);
+gtk_paned_add1(GTK_BOX(hbox), _gps_widget);
+
+_map_widget = gtk_drawing_area_new();
+gtk_paned_add2(GTK_BOX(hbox), _map_widget);
+
+gps_show_info();
+map_poi_init(_map_widget);
+gtk_widget_realize(_map_widget);
+
+g_print("A\n");
+_menu_maps_submenu = gtk_ui_manager_get_widget (ui, "/MenuBar/map/map_maps");
+menu_maps_add_repos(_menu_maps_submenu);
+g_print("B\n");
+
+menu_init_cmenu();
+
+/* -1: use bit depth of widget->window. */
+_map_pixmap = gdk_pixmap_new(_map_widget->window, BUF_WIDTH_PIXELS, BUF_HEIGHT_PIXELS, -1);    
+
+/* Connect signals. */
+g_signal_connect(G_OBJECT(_window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
+g_signal_connect(G_OBJECT(_window), "key_press_event", G_CALLBACK(window_cb_key_press), NULL);
+g_signal_connect(G_OBJECT(_window), "key_release_event", G_CALLBACK(window_cb_key_release), NULL);
+
+g_signal_connect(G_OBJECT(_map_widget), "configure_event", G_CALLBACK(map_cb_configure), NULL);
+g_signal_connect(G_OBJECT(_map_widget), "expose_event", G_CALLBACK(map_cb_expose), NULL);
+g_signal_connect(G_OBJECT(_map_widget), "button_press_event", G_CALLBACK(map_cb_button_press), NULL);
+g_signal_connect(G_OBJECT(_map_widget), "button_release_event",G_CALLBACK(map_cb_button_release), NULL);
+g_signal_connect(G_OBJECT(_map_widget), "scroll_event",         G_CALLBACK(map_cb_scroll_event), NULL);
+
+gtk_widget_add_events(_map_widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+      | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
+
+gtk_widget_show_all(hbox);
+
+/* Cache some pango and GCs for drawing. */
+_scale_context = gtk_widget_get_pango_context(_map_widget);
+_scale_layout = pango_layout_new(_scale_context);
+_scale_font = pango_font_description_new();
+pango_font_description_set_size(_scale_font, 12 * PANGO_SCALE);
+pango_layout_set_font_description(_scale_layout, _scale_font);
+
+/* speed limit */
+_speed_limit_gc1 = gdk_gc_new(_map_widget->window);
+color.red = 0xffff;
+color.green = 0;
+color.blue = 0;
+gdk_gc_set_rgb_fg_color(_speed_limit_gc1, &color);
+color.red = 0;
+color.green = 0;
+color.blue = 0;
+_speed_limit_gc2 = gdk_gc_new(_map_widget->window);
+gdk_gc_set_rgb_fg_color(_speed_limit_gc2, &color);
+_speed_limit_context = gtk_widget_get_pango_context(_map_widget);
+_speed_limit_layout = pango_layout_new(_speed_limit_context);
+_speed_limit_fontdesc = pango_font_description_new();
+pango_font_description_set_size(_speed_limit_fontdesc,64 * PANGO_SCALE);
+pango_layout_set_font_description(_speed_limit_layout, _speed_limit_fontdesc);
+pango_layout_set_alignment(_speed_limit_layout, PANGO_ALIGN_CENTER);
+
+/* draw_sat_info() */
+_sat_info_gc1 = gdk_gc_new(_map_widget->window);
+color.red = 0;
+color.green = 0;
+color.blue = 0;
+gdk_gc_set_rgb_fg_color(_sat_info_gc1, &color);
+color.red = 0;
+color.green = 0;
+color.blue = 0xffff;
+_sat_info_gc2 = gdk_gc_new(_map_widget->window);
+gdk_gc_set_rgb_fg_color(_sat_info_gc2, &color);
+_sat_info_context = gtk_widget_get_pango_context(_map_widget);
+_sat_info_layout = pango_layout_new(_sat_info_context);
+_sat_info_fontdesc = pango_font_description_new();
+pango_font_description_set_family(_sat_info_fontdesc, "Sans Serif");
+pango_font_description_set_size(_sat_info_fontdesc, 8 * PANGO_SCALE);
+pango_layout_set_font_description(_sat_info_layout, _sat_info_fontdesc);
+pango_layout_set_alignment(_sat_info_layout, PANGO_ALIGN_CENTER);
 
        /* sat_panel_expose() */
-       _sat_panel_context = gtk_widget_get_pango_context(_map_widget);
-       _sat_panel_layout = pango_layout_new(_sat_panel_context);
-       _sat_panel_fontdesc = pango_font_description_new();
-       pango_font_description_set_family(_sat_panel_fontdesc, "Sans Serif");
-       pango_font_description_set_size(_sat_panel_fontdesc, 14 * PANGO_SCALE);
-       pango_layout_set_font_description(_sat_panel_layout, _sat_panel_fontdesc);
-
-       /* heading_panel_expose() */
-       _heading_panel_context = gtk_widget_get_pango_context(_map_widget);
-       _heading_panel_layout = pango_layout_new(_heading_panel_context);
-       _heading_panel_fontdesc = pango_font_description_new();
-       pango_font_description_set_family(_heading_panel_fontdesc, "Sans Serif");
-
-       /* draw_sat_details() */
-       _sat_details_context = gtk_widget_get_pango_context(_map_widget);
-       _sat_details_layout = pango_layout_new(_sat_details_context);
-       _sat_details_fontdesc = pango_font_description_new();
-
-       pango_font_description_set_family(_sat_details_fontdesc, "Sans Serif");
-       pango_font_description_set_size(_sat_details_fontdesc, 10 * PANGO_SCALE);
-       pango_layout_set_font_description(_sat_details_layout, _sat_details_fontdesc);
-       pango_layout_set_alignment(_sat_details_layout, PANGO_ALIGN_CENTER);
-
-       /* sat_details_panel_expose() */
-       _sat_details_expose_context = gtk_widget_get_pango_context(_map_widget);
-       _sat_details_expose_layout = pango_layout_new(_sat_details_expose_context);
-       _sat_details_expose_fontdesc = pango_font_description_new();
-       pango_font_description_set_family(_sat_details_expose_fontdesc, "Sans Serif");
-       pango_layout_set_alignment(_sat_details_expose_layout, PANGO_ALIGN_CENTER);
-       pango_font_description_set_size(_sat_details_expose_fontdesc,14 * PANGO_SCALE);
-       pango_layout_set_font_description(_sat_details_expose_layout, _sat_details_expose_fontdesc);
-
-       _last_spoken_phrase = g_strdup("");
-
-       memset(&_autoroute_data, 0, sizeof(_autoroute_data));
-
-       _gps.lat = 0;
-       _gps.lon = 0;
-       _pos.unitx = 0;
-       _pos.unity = 0;
-
-       _gps.heading = 0;
-       _gps.lheading = 0;
-
-       integerize_data(_vel_offsetx, _vel_offsety, _pos, _gps);
-
-       /* Initialize our line styles. */
-       update_gcs();
-
-       menu_init();
-
-       osm_init();
-
-       /* If present, attempt to load the file specified on the command line. */
-       if (argc > 1) {
-               GnomeVFSResult vfs_result;
-               gint size;
-               gchar *buffer;
-               gchar *file_uri;
-
-               /* Get the selected filename. */
-               file_uri = gnome_vfs_make_uri_from_shell_arg(argv[1]);
-
-               if (GNOME_VFS_OK !=
-                   (vfs_result =
-                    gnome_vfs_read_entire_file(file_uri, &size, &buffer))) {
-                       gchar buffer[BUFFER_SIZE];
-                       snprintf(buffer, sizeof(buffer),
-                                "%s:\n%s",
-                                _("Failed to open file for reading"),
-                                gnome_vfs_result_to_string(vfs_result));
-                       popup_error(_window, buffer);
-               } else {
-                       if (parse_gpx(&_route, buffer, size, 0)) {
-                               MACRO_BANNER_SHOW_INFO(_window, _("Route Opened"));
-                       } else
-                               popup_error(_window, _("Error parsing GPX file."));
-                       g_free(buffer);
-               }
-               g_free(file_uri);
-       }
-
-       /* If we have a route, calculate the next point. */
-       route_find_nearest_point();
-
-#ifdef WITH_OSSO
-       /* Add D-BUS signal handler for 'status_changed' */
-       {
-               DBusConnection *dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
-               gchar *filter_string = g_strdup_printf("interface=%s", ICD_DBUS_INTERFACE);
-               /* add match */
-               dbus_bus_add_match(dbus_conn, filter_string, NULL);
-
-               g_free(filter_string);
-
-               /* add the callback */
-               dbus_connection_add_filter(dbus_conn,
-                                          get_connection_status_signal_cb,
-                                          NULL, NULL);
-       }
-       osso_iap_cb(iap_callback);
-
-       {
-               DBusGConnection *dbus_conn;
-               GError *error = NULL;
-
-               /* Initialize D-Bus. */
-               if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) {
-                       g_printerr("Failed to open connection to D-Bus: %s.\n",
-                                  error->message);
-                       error = NULL;
-               }
-
-               if (NULL == (_rfcomm_req_proxy =
-                    dbus_g_proxy_new_for_name(dbus_conn, BTCOND_SERVICE,
-                                              BTCOND_REQ_PATH,
-                                              BTCOND_REQ_INTERFACE))) {
-                       g_printerr("Failed to open connection to %s.\n",
-                                  BTCOND_REQ_INTERFACE);
-               }
-       }
+_sat_panel_context = gtk_widget_get_pango_context(_map_widget);
+_sat_panel_layout = pango_layout_new(_sat_panel_context);
+_sat_panel_fontdesc = pango_font_description_new();
+pango_font_description_set_family(_sat_panel_fontdesc, "Sans Serif");
+pango_font_description_set_size(_sat_panel_fontdesc, 12 * PANGO_SCALE);
+pango_layout_set_font_description(_sat_panel_layout, _sat_panel_fontdesc);
+
+/* heading_panel_expose() */
+_heading_panel_context = gtk_widget_get_pango_context(_map_widget);
+_heading_panel_layout = pango_layout_new(_heading_panel_context);
+_heading_panel_fontdesc = pango_font_description_new();
+pango_font_description_set_family(_heading_panel_fontdesc, "Sans Serif");
+
+/* draw_sat_details() */
+_sat_details_context = gtk_widget_get_pango_context(_map_widget);
+_sat_details_layout = pango_layout_new(_sat_details_context);
+_sat_details_fontdesc = pango_font_description_new();
+
+pango_font_description_set_family(_sat_details_fontdesc, "Sans Serif");
+pango_font_description_set_size(_sat_details_fontdesc, 10 * PANGO_SCALE);
+pango_layout_set_font_description(_sat_details_layout, _sat_details_fontdesc);
+pango_layout_set_alignment(_sat_details_layout, PANGO_ALIGN_CENTER);
+
+/* sat_details_panel_expose() */
+_sat_details_expose_context = gtk_widget_get_pango_context(_map_widget);
+_sat_details_expose_layout = pango_layout_new(_sat_details_expose_context);
+_sat_details_expose_fontdesc = pango_font_description_new();
+pango_font_description_set_family(_sat_details_expose_fontdesc, "Sans Serif");
+pango_layout_set_alignment(_sat_details_expose_layout, PANGO_ALIGN_CENTER);
+pango_font_description_set_size(_sat_details_expose_fontdesc, 12 * PANGO_SCALE);
+pango_layout_set_font_description(_sat_details_expose_layout, _sat_details_expose_fontdesc);
+
+_last_spoken_phrase = g_strdup("");
+memset(&_autoroute_data, 0, sizeof(_autoroute_data));
+
+/* Initialize our line styles. */
+update_gcs();
+
+/* If we have a route, calculate the next point. */
+route_find_nearest_point();
+
+gtk_idle_add((GSourceFunc)window_present, NULL);
+}
 
-#endif
-       gtk_idle_add((GSourceFunc) window_present, NULL);
+GtkWidget *
+progress_dialog(const gchar *title, GtkWidget *progress)
+{
+GtkWidget *dialog;
+
+dialog = gtk_dialog_new();
+gtk_window_set_title(GTK_WINDOW(dialog), title);
+gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(_window));
+gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+gtk_window_set_default_size(GTK_WINDOW(dialog), 300, 100);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), progress, TRUE, TRUE, 0);
+gtk_widget_show_all(dialog);
+return dialog;
+}
 
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+void
+progress_dialog_remove(GtkWidget *dialog)
+{
+if (dialog)
+       gtk_widget_destroy(dialog);
 }
index 928546582d82f124e34089c339196c30f7544645..dc8a4bc5d91de0a367b79db3c73d029a89d819f8 100644 (file)
@@ -27,6 +27,8 @@
 #include "ui-maemo.h"
 #include "hildon-wrappers.h"
 
+#define SCALE_WIDTH (200)
+
 /** The main GtkContainer of the application. */
 GtkWidget *_window;
 
@@ -37,15 +39,6 @@ GtkWidget *_map_widget;
 GdkPixmap *_map_pixmap;
 
 GtkWidget *_gps_widget;
-GtkWidget *_text_lat;
-GtkWidget *_text_lon;
-GtkWidget *_text_speed;
-GtkWidget *_text_alt;
-GtkWidget *_text_dop;
-GtkWidget *_text_time;
-
-GtkWidget *_sat_panel;
-GtkWidget *_heading_panel;
 
 GtkWidget *_sat_details_panel;
 GtkWidget *_sdi_lat;
@@ -87,7 +80,6 @@ PangoFontDescription *_sat_details_fontdesc;
 PangoContext *_sat_details_expose_context;
 PangoLayout *_sat_details_expose_layout;
 PangoFontDescription *_sat_details_expose_fontdesc;
-#define SCALE_WIDTH (100)
 
 /** THE GdkGC OBJECTS USED FOR DRAWING. */
 GdkGC *_gc[COLORABLE_ENUM_COUNT];
@@ -211,6 +203,6 @@ guint _cmenu_position_y;
 
 gboolean window_present();
 void popup_error(GtkWidget * window, const gchar * error);
-void mapper_init(gint argc, gchar ** argv);
+void mapper_ui_init(void);
 
 #endif
index 49b6a6d0f7564eb6cd40a498deba058111e800db..c357935a992fc94434b91c424fd0bbd003ef2ba3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file is part of maemo-mapper
+ * This file is part of mapper
  *
  * Copyright (C) 2006-2007 John Costigan.
  *
@@ -23,8 +23,6 @@
 
 #define _GNU_SOURCE
 
-#define _(String) gettext(String)
-
 #include <config.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -36,6 +34,7 @@
 #include <errno.h>
 #include <sys/wait.h>
 #include <glib/gstdio.h>
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <curl/multi.h>