]> err.no Git - mapper/blobdiff - src/cb.c
Use menu entry for color settings.
[mapper] / src / cb.c
index 21e7870f77187768f9815da73412889d209ee570..2252c15fd125447a8b2b0590e237a56c9e2731c6 100644 (file)
--- a/src/cb.c
+++ b/src/cb.c
@@ -1,6 +1,29 @@
-#include <config.h>
+/*
+ * 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.
+ *
+ * Default map data provided by http://www.openstreetmap.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
-#define _GNU_SOURCE
+#include <config.h>
 
 #include <unistd.h>
 #include <stdlib.h>
 #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 <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>
-
-#ifdef WITH_HILDON
-#include <libosso.h>
-#include <osso-helplib.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-input-mode-hint.h>
-#include <device_symbols.h>
-#endif
+
+#include "hildon-mapper.h"
 
 #include "utils.h"
 #include "poi.h"
+#include "path.h"
 #include "route.h"
+#include "track.h"
 #include "settings.h"
 #include "gps.h"
 #include "map.h"
 #include "mapper-types.h"
-#include "bt.h"
 #include "ui-common.h"
 #include "db.h"
-
+#include "latlon.h"
 #include "cb.h"
+#include "poi-gui.h"
+#include "gps-panels.h"
+#include "gps-conn.h"
+#include "search.h"
+#include "help.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;
+GtkListStore *store;
 
-       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;
+route_download(NULL);
+store=route_generate_store(&_route);
+if (store!=NULL) {
+       gtk_tree_view_set_model(route_tree_view, store);
+       g_object_unref(G_OBJECT(store));
 }
-
-gboolean menu_cb_route_download(GtkAction * action)
-{
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       route_download(NULL);
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_route_open(GtkAction * action)
+gboolean 
+menu_cb_route_open(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       route_open_file();
+GtkListStore *store;
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_open_file();
+store=route_generate_store(&_route);
+if (store!=NULL) {
+       gtk_tree_view_set_model(route_tree_view, store);
+       g_object_unref(G_OBJECT(store));
+}
+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__);
-
-       cancel_autoroute(FALSE);
-       MACRO_PATH_FREE(_route);
-       MACRO_PATH_INIT(_route);
-       route_find_nearest_point();
-       map_force_redraw();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+route_clear();
+gtk_tree_view_set_model(route_tree_view, NULL);
+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_show_tracks(GtkAction * action)
+gboolean 
+menu_cb_track_filter(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;
+filter_dialog();
+return TRUE;
 }
 
-gboolean menu_cb_show_scale(GtkAction * action)
+gboolean 
+menu_cb_show_tracks(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"));
+}
+return TRUE;
 }
 
-gboolean menu_cb_gps_show_info(GtkAction * action)
+gboolean 
+menu_cb_show_velvec(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;
+_show_velvec = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+map_move_mark();
+return TRUE;
 }
 
-gboolean menu_cb_ac_lead(GtkAction * action)
+gboolean 
+menu_cb_show_poi(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_poi = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+map_force_redraw();
+return TRUE;
 }
 
-gboolean menu_cb_ac_latlon(GtkAction * action)
+gboolean 
+menu_cb_gps_show_info(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;
+_gps_info = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action));
+gps_show_info(_gps);
+return TRUE;
 }
 
-gboolean menu_cb_ac_none(GtkAction * action)
+gboolean
+menu_cb_autocenter(GtkAction *action, GtkRadioAction *current)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+guint new_center_unitx, new_center_unity;
+gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
 
-       _center_mode = -_center_mode;
-       MACRO_BANNER_SHOW_INFO(_window, _("Auto-Center Off"));
+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:
+       default:
+               _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(_gps->data, 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__);
-
-       dialog = gtk_dialog_new_with_buttons(_("Go to Lat/Lon"),
-                                            GTK_WINDOW(_window),
-                                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                            GTK_RESPONSE_ACCEPT,
-                                            GTK_STOCK_CANCEL,
-                                            GTK_RESPONSE_REJECT, NULL);
-
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                          table = gtk_table_new(2, 3, FALSE), TRUE, TRUE, 0);
-
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Latitude")),
-                        0, 1, 0, 1, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-
-       gtk_table_attach(GTK_TABLE(table),
-                        txt_lat = gtk_entry_new(),
-                        1, 2, 0, 1, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
-
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Longitude")),
-                        0, 1, 1, 2, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-
-       gtk_table_attach(GTK_TABLE(table),
-                        txt_lon = gtk_entry_new(),
-                        1, 2, 1, 2, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.5f);
-
-#ifdef WITH_HILDON
-       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];
-               gfloat 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);
-
-       while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               const gchar *text;
-               gchar *error_check;
-               gfloat 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;
-               }
-
-               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;
-       }
-       gtk_widget_destroy(dialog);
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+map_dialog_goto_latlon();
+return TRUE;
 }
 
-gboolean menu_cb_goto_home(GtkAction * action)
+gboolean 
+menu_cb_goto_home(GtkAction *action)
 {
-       guint unitx, unity;
-
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       if (_center_mode > 0)
-               gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM
-                                              (_menu_ac_none_item), TRUE);
-
-       latlon2unit(_home.lat, _home.lon, unitx, unity);
-       map_center_unit(unitx, unity);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+if (map_goto_position(&_home)==FALSE) {
+       MACRO_BANNER_SHOW_INFO(_window, _("Home not set."));
+} else {
+       map_set_zoom(3);
+       MACRO_BANNER_SHOW_INFO(_window, _("At home location"));
+}
+return TRUE;
 }
 
-gboolean menu_cb_goto_gps(GtkAction * action)
+gboolean 
+menu_cb_goto_destination(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);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+if (map_goto_position(&_dest)==FALSE) {
+       MACRO_BANNER_SHOW_INFO(_window, _("Destination not set."));
+} else {
+       map_set_zoom(3);
+       MACRO_BANNER_SHOW_INFO(_window, _("At destination"));
+}
+return TRUE;
 }
 
-gboolean menu_cb_goto_nextway(GtkAction * action)
+gboolean 
+menu_cb_goto_gps(GtkAction *action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+_center_mode = CENTER_LATLON;
+map_center_unit(_gps->data.unitx, _gps->data.unity);
+map_update_location_from_center();
+MACRO_BANNER_SHOW_INFO(_window, _("At GPS coordinates."));
+return TRUE;
+}
 
-       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);
+gboolean 
+menu_cb_goto_nextway(GtkAction * action)
+{
+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;
-PoiInfo *p;
-
-printf("%s()\n", __PRETTY_FUNCTION__);
+poi_info *p;
 
 if (_center_mode > 0) {
        /* Auto-Center is enabled - use the GPS position. */
-       unit2latlon(_pos.unitx, _pos.unity, lat, lon);
+       lat=_gps->data.lat;
+       lon=_gps->data.lon;
 } else {
        /* Auto-Center is disabled - use the view center. */
        unit2latlon(_center.unitx, _center.unity, lat, lon);
@@ -523,200 +360,174 @@ 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();
 } else {
        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, _gps->data.speed);
+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, 0);
+map_set_zoom(3);
+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, 0);
+g_idle_add((GSourceFunc)map_zoom_in, NULL);
+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, 0);
+g_idle_add((GSourceFunc)map_zoom_out, NULL);
+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));
+}
+gtk_idle_add((GSourceFunc) window_present, NULL);
+return TRUE;
 }
 
-gboolean cb_fullscreen(GtkAction * action)
+gboolean 
+menu_cb_enable_gps(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(_toolbar_fullscreen_item, GTK_STATE_ACTIVE);
+if ((_enable_gps = gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)))) {
+       if (_gps->io.address) {
+               gps_conn_set_state(_gps, RCVR_DOWN);
+               gps_connect_now(_gps);
        } else {
-               gtk_window_unfullscreen(GTK_WINDOW(_window));
-               gtk_widget_set_state(_toolbar_fullscreen_item, GTK_STATE_NORMAL);
+               popup_error(_window, _("Cannot enable GPS until a GPS Receiver has been configured in the GPS Settings dialog."));
+               set_action_activate("gps_enabled", FALSE);
        }
+} else {
+       if (_gps->io.conn > RCVR_OFF)
+               gps_conn_set_state(_gps, RCVR_OFF);
+       gps_disconnect(_gps);
+       track_add(NULL, FALSE);
+       _speed_excess=FALSE;
+}
+if (_enable_gps==FALSE)
+       set_action_activate("autocenter_none", TRUE);
+set_action_sensitive("goto_gps", _enable_gps);
+set_action_sensitive("autocenter_latlon", _enable_gps);
+set_action_sensitive("autocenter_lead", _enable_gps);
 
-       gtk_idle_add((GSourceFunc) window_present, NULL);
+map_move_mark();
+gps_show_info(&_gps->data);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean menu_cb_enable_gps(GtkAction * action)
+gboolean 
+menu_cb_auto_download(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);
-               }
-       } 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();
-       gtk_widget_set_sensitive(GTK_WIDGET(_menu_gps_details_item), _enable_gps);
+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_auto_download(GtkAction * action)
+gboolean 
+menu_cb_settings(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+settings_dialog();
+MACRO_RECALC_FOCUS_BASE();
+MACRO_RECALC_FOCUS_SIZE();
+map_force_redraw();
+return TRUE;
+}
 
-       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();
+gboolean 
+menu_cb_settings_gps(GtkAction * action)
+{
+if (settings_dialog_gps()) {
+       /* Settings have changed - reconnect to receiver. */
+       if (_enable_gps) {
+               gps_conn_set_state(_gps, RCVR_DOWN);
+               gps_disconnect(_gps);
+               gps_connect_now(_gps);
        }
-
-       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_gps_details(GtkAction * action)
+gboolean 
+menu_cb_settings_colors(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       gps_details();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+settings_dialog_colors();
+map_force_redraw();
+return TRUE;
 }
 
-gboolean menu_cb_settings(GtkAction * action)
+gboolean 
+menu_cb_settings_osm(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();
-               }
-       }
-       MACRO_RECALC_FOCUS_BASE();
-       MACRO_RECALC_FOCUS_SIZE();
-       map_force_redraw();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+settings_dialog_osm();
+return TRUE;
 }
 
-gboolean menu_cb_help(GtkAction * action)
+gboolean 
+menu_cb_help(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-#ifdef WITH_HILDON
-       ossohelp_show(_osso, HELP_ID_INTRO, 0);
-#endif
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+help_topic_display(HELP_ID_INTRO, 0);
+return TRUE;
 }
 
-gboolean menu_cb_about(GtkAction * action)
+gboolean 
+menu_cb_about(GtkAction * action)
 {
-#ifdef WITH_HILDON
-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",
@@ -725,108 +536,87 @@ 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);
-                               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:
@@ -846,100 +636,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;
-
+               _speed_on ^= 1;
+       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) {
@@ -947,114 +705,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)
 {
-       gfloat 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(_degformat, lat, tmp1);
+lon_format(_degformat, lon, tmp2);
 
-       MACRO_BANNER_SHOW_INFO(_window, buffer);
+g_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];
-       gfloat 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);
+g_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];
-       gfloat 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);
+g_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];
-       gfloat lat, lon;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       unit2latlon(unitx, unity, lat, lon);
+gchar buffer[80];
+gdouble lat, lon;
 
-       snprintf(buffer, sizeof(buffer), "%s: %.02f %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__);
+g_snprintf(buffer, sizeof(buffer), "%s: %.02lf %s", _("Distance"),
+        calculate_distance(_gps->data.lat, _gps->data.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)
 {
-       gfloat 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);
@@ -1065,8 +807,8 @@ void cmenu_route_add_way(guint unitx, guint unity)
        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
 
        unit2latlon(unitx, unity, lat, lon);
-       lat_format(lat, tmp1);
-       lon_format(lon, tmp2);
+       lat_format(_degformat, lat, tmp1);
+       lon_format(_degformat, lon, tmp2);
        p_latlon = g_strdup_printf("%s, %s", tmp1, tmp2);
        gtk_table_attach(GTK_TABLE(table),
                         label = gtk_label_new(p_latlon),
@@ -1125,14 +867,11 @@ void cmenu_route_add_way(guint unitx, guint unity)
 
                        g_free(desc);
 
-                       confirm =
-                           hildon_note_new_confirmation(GTK_WINDOW(dialog),
-                                                        _
-                                                        ("Creating a \"waypoint\" with no description actually "
+                       confirm = hildon_note_new_confirmation(GTK_WINDOW(dialog),
+                                                        _("Creating a \"waypoint\" with no description actually "
                                                          "adds a break point.  Is that what you want?"));
 
-                       if (GTK_RESPONSE_OK ==
-                           gtk_dialog_run(GTK_DIALOG(confirm))) {
+                       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
                                /* There's no description.  Add a break by adding a (0, 0)
                                 * point (if necessary), and then the ordinary route point. */
                                if (_route.tail->unity) {
@@ -1158,351 +897,404 @@ 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));
+cmenu_clip_latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gboolean 
+cmenu_cb_loc_route_to(GtkAction * action)
+{
+cmenu_route_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_route_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));
+return TRUE;
+}
 
-       cmenu_route_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+gboolean 
+cmenu_cb_loc_add_route(GtkAction * action)
+{
+cmenu_add_route(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gboolean 
+cmenu_cb_loc_add_way(GtkAction * action)
+{
+cmenu_route_add_way(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_distance_to(GtkAction * action)
+gboolean 
+cmenu_cb_loc_add_poi(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+guint ux, uy;
+poi_info *poi;
 
-       cmenu_distance_to(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+poi=poi_new();
+ux=x2unit(_cmenu_position_x);
+uy=y2unit(_cmenu_position_y);
+unit2latlon(ux, uy, poi->lat, poi->lon);
+poi_edit_dialog(ACTION_ADD_POI, poi);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_add_route(GtkAction * action)
+gboolean
+cb_poi_search(GtkAction *action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+poi_info poi;
+gdouble lat, lon;
 
-       cmenu_add_route(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+if (_center_mode>0) {
+       lat=_gps->data.lat;
+       lon=_gps->data.lon;
+} else {
+       unit2latlon(_center.unitx, _center.unity, lat, lon);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+mapper_search_dialog(SEARCH_TYPE_POI, lat, lon);
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_add_way(GtkAction * action)
+gboolean 
+cb_poi_add(GtkAction *action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+gdouble lat,lon;
+const gchar *name = gtk_action_get_name(action);
+poi_info *p;
 
-       cmenu_route_add_way(x2unit(_cmenu_position_x),
-                           y2unit(_cmenu_position_y));
+if (_center_mode>0) {
+       lat=_gps->data.lat;
+       lon=_gps->data.lon;
+} else {
+       unit2latlon(_center.unitx, _center.unity, lat, lon);
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+if (strcmp(name, "poi_add")==0) {
+       p=poi_new();
+       p->lat=lat;
+       p->lon=lon;
+       poi_edit_dialog(ACTION_ADD_POI, p);
+       map_poi_cache_clear();
+} else if (strcmp(name, "poi_quick_add")==0) {
+       poi_quick_dialog(lat, lon);
+       map_poi_cache_clear();
+} else
+       g_assert_not_reached();
+
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_add_poi(GtkAction * action)
+gboolean
+menu_cb_search_address(GtkAction *action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       poi_dialog(ACTION_ADD_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+gdouble lat, lon;
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+if (_center_mode>0) {
+       lat=_gps->data.lat;
+       lon=_gps->data.lon;
+} else {
+       unit2latlon(_center.unitx, _center.unity, lat, lon);
+}
+mapper_search_dialog(SEARCH_TYPE_WAY, lat, lon);
+return TRUE;
 }
 
-gboolean cb_add_poi(GtkAction * action)
+gboolean 
+cmenu_cb_loc_set_home(GtkAction * action)
 {
-       guint unitx, unity;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+guint unitx, unity;
 
-       latlon2unit(_gps.lat, _gps.lon, unitx, unity);
-       poi_dialog(ACTION_ADD_POI, unitx, unity);
+unitx = x2unit(_cmenu_position_x);
+unity = y2unit(_cmenu_position_y);
+unit2latlon(unitx, unity, _home.lat, _home.lon);
+_home.valid=TRUE;
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+config_save_home();
+map_render_data();
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_set_home(GtkAction * action)
+gboolean 
+cmenu_cb_loc_set_destination(GtkAction *action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       _pos.unitx = x2unit(_cmenu_position_x);
-       _pos.unity = y2unit(_cmenu_position_y);
-       unit2latlon(_pos.unitx, _pos.unity, _home.lat, _home.lon);
+guint unitx, unity;
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+unitx = x2unit(_cmenu_position_x);
+unity = y2unit(_cmenu_position_y);
+unit2latlon(unitx, unity, _dest.lat, _dest.lon);
+_dest.valid=TRUE;
+#if 0
+map_update_location_from_center();
+#endif
+return TRUE;
 }
 
-gboolean cmenu_cb_loc_set_gps(GtkAction * action)
+gboolean 
+cmenu_cb_loc_set_gps(GtkAction * action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+_gps->data.unitx = x2unit(_cmenu_position_x);
+_gps->data.unity = y2unit(_cmenu_position_y);
+unit2latlon(_gps->data.unitx, _gps->data.unity, _gps->data.lat, _gps->data.lon);
 
-       _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. */
+map_refresh_mark();
+_gps->data.time=time(NULL);
+track_add(&_gps->data, FALSE);
 
-       /* Move mark to new location. */
-       refresh_mark();
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+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__);
+WayPoint *way;
 
-       if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x),
-                                        y2unit(_cmenu_position_y)))) {
-               gchar buffer[BUFFER_SIZE];
-               GtkWidget *confirm;
+if ((way = find_nearest_waypoint(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y)))) {
+       gchar buffer[BUFFER_SIZE];
+       GtkWidget *confirm;
 
-               snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
-                        _("Confirm delete of waypoint"), way->desc);
-               confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
+       g_snprintf(buffer, sizeof(buffer), "%s:\n%s\n", _("Confirm delete of waypoint"), way->desc);
+       confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
 
-               if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
-                       Point *pdel_min, *pdel_max, *pdel_start, *pdel_end;
-                       guint num_del;
+       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+               Point *pdel_min, *pdel_max, *pdel_start, *pdel_end;
+               guint num_del;
 
-                       /* Delete surrounding route data, too. */
-                       if (way == _route.whead)
-                               pdel_min = _route.head;
-                       else
-                               pdel_min = way[-1].point;
+               /* Delete surrounding route data, too. */
+               if (way == _route.whead)
+                       pdel_min = _route.head;
+               else
+                       pdel_min = way[-1].point;
 
-                       if (way == _route.wtail)
-                               pdel_max = _route.tail;
-                       else
-                               pdel_max = way[1].point;
+               if (way == _route.wtail)
+                       pdel_max = _route.tail;
+               else
+                       pdel_max = 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 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
+menu_cb_category(GtkAction * action)
+{
+if (poi_category_list())
+       map_force_redraw();
+
+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_info *p;
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+       p=poi_new();
+       unit2latlon(way->point->unitx, way->point->unity, p->lat, p->lon);
+       poi_edit_dialog(ACTION_ADD_POI, p);
+}
+return TRUE;
 }
 
-gboolean cmenu_cb_poi_route_to(GtkAction * action)
+gboolean 
+cmenu_cb_poi_route_to(GtkAction * action)
 {
-       PoiInfo 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 (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), 4, &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)
 {
-       PoiInfo 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 (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), 4, &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)
 {
-       PoiInfo 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 (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), 4, &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)
 {
-       PoiInfo 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 (poi_select(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), 4, &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_show_poi(GtkAction *action)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
+/* XXX: Write this */
+return TRUE;
+}
 
-       poi_dialog(ACTION_EDIT_POI, x2unit(_cmenu_position_x), y2unit(_cmenu_position_y));
+gboolean 
+cmenu_cb_poi_edit_poi(GtkAction * action)
+{
+poi_info *p;
+gdouble lat, lon;
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+unit2latlon(x2unit(_cmenu_position_x), y2unit(_cmenu_position_y), lat, lon);
+p=poi_find_nearest(lat, lon);
+if (!p) {
+       popup_error(_window, _("No POI found at location."));
        return TRUE;
 }
+poi_edit_dialog(ACTION_EDIT_POI, p);
+return TRUE;
+}