]> git.itanic.dy.fi Git - maemo-mapper/blobdiff - src/poi.c
Fixed silly compile-time error.
[maemo-mapper] / src / poi.c
index 4b214244ca8133e4403e7fedf17b7cd8c6c71a47..0856482d76198d190edaf22a67071c8ab2d6e9dc 100644 (file)
--- a/src/poi.c
+++ b/src/poi.c
  * along with Maemo Mapper.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#ifdef HAVE_CONFIG_H
+#    include "config.h"
+#endif
 
 #define _GNU_SOURCE
 
 #include <string.h>
 #include <math.h>
-#include <osso-helplib.h>
-#include <hildon-widgets/hildon-note.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>
+
+#ifndef LEGACY
+#    include <hildon/hildon-help.h>
+#    include <hildon/hildon-note.h>
+#    include <hildon/hildon-file-chooser-dialog.h>
+#    include <hildon/hildon-number-editor.h>
+#    include <hildon/hildon-banner.h>
+#else
+#    include <osso-helplib.h>
+#    include <hildon-widgets/hildon-note.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>
+#endif
 
 #include <sqlite3.h>
 
@@ -106,6 +118,7 @@ poi_db_connect()
     gchar buffer[100];
     gchar **pszResult;
     gint nRow, nColumn;
+    gchar *db_dirname = NULL;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     if(_poi_db)
@@ -118,7 +131,9 @@ poi_db_connect()
     {
         /* Do nothing. */
     }
-    else if(SQLITE_OK != (sqlite3_open(_poi_db_filename, &_poi_db)))
+    else if(NULL == (db_dirname = g_path_get_dirname(_poi_db_filename))
+            || (g_mkdir_with_parents(db_dirname, 0755), /* comma operator */
+                (SQLITE_OK != (sqlite3_open(_poi_db_filename, &_poi_db)))))
     {
         gchar buffer2[BUFFER_SIZE];
         snprintf(buffer2, sizeof(buffer2),
@@ -199,6 +214,8 @@ poi_db_connect()
     else
         sqlite3_free_table(pszResult);
 
+    g_free(db_dirname);
+
     if(_poi_db)
     {
         /* Prepare our SQL statements. */
@@ -286,7 +303,7 @@ poi_db_connect()
         /* update category */
         sqlite3_prepare(_poi_db,
                         "update category set label = ?, desc = ?,"
-                        " enabled = ? where poi_id = ?",
+                        " enabled = ? where cat_id = ?",
                         -1, &_stmt_update_cat, NULL);
         /* delete from category */
         sqlite3_prepare(_poi_db,
@@ -325,7 +342,7 @@ get_nearest_poi(gint unitx, gint unity, PoiInfo *poi)
 {
     printf("%s(%d, %d)\n", __PRETTY_FUNCTION__, unitx, unity);
     gboolean result;
-    gfloat lat, lon;
+    gdouble lat, lon;
     unit2latlon(unitx, unity, lat, lon);
 
     if(SQLITE_OK == sqlite3_bind_double(_stmt_select_nearest_poi, 1, lat)
@@ -352,7 +369,7 @@ gboolean
 select_poi(gint unitx, gint unity, PoiInfo *poi, gboolean quick)
 {
     gint x, y;
-    gfloat lat1, lon1, lat2, lon2;
+    gdouble lat1, lon1, lat2, lon2;
     static GtkWidget *dialog = NULL;
     static GtkWidget *list = NULL;
     static GtkWidget *sw = NULL;
@@ -387,8 +404,8 @@ select_poi(gint unitx, gint unity, PoiInfo *poi, gboolean quick)
                                G_TYPE_BOOLEAN,/* Selected */
                                G_TYPE_INT,    /* POI ID */
                                G_TYPE_INT,    /* Category ID */
-                               G_TYPE_FLOAT,  /* Latitude */
-                               G_TYPE_FLOAT,  /* Longitude */
+                               G_TYPE_DOUBLE,  /* Latitude */
+                               G_TYPE_DOUBLE,  /* Longitude */
                                G_TYPE_STRING, /* Lat/Lon */
                                G_TYPE_FLOAT,  /* Bearing */
                                G_TYPE_FLOAT,  /* Distance */
@@ -398,7 +415,7 @@ select_poi(gint unitx, gint unity, PoiInfo *poi, gboolean quick)
 
     while(SQLITE_ROW == sqlite3_step(_stmt_select_poi))
     {
-        gfloat lat, lon;
+        gdouble lat, lon;
         lat = sqlite3_column_double(_stmt_select_poi, 0);
         lon = sqlite3_column_double(_stmt_select_poi, 1);
         lat_format(lat, tmp1);
@@ -635,7 +652,7 @@ category_edit_dialog(GtkWidget *parent, gint cat_id)
     {
         cat_enabled = 1;
         cat_label = g_strdup("");
-        cat_id = 0;
+        cat_id = -1;
         cat_desc = g_strdup("");
 
         dialog = gtk_dialog_new_with_buttons(_("Add Category"),
@@ -898,79 +915,80 @@ category_list_dialog(GtkWidget *parent)
     if(!store)
         return TRUE;
 
-    if(dialog == NULL)
-    {
-        dialog = gtk_dialog_new_with_buttons(_("POI Categories"),
-                GTK_WINDOW(parent), GTK_DIALOG_MODAL,
-                GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-                NULL);
-
-        /* Enable the help button. */
-        ossohelp_dialog_help_enable(
-                GTK_DIALOG(dialog), HELP_ID_POICAT, _osso);
-
-        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
-                btn_edit = gtk_button_new_with_label(_("Edit...")));
-
-        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
-                btn_add = gtk_button_new_with_label(_("Add...")));
-
-        sw = gtk_scrolled_window_new(NULL, NULL);
-        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (sw),
-                      GTK_POLICY_NEVER,
-                      GTK_POLICY_AUTOMATIC);
-        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                sw, TRUE, TRUE, 0);
-
-        tree_view = gtk_tree_view_new();
-        /* Maemo-related? */
-        g_object_set(tree_view, "allow-checkbox-mode", FALSE, NULL);
-        gtk_container_add (GTK_CONTAINER (sw), tree_view);
-
-        gtk_tree_selection_set_mode(
-                gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)),
-                GTK_SELECTION_SINGLE);
-        gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), TRUE);
-
-        renderer = gtk_cell_renderer_text_new();
-        column = gtk_tree_view_column_new_with_attributes(
-                _("ID"), renderer, "text", CAT_ID, NULL);
-        gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
-        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);
-        column = gtk_tree_view_column_new_with_attributes(
-                _("Enabled"), renderer, "active", CAT_ENABLED, NULL);
-        gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+    dialog = gtk_dialog_new_with_buttons(_("POI Categories"),
+            GTK_WINDOW(parent), GTK_DIALOG_MODAL,
+            GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+            NULL);
 
-        renderer = gtk_cell_renderer_text_new();
-        column = gtk_tree_view_column_new_with_attributes(
-                _("Label"), renderer, "text", CAT_LABEL, NULL);
-        gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+    /* Enable the help button. */
+#ifndef LEGACY
+    hildon_help_dialog_help_enable(
+#else
+    ossohelp_dialog_help_enable(
+#endif
+            GTK_DIALOG(dialog), HELP_ID_POICAT, _osso);
 
-        renderer = gtk_cell_renderer_text_new();
-        column = gtk_tree_view_column_new_with_attributes(
-                _("Description"), renderer, "text", CAT_DESC, NULL);
-        gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
+            btn_edit = gtk_button_new_with_label(_("Edit...")));
 
-        renderer = gtk_cell_renderer_text_new();
-        column = gtk_tree_view_column_new_with_attributes(
-                _("# POIs"), renderer, "text", CAT_POI_CNT, NULL);
-        gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+    gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
+            btn_add = gtk_button_new_with_label(_("Add...")));
 
-        gtk_window_set_default_size(GTK_WINDOW(dialog), -1, 400);
+    sw = gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (sw),
+                  GTK_POLICY_NEVER,
+                  GTK_POLICY_AUTOMATIC);
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+            sw, TRUE, TRUE, 0);
+
+    tree_view = gtk_tree_view_new();
+    /* Maemo-related? */
+    g_object_set(tree_view, "allow-checkbox-mode", FALSE, NULL);
+    gtk_container_add (GTK_CONTAINER (sw), tree_view);
+
+    gtk_tree_selection_set_mode(
+            gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)),
+            GTK_SELECTION_SINGLE);
+    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view), TRUE);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(
+            _("ID"), renderer, "text", CAT_ID, NULL);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+    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);
+    column = gtk_tree_view_column_new_with_attributes(
+            _("Enabled"), renderer, "active", CAT_ENABLED, NULL);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(
+            _("Label"), renderer, "text", CAT_LABEL, NULL);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(
+            _("Description"), renderer, "text", CAT_DESC, NULL);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+
+    renderer = gtk_cell_renderer_text_new();
+    column = gtk_tree_view_column_new_with_attributes(
+            _("# POIs"), renderer, "text", CAT_POI_CNT, NULL);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
+
+    gtk_window_set_default_size(GTK_WINDOW(dialog), -1, 400);
 
-        pcedit.dialog = dialog;
-        pcedit.tree_view = tree_view;
+    pcedit.dialog = dialog;
+    pcedit.tree_view = tree_view;
 
-        g_signal_connect(G_OBJECT(btn_edit), "clicked",
-                G_CALLBACK(category_edit), &pcedit);
+    g_signal_connect(G_OBJECT(btn_edit), "clicked",
+            G_CALLBACK(category_edit), &pcedit);
 
-        g_signal_connect(G_OBJECT(btn_add), "clicked",
-                G_CALLBACK(category_add), &pcedit);
-    }
+    g_signal_connect(G_OBJECT(btn_add), "clicked",
+            G_CALLBACK(category_add), &pcedit);
 
     gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(store));
     g_object_unref(G_OBJECT(store));
@@ -982,7 +1000,7 @@ category_list_dialog(GtkWidget *parent)
         break;
     }
 
-    gtk_widget_hide(dialog);
+    gtk_widget_destroy(dialog);
 
     vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
     return TRUE;
@@ -1022,7 +1040,7 @@ poi_delete(GtkWidget *widget, DeletePOI *dpoi)
     return TRUE;
 }
 
-static void
+static gboolean
 poi_populate_categories(GtkListStore *store, gint cat_id,
         GtkTreeIter *out_active)
 {
@@ -1042,13 +1060,15 @@ poi_populate_categories(GtkListStore *store, gint cat_id,
 
         if(cid == cat_id || !has_active)
         {
-            *out_active = iter;
+            if(out_active)
+                *out_active = iter;
             has_active = TRUE;
         }
     }
     sqlite3_reset(_stmt_selall_cat);
 
     vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+    return has_active;
 }
 
 static gboolean
@@ -1058,18 +1078,20 @@ poi_edit_cat(GtkWidget *widget, PoiCategoryEditInfo *data)
     if(category_list_dialog(data->dialog))
     {
         GtkTreeIter active;
-        poi_populate_categories(GTK_LIST_STORE(gtk_combo_box_get_model(
+        if(poi_populate_categories(GTK_LIST_STORE(gtk_combo_box_get_model(
                         GTK_COMBO_BOX(data->cmb_category))),
-                data->cat_id, &active);
-        gtk_combo_box_set_active_iter(
-                GTK_COMBO_BOX(data->cmb_category), &active);
+                data->cat_id, &active))
+        {
+            gtk_combo_box_set_active_iter(
+                    GTK_COMBO_BOX(data->cmb_category), &active);
+        }
     }
     vprintf("%s(): return\n", __PRETTY_FUNCTION__);
     return TRUE;
 }
 
 static GtkWidget*
-poi_create_cat_combo(gint selected_cat_id)
+poi_create_cat_combo()
 {
     GtkWidget *cmb_category;
     GtkTreeModel *model;
@@ -1092,158 +1114,376 @@ poi_create_cat_combo(gint selected_cat_id)
                 GTK_CELL_LAYOUT(cmb_category), renderer, "text", 1, NULL);
 
         poi_populate_categories(GTK_LIST_STORE(gtk_combo_box_get_model(
-                    GTK_COMBO_BOX(cmb_category))), selected_cat_id,
-                &active);
-        if(selected_cat_id)
-            gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_category),&active);
+                        GTK_COMBO_BOX(cmb_category))), -1, &active);
     }
     vprintf("%s(): return\n", __PRETTY_FUNCTION__);
     return cmb_category;
 }
 
 gboolean
-poi_view_dialog(GtkWidget *parent, PoiInfo *poi, gint unitx, gint unity)
+poi_add_dialog(GtkWidget *parent, gint unitx, gint unity)
 {
-    PoiInfo static_poi;
     gchar buffer[16];
-    GtkWidget *dialog;
-    GtkWidget *table;
-    GtkWidget *label;
-    GtkWidget *txt_label;
-    GtkWidget *txt_lat;
-    GtkWidget *txt_lon;
-    GtkWidget *cmb_category;
-    GtkWidget *txt_desc;
-    GtkWidget *btn_delete = NULL;
-    GtkWidget *btn_catedit;
-    GtkWidget *hbox;
-    GtkWidget *txt_scroll;
-    GtkTextBuffer *desc_txt;
-    GtkTextIter begin, end;
-    DeletePOI dpoi = {NULL, NULL, 0};
-    PoiCategoryEditInfo pcedit;
-    gboolean is_edit;
+    static PoiInfo poi;
+    static GtkWidget *dialog;
+    static GtkWidget *table;
+    static GtkWidget *label;
+    static GtkWidget *txt_label;
+    static GtkWidget *txt_lat;
+    static GtkWidget *txt_lon;
+    static GtkWidget *cmb_category;
+    static GtkWidget *txt_desc;
+    static GtkWidget *btn_catedit;
+    static GtkWidget *hbox;
+    static GtkWidget *txt_scroll;
+    static GtkTextBuffer *desc_txt;
+    static GtkTextIter begin, end;
+    static DeletePOI dpoi = {NULL, NULL, 0};
+    static PoiCategoryEditInfo pcedit;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
-    is_edit = poi ? TRUE : FALSE;
-
-    if(is_edit)
+    if(dialog == NULL)
     {
-        dialog = gtk_dialog_new_with_buttons(_("Edit POI"),
+        dialog = gtk_dialog_new_with_buttons(_("Add POI"),
             GTK_WINDOW(parent), GTK_DIALOG_MODAL,
             GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+            GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
             NULL);
 
-        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
-                btn_delete = gtk_button_new_with_label(_("Delete...")));
+        /* Set the lat/lon strings. */
+        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+                table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0);
 
-        dpoi.dialog = dialog;
-        dpoi.txt_label = g_strdup(poi->label);
-        dpoi.id = poi->poi_id;
-        dpoi.deleted = FALSE;
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Lat")),
+                0, 1, 0, 1, GTK_FILL, 0, 2, 0);
+        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, 0);
 
-        g_signal_connect(G_OBJECT(btn_delete), "clicked",
-                          G_CALLBACK(poi_delete), &dpoi);
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Lon")),
+                2, 3, 0, 1, GTK_FILL, 0, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+        gtk_table_attach(GTK_TABLE(table),
+                txt_lon = gtk_entry_new(),
+                3, 4, 0, 1, GTK_FILL, 0, 2, 0);
 
-        gtk_dialog_add_button(GTK_DIALOG(dialog),
-                GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Label")),
+                0, 1, 1, 2, GTK_FILL, 0, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+        gtk_table_attach(GTK_TABLE(table),
+                txt_label = gtk_entry_new(),
+                1, 4, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 0);
+
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Category")),
+                0, 1, 3, 4, GTK_FILL, 0, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+        gtk_table_attach(GTK_TABLE(table),
+                hbox = gtk_hbox_new(FALSE, 4),
+                1, 4, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 0);
+        gtk_box_pack_start(GTK_BOX(hbox),
+                cmb_category = poi_create_cat_combo(),
+                FALSE, FALSE, 0);
+
+        gtk_box_pack_start(GTK_BOX(hbox),
+                btn_catedit = gtk_button_new_with_label(
+                    _("Edit Categories...")),
+                FALSE, FALSE, 0);
+
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Description")),
+                0, 1, 5, 6, GTK_FILL, GTK_FILL, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.0f);
+
+        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,
+                1, 4, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 0);
+
+        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll),
+                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+        txt_desc = gtk_text_view_new ();
+        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD);
+
+        gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
+        gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 550, 120);
+
+        desc_txt = gtk_text_view_get_buffer(GTK_TEXT_VIEW (txt_desc));
+
+        g_signal_connect(G_OBJECT(btn_catedit), "clicked",
+                G_CALLBACK(poi_edit_cat), &pcedit);
     }
+
+    poi.poi_id = -1;
+    poi.cat_id = -1;
+    poi.clabel = NULL;
+    poi.desc = g_strdup("");
+    unit2latlon(unitx, unity, poi.lat, poi.lon);
+
+    /* Lat/Lon */
+    snprintf(buffer, sizeof(buffer), "%.06f", poi.lat);
+    gtk_entry_set_text(GTK_ENTRY(txt_lat), buffer);
+    snprintf(buffer, sizeof(buffer), "%.06f", poi.lon);
+    gtk_entry_set_text(GTK_ENTRY(txt_lon), buffer);
+
+    /* Label */
+    if(SQLITE_ROW == sqlite3_step(_stmt_nextlabel_poi))
+        poi.label = g_strdup_printf("Point%06d",
+                sqlite3_column_int(_stmt_nextlabel_poi, 0));
     else
+        poi.label = g_strdup("");
+    sqlite3_reset(_stmt_nextlabel_poi);
+    gtk_entry_set_text(GTK_ENTRY(txt_label), poi.label);
+
+    /* POI Desc. */
+    gtk_text_buffer_set_text(desc_txt, "", -1);
+
+    /* Category. */
+    {
+        GtkTreeIter iter;
+        gint cat_id = -1;
+        gboolean had_cat_id = FALSE;
+
+        if(gtk_combo_box_get_active_iter(
+                GTK_COMBO_BOX(cmb_category), &iter))
+        {
+            gtk_tree_model_get(
+                    gtk_combo_box_get_model(GTK_COMBO_BOX(cmb_category)),&iter,
+                    0, &cat_id,
+                    -1);
+            had_cat_id = TRUE;
+        }
+        gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(
+                        GTK_COMBO_BOX(cmb_category))));
+        if(poi_populate_categories(GTK_LIST_STORE(gtk_combo_box_get_model(
+                    GTK_COMBO_BOX(cmb_category))), cat_id, &iter)
+                && had_cat_id)
+        {
+            gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_category), &iter);
+        }
+    }
+
+    pcedit.dialog = dialog;
+    pcedit.cmb_category = cmb_category;
+    pcedit.cat_id = poi.cat_id;
+
+    gtk_widget_show_all(dialog);
+
+    while(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog)))
     {
-        poi = &static_poi;
+        GtkTreeIter iter;
+        const gchar *text;
+        gchar *error_check;
 
-        if(SQLITE_ROW == sqlite3_step(_stmt_nextlabel_poi))
-            poi->label = g_strdup_printf("Point%06d",
-                    sqlite3_column_int(_stmt_nextlabel_poi, 0));
+        text = gtk_entry_get_text(GTK_ENTRY(txt_lat));
+        poi.lat = strdmstod(text, &error_check);
+        if(text == error_check || poi.lat < -90. || poi.lat > 90.) {
+            popup_error(dialog, _("Invalid Latitude"));
+            continue;
+        }
+
+        text = gtk_entry_get_text(GTK_ENTRY(txt_lon));
+        poi.lon = strdmstod(text, &error_check);
+        if(text == error_check || poi.lon < -180. || poi.lon > 180.) {
+            popup_error(dialog, _("Invalid Longitude"));
+            continue;
+        }
+
+        if(strlen(gtk_entry_get_text(GTK_ENTRY(txt_label))))
+        {
+            if(poi.label)
+                g_free(poi.label);
+            poi.label = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_label)));
+        }
         else
-            poi->label = g_strdup("");
-        sqlite3_reset(_stmt_nextlabel_poi);
+        {
+            popup_error(dialog, _("Please specify a name."));
+            continue;
+        }
 
-        unit2latlon(unitx, unity, poi->lat, poi->lon);
+        if(!gtk_combo_box_get_active_iter(
+                GTK_COMBO_BOX(cmb_category), &iter))
+        {
+            popup_error(dialog, _("Please specify a category."));
+            continue;
+        }
 
-        poi->poi_id = 0;
-        poi->cat_id = 0;
-        poi->clabel = NULL;
-        poi->desc = g_strdup("");
+        gtk_text_buffer_get_iter_at_offset(desc_txt, &begin,0 );
+        gtk_text_buffer_get_end_iter (desc_txt, &end);
+        if(poi.desc)
+            g_free(poi.desc);
+        poi.desc = gtk_text_buffer_get_text(desc_txt, &begin, &end, TRUE);
 
-        dialog = gtk_dialog_new_with_buttons(_("Add POI"),
+        if(poi.clabel)
+            g_free(poi.clabel);
+        gtk_tree_model_get(
+                gtk_combo_box_get_model(GTK_COMBO_BOX(cmb_category)), &iter,
+                0, &poi.cat_id,
+                1, &poi.clabel,
+                -1);
+
+        /* add poi */
+        if(SQLITE_OK != sqlite3_bind_double(_stmt_insert_poi, 1, poi.lat)
+        || SQLITE_OK != sqlite3_bind_double(_stmt_insert_poi, 2, poi.lon)
+        || SQLITE_OK != sqlite3_bind_text(_stmt_insert_poi, 3, poi.label,
+               -1, g_free)
+        || SQLITE_OK != sqlite3_bind_text(_stmt_insert_poi, 4, poi.desc,
+               -1, g_free)
+        || SQLITE_OK != sqlite3_bind_int(_stmt_insert_poi, 5, poi.cat_id)
+        || SQLITE_DONE != sqlite3_step(_stmt_insert_poi))
+        {
+            MACRO_BANNER_SHOW_INFO(parent, _("Error adding POI"));
+        }
+
+        sqlite3_reset(_stmt_insert_poi);
+
+        /* We're done. */
+        break;
+    }
+
+    g_free(poi.label);
+    g_free(poi.desc);
+    g_free(dpoi.txt_label);
+
+    map_force_redraw();
+
+    gtk_widget_hide(dialog);
+
+    vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
+    return !dpoi.deleted;
+}
+
+gboolean
+poi_view_dialog(GtkWidget *parent, PoiInfo *poi)
+{
+    GtkTreeIter iter;
+    static GtkWidget *dialog;
+    static GtkWidget *table;
+    static GtkWidget *label;
+    static GtkWidget *txt_label;
+    static GtkWidget *txt_lat;
+    static GtkWidget *txt_lon;
+    static GtkWidget *cmb_category;
+    static GtkWidget *txt_desc;
+    static GtkWidget *btn_delete = NULL;
+    static GtkWidget *btn_catedit;
+    static GtkWidget *hbox;
+    static GtkWidget *txt_scroll;
+    static GtkTextBuffer *desc_txt;
+    static GtkTextIter begin, end;
+    static DeletePOI dpoi = {NULL, NULL, 0};
+    static PoiCategoryEditInfo pcedit;
+    printf("%s()\n", __PRETTY_FUNCTION__);
+
+    if(dialog == NULL)
+    {
+        dialog = gtk_dialog_new_with_buttons(_("Edit POI"),
             GTK_WINDOW(parent), GTK_DIALOG_MODAL,
             GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
-            GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
             NULL);
-    }
 
-    /* Set the lat/lon strings. */
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-            table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0);
+        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
+                btn_delete = gtk_button_new_with_label(_("Delete...")));
 
-    gtk_table_attach(GTK_TABLE(table),
-            label = gtk_label_new(_("Lat")),
-            0, 1, 0, 1, GTK_FILL, 0, 2, 0);
-    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, 0);
+        gtk_dialog_add_button(GTK_DIALOG(dialog),
+                GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
 
-    gtk_table_attach(GTK_TABLE(table),
-            label = gtk_label_new(_("Lon")),
-            2, 3, 0, 1, GTK_FILL, 0, 2, 0);
-    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-    gtk_table_attach(GTK_TABLE(table),
-            txt_lon = gtk_entry_new(),
-            3, 4, 0, 1, GTK_FILL, 0, 2, 0);
+        /* Set the lat/lon strings. */
+        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
+                table = gtk_table_new(6, 4, FALSE), TRUE, TRUE, 0);
 
-    gtk_table_attach(GTK_TABLE(table),
-            label = gtk_label_new(_("Label")),
-            0, 1, 1, 2, GTK_FILL, 0, 2, 0);
-    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-    gtk_table_attach(GTK_TABLE(table),
-            txt_label = gtk_entry_new(),
-            1, 4, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 0);
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Lat")),
+                0, 1, 0, 1, GTK_FILL, 0, 2, 0);
+        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, 0);
 
-    gtk_table_attach(GTK_TABLE(table),
-            label = gtk_label_new(_("Category")),
-            0, 1, 3, 4, GTK_FILL, 0, 2, 0);
-    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-    gtk_table_attach(GTK_TABLE(table),
-            hbox = gtk_hbox_new(FALSE, 4),
-            1, 4, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 0);
-    gtk_box_pack_start(GTK_BOX(hbox),
-            cmb_category = poi_create_cat_combo(poi->cat_id),
-            FALSE, FALSE, 0);
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Lon")),
+                2, 3, 0, 1, GTK_FILL, 0, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+        gtk_table_attach(GTK_TABLE(table),
+                txt_lon = gtk_entry_new(),
+                3, 4, 0, 1, GTK_FILL, 0, 2, 0);
 
-    gtk_box_pack_start(GTK_BOX(hbox),
-            btn_catedit = gtk_button_new_with_label(_("Edit Categories...")),
-            FALSE, FALSE, 0);
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Label")),
+                0, 1, 1, 2, GTK_FILL, 0, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+        gtk_table_attach(GTK_TABLE(table),
+                txt_label = gtk_entry_new(),
+                1, 4, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 0);
 
-    gtk_table_attach(GTK_TABLE(table),
-            label = gtk_label_new(_("Description")),
-            0, 1, 5, 6, GTK_FILL, 0, 2, 0);
-    gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.0f);
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Category")),
+                0, 1, 3, 4, GTK_FILL, 0, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+        gtk_table_attach(GTK_TABLE(table),
+                hbox = gtk_hbox_new(FALSE, 4),
+                1, 4, 3, 4, GTK_EXPAND | GTK_FILL, 0, 2, 0);
+        gtk_box_pack_start(GTK_BOX(hbox),
+                cmb_category = poi_create_cat_combo(),
+                FALSE, FALSE, 0);
 
-    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,
-            1, 4, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 0);
+        gtk_box_pack_start(GTK_BOX(hbox),
+                btn_catedit = gtk_button_new_with_label(
+                    _("Edit Categories...")),
+                FALSE, FALSE, 0);
 
-    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll),
-                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+        gtk_table_attach(GTK_TABLE(table),
+                label = gtk_label_new(_("Description")),
+                0, 1, 5, 6, GTK_FILL, GTK_FILL, 2, 0);
+        gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.0f);
 
-    txt_desc = gtk_text_view_new ();
-    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD);
+        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,
+                1, 4, 5, 6, GTK_EXPAND | GTK_FILL, 0, 2, 0);
 
-    gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
-    gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 550, 120);
+        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(txt_scroll),
+                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+        txt_desc = gtk_text_view_new ();
+        gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(txt_desc), GTK_WRAP_WORD);
+
+        gtk_container_add(GTK_CONTAINER(txt_scroll), txt_desc);
+        gtk_widget_set_size_request(GTK_WIDGET(txt_scroll), 550, 120);
 
-    desc_txt = gtk_text_view_get_buffer (GTK_TEXT_VIEW (txt_desc));
+        desc_txt = gtk_text_view_get_buffer (GTK_TEXT_VIEW (txt_desc));
+
+        g_signal_connect(G_OBJECT(btn_delete), "clicked",
+                          G_CALLBACK(poi_delete), &dpoi);
+
+        g_signal_connect(G_OBJECT(btn_catedit), "clicked",
+                G_CALLBACK(poi_edit_cat), &pcedit);
+    }
+
+    dpoi.dialog = dialog;
+    dpoi.txt_label = g_strdup(poi->label);
+    dpoi.id = poi->poi_id;
+    dpoi.deleted = FALSE;
 
     /* Lat/Lon */
-    snprintf(buffer, sizeof(buffer), "%.06f", poi->lat);
-    gtk_entry_set_text(GTK_ENTRY(txt_lat), buffer);
-    snprintf(buffer, sizeof(buffer), "%.06f", poi->lon);
-    gtk_entry_set_text(GTK_ENTRY(txt_lon), buffer);
+    {
+        gchar tmp1[LL_FMT_LEN], tmp2[LL_FMT_LEN];
+
+        lat_format(poi->lat, tmp1);
+        lon_format(poi->lon, tmp2);
+
+        gtk_entry_set_text(GTK_ENTRY(txt_lat), tmp2);
+        gtk_entry_set_text(GTK_ENTRY(txt_lon), tmp1);
+    }
 
     /* label */
     gtk_entry_set_text(GTK_ENTRY(txt_label), poi->label);
@@ -1251,17 +1491,22 @@ poi_view_dialog(GtkWidget *parent, PoiInfo *poi, gint unitx, gint unity)
     /* poi_desc */
     gtk_text_buffer_set_text(desc_txt, poi->desc, -1);
 
+    /* Category. */
+    gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(
+                    GTK_COMBO_BOX(cmb_category))));
+    if(poi_populate_categories(GTK_LIST_STORE(gtk_combo_box_get_model(
+                GTK_COMBO_BOX(cmb_category))), poi->cat_id, &iter))
+        gtk_combo_box_set_active_iter(GTK_COMBO_BOX(cmb_category), &iter);
+
     /* Connect Signals */
     pcedit.dialog = dialog;
     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);
+
     gtk_widget_show_all(dialog);
 
     while(GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog)))
     {
-        GtkTreeIter iter;
         const gchar *text;
         gchar *error_check;
 
@@ -1312,53 +1557,27 @@ poi_view_dialog(GtkWidget *parent, PoiInfo *poi, gint unitx, gint unity)
                 1, &poi->clabel,
                 -1);
 
-        if(is_edit)
+        /* edit poi */
+        if(SQLITE_OK != sqlite3_bind_double(
+                    _stmt_update_poi, 1, poi->lat) ||
+           SQLITE_OK != sqlite3_bind_double(
+               _stmt_update_poi, 2, poi->lon) ||
+           SQLITE_OK != sqlite3_bind_text(_stmt_update_poi, 3, poi->label,
+                    -1, SQLITE_STATIC) ||
+           SQLITE_OK != sqlite3_bind_text(_stmt_update_poi, 4, poi->desc,
+               -1, g_free) ||
+           SQLITE_OK != sqlite3_bind_int(
+               _stmt_update_poi, 5, poi->cat_id) ||
+           SQLITE_OK != sqlite3_bind_int(
+               _stmt_update_poi, 6, poi->poi_id) ||
+           SQLITE_DONE != sqlite3_step(_stmt_update_poi))
         {
-            /* edit poi */
-            if(SQLITE_OK != sqlite3_bind_double(
-                        _stmt_update_poi, 1, poi->lat) ||
-               SQLITE_OK != sqlite3_bind_double(
-                   _stmt_update_poi, 2, poi->lon) ||
-               SQLITE_OK != sqlite3_bind_text(_stmt_update_poi, 3, poi->label,
-                        -1, SQLITE_STATIC) ||
-               SQLITE_OK != sqlite3_bind_text(_stmt_update_poi, 4, poi->desc,
-                   -1, g_free) ||
-               SQLITE_OK != sqlite3_bind_int(
-                   _stmt_update_poi, 5, poi->cat_id) ||
-               SQLITE_OK != sqlite3_bind_int(
-                   _stmt_update_poi, 6, poi->poi_id) ||
-               SQLITE_DONE != sqlite3_step(_stmt_update_poi))
-            {
-                MACRO_BANNER_SHOW_INFO(parent, _("Error updating POI"));
-            }
-            else
-            {
-                map_force_redraw();
-            }
-            sqlite3_reset(_stmt_update_poi);
-        }
-        else
-        {
-            /* add poi */
-            if(SQLITE_OK != sqlite3_bind_double(_stmt_insert_poi, 1, poi->lat)
-            || SQLITE_OK != sqlite3_bind_double(_stmt_insert_poi, 2, poi->lon)
-            || SQLITE_OK != sqlite3_bind_text(_stmt_insert_poi, 3, poi->label,
-                   -1, g_free)
-            || SQLITE_OK != sqlite3_bind_text(_stmt_insert_poi, 4, poi->desc,
-                   -1, g_free)
-            || SQLITE_OK != sqlite3_bind_int(_stmt_insert_poi, 5, poi->cat_id)
-            || SQLITE_DONE != sqlite3_step(_stmt_insert_poi))
-            {
-                MACRO_BANNER_SHOW_INFO(parent, _("Error adding POI"));
-            }
-            else
-            {
-                MACRO_MAP_RENDER_DATA();
-            }
-            sqlite3_reset(_stmt_insert_poi);
-            g_free(poi->label);
-            g_free(poi->desc);
+            MACRO_BANNER_SHOW_INFO(parent, _("Error updating POI"));
         }
+
+        sqlite3_reset(_stmt_update_poi);
+
+        /* We're done. */
         break;
     }
 
@@ -1366,7 +1585,7 @@ poi_view_dialog(GtkWidget *parent, PoiInfo *poi, gint unitx, gint unity)
 
     map_force_redraw();
 
-    gtk_widget_destroy(dialog);
+    gtk_widget_hide(dialog); /* Destroying causes a crash.... ??? */
 
     vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
     return !dpoi.deleted;
@@ -1565,7 +1784,7 @@ poi_list_set_category(GtkWidget *widget, PoiListInfo *pli)
                 FALSE, FALSE, 0);
 
         gtk_box_pack_start(GTK_BOX(hbox),
-                cmb_category = poi_create_cat_combo(0),
+                cmb_category = poi_create_cat_combo(),
                 FALSE, FALSE, 4);
 
         gtk_box_pack_start(GTK_BOX(hbox),
@@ -1713,7 +1932,7 @@ poi_list_view(GtkWidget *widget, PoiListInfo *pli)
                 POI_CLABEL, &(poi.clabel),
                 -1);
 
-        if(poi_view_dialog(pli->dialog, &poi, 0, 0))
+        if(poi_view_dialog(pli->dialog, &poi))
         {
             gtk_list_store_set(store, &iter,
                     POI_POIID, poi.poi_id,
@@ -1763,7 +1982,7 @@ poi_list_goto(GtkWidget *widget, PoiListInfo *pli)
     /* Iterate through the data store and import as desired. */
     if(gtk_tree_selection_get_selected(selection, NULL, &iter))
     {
-        gfloat lat, lon;
+        gdouble lat, lon;
         Point unit;
 
         gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
@@ -1934,7 +2153,7 @@ poi_list_dialog(GtkWidget *parent, gint unitx, gint unity, GList *poi_list)
     static GtkListStore *store;
     GtkTreeIter iter;
     GList *curr;
-    gfloat src_lat, src_lon;
+    gdouble src_lat, src_lon;
     printf("%s()\n", __PRETTY_FUNCTION__);
 
     if(pli.dialog == NULL)
@@ -1950,8 +2169,8 @@ poi_list_dialog(GtkWidget *parent, gint unitx, gint unity, GList *poi_list)
                                    G_TYPE_BOOLEAN,/* Selected */
                                    G_TYPE_INT,    /* POI ID */
                                    G_TYPE_INT,    /* Category ID */
-                                   G_TYPE_FLOAT,  /* Latitude */
-                                   G_TYPE_FLOAT,  /* Longitude */
+                                   G_TYPE_DOUBLE, /* Latitude */
+                                   G_TYPE_DOUBLE, /* Longitude */
                                    G_TYPE_STRING, /* Lat/Lon */
                                    G_TYPE_FLOAT,  /* Bearing */
                                    G_TYPE_FLOAT,  /* Distance */
@@ -2023,7 +2242,11 @@ poi_list_dialog(GtkWidget *parent, gint unitx, gint unity, GList *poi_list)
         g_object_unref(G_OBJECT(store));
 
         /* Enable the help button. */
+#ifndef LEGACY
+        hildon_help_dialog_help_enable(
+#else
         ossohelp_dialog_help_enable(
+#endif
                 GTK_DIALOG(pli.dialog), HELP_ID_POILIST, _osso);
 
         gtk_container_add(GTK_CONTAINER(GTK_DIALOG(pli.dialog)->action_area),
@@ -2163,7 +2386,7 @@ poi_import_dialog(gint unitx, gint unity)
                         FALSE, FALSE, 0);
 
                 gtk_box_pack_start(GTK_BOX(hbox),
-                        cmb_category = poi_create_cat_combo(0),
+                        cmb_category = poi_create_cat_combo(),
                         FALSE, FALSE, 4);
 
                 gtk_box_pack_start(GTK_BOX(hbox),
@@ -2301,7 +2524,11 @@ poi_download_dialog(gint unitx, gint unity)
                 NULL);
 
         /* Enable the help button. */
+#ifndef LEGACY
+        hildon_help_dialog_help_enable(
+#else
         ossohelp_dialog_help_enable(
+#endif
                 GTK_DIALOG(dialog), HELP_ID_DOWNPOI, _osso);
 
         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
@@ -2339,7 +2566,7 @@ poi_download_dialog(gint unitx, gint unity)
                 2, 3, 1, 2, GTK_FILL, 0, 2, 4);
         gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
         gtk_table_attach(GTK_TABLE(table),
-                cmb_category = poi_create_cat_combo(0),
+                cmb_category = poi_create_cat_combo(),
                 3, 4, 1, 2, GTK_FILL, 0, 2, 4);
 
         /* Page. */
@@ -2366,7 +2593,12 @@ poi_download_dialog(gint unitx, gint unity)
                 oti.txt_origin = gtk_entry_new(),
                 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
         gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_origin), 25);
+#ifndef LEGACY
+        g_object_set(G_OBJECT(oti.txt_origin), "hildon-input-mode",
+                HILDON_GTK_INPUT_MODE_FULL, NULL);
+#else
         g_object_set(G_OBJECT(oti.txt_origin), HILDON_AUTOCAP, FALSE, NULL);
+#endif
 
         /* Query. */
         gtk_table_attach(GTK_TABLE(table2),
@@ -2377,7 +2609,12 @@ poi_download_dialog(gint unitx, gint unity)
                 oti.txt_query = gtk_entry_new(),
                 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
         gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_query), 25);
+#ifndef LEGACY
+        g_object_set(G_OBJECT(oti.txt_query), "hildon-input-mode",
+                HILDON_GTK_INPUT_MODE_FULL, NULL);
+#else
         g_object_set(G_OBJECT(oti.txt_query), HILDON_AUTOCAP, FALSE, NULL);
+#endif
 
         /* Set up auto-completion. */
         origin_comp = gtk_entry_completion_new();
@@ -2406,7 +2643,7 @@ poi_download_dialog(gint unitx, gint unity)
         gchar buffer[80];
         gchar strlat[32];
         gchar strlon[32];
-        gfloat lat, lon;
+        gdouble lat, lon;
 
         unit2latlon(unitx, unity, lat, lon);
 
@@ -2488,7 +2725,7 @@ poi_download_dialog(gint unitx, gint unity)
             gchar strlat[32];
             gchar strlon[32];
             Point *p;
-            gfloat lat, lon;
+            gdouble lat, lon;
 
             /* Use last non-zero route point. */
             for(p = _route.tail; !p->unity; p--) { }
@@ -2614,7 +2851,11 @@ poi_browse_dialog(gint unitx, gint unity)
                 NULL);
 
         /* Enable the help button. */
+#ifndef LEGACY
+        hildon_help_dialog_help_enable(
+#else
         ossohelp_dialog_help_enable(
+#endif
                 GTK_DIALOG(dialog), HELP_ID_BROWSEPOI, _osso);
 
         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
@@ -2642,7 +2883,7 @@ poi_browse_dialog(gint unitx, gint unity)
                 2, 3, 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_category = poi_create_cat_combo(0),
+                cmb_category = poi_create_cat_combo(),
                 3, 4, 0, 1, GTK_FILL, 0, 2, 4);
         /* Add an extra, "<any>" category. */
         {
@@ -2669,7 +2910,12 @@ poi_browse_dialog(gint unitx, gint unity)
                 oti.txt_origin = gtk_entry_new(),
                 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
         gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_origin), 25);
+#ifndef LEGACY
+        g_object_set(G_OBJECT(oti.txt_origin), "hildon-input-mode",
+                HILDON_GTK_INPUT_MODE_FULL, NULL);
+#else
         g_object_set(G_OBJECT(oti.txt_origin), HILDON_AUTOCAP, FALSE, NULL);
+#endif
 
         /* Destination. */
         gtk_table_attach(GTK_TABLE(table2),
@@ -2680,7 +2926,12 @@ poi_browse_dialog(gint unitx, gint unity)
                 oti.txt_query = gtk_entry_new(),
                 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
         gtk_entry_set_width_chars(GTK_ENTRY(oti.txt_query), 25);
+#ifndef LEGACY
+        g_object_set(G_OBJECT(oti.txt_query), "hildon-input-mode",
+                HILDON_GTK_INPUT_MODE_FULL, NULL);
+#else
         g_object_set(G_OBJECT(oti.txt_query), HILDON_AUTOCAP, FALSE, NULL);
+#endif
 
         /* Set up auto-completion. */
         origin_comp = gtk_entry_completion_new();
@@ -2703,7 +2954,7 @@ poi_browse_dialog(gint unitx, gint unity)
         gchar buffer[80];
         gchar strlat[32];
         gchar strlon[32];
-        gfloat lat, lon;
+        gdouble lat, lon;
 
         unit2latlon(unitx, unity, lat, lon);
 
@@ -2750,7 +3001,7 @@ poi_browse_dialog(gint unitx, gint unity)
     {
         gchar buffer[BUFFER_SIZE];
         const gchar *origin, *query;
-        gfloat lat, lon;
+        gdouble lat, lon;
         GList *poi_list = NULL;
         gint cat_id;
         gboolean is_cat = FALSE;
@@ -2772,7 +3023,7 @@ poi_browse_dialog(gint unitx, gint unity)
             gchar strlat[32];
             gchar strlon[32];
             Point *p;
-            gfloat lat, lon;
+            gdouble lat, lon;
 
             /* Use last non-zero route point. */
             for(p = _route.tail; !p->unity; p--) { }
@@ -2823,7 +3074,6 @@ poi_browse_dialog(gint unitx, gint unity)
 
         if(is_cat)
         {
-            printf("Searching for cat_id = %d\n", cat_id);
             if(SQLITE_OK != sqlite3_bind_int(_stmt_browsecat_poi, 1, cat_id) ||
                SQLITE_OK != sqlite3_bind_text(_stmt_browsecat_poi, 2, query,
                    -1, g_free) ||
@@ -2888,7 +3138,7 @@ void
 map_render_poi()
 {
     gint unitx, unity;
-    gfloat lat1, lat2, lon1, lon2;
+    gdouble lat1, lat2, lon1, lon2;
     gchar buffer[100];
     gint poix, poiy;
     GdkPixbuf *pixbuf = NULL;
@@ -2897,9 +3147,14 @@ map_render_poi()
 
     if(_poi_db && _poi_zoom > _zoom)
     {
-        buf2unit(0, _screen_height_pixels, unitx, unity);
+        gint diag_offset = pixel2unit(MAX(_view_width_pixels,
+                    _view_height_pixels) / 2);
+        buf2unit(0, _view_height_pixels, unitx, unity);
+        unitx = _center.unitx - diag_offset;
+        unity = _center.unity + diag_offset;
         unit2latlon(unitx, unity, lat1, lon1);
-        buf2unit(_screen_width_pixels, 0, unitx, unity);
+        unitx = _center.unitx + diag_offset;
+        unity = _center.unity - diag_offset;
         unit2latlon(unitx, unity, lat2, lon2);
 
         if(SQLITE_OK != sqlite3_bind_double(_stmt_select_poi, 1, lat1) ||