]> err.no Git - mapper/blobdiff - src/map-repo.c
Fixes to gstreamer element and caps handlings.
[mapper] / src / map-repo.c
index 61dbdc9708203cd96438d2b10dc685b79e7e1df9..db804047eb3dfb132ab3e498579d8409fbe42f73 100644 (file)
@@ -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 <math.h>
 #include <gtk/gtk.h>
 #include <libgnomevfs/gnome-vfs.h>
-#include <curl/multi.h>
-#include <gconf/gconf-client.h>
-#include <sqlite3.h>
-
-#ifdef WITH_HILDON
-#include <libosso.h>
-#include <osso-helplib.h>
-#include <hildon-widgets/hildon-controlbar.h>
-#include <hildon-widgets/hildon-note.h>
-#include <hildon-widgets/hildon-color-button.h>
-#include <hildon-widgets/hildon-file-chooser-dialog.h>
-#include <hildon-widgets/hildon-number-editor.h>
-#include <hildon-widgets/hildon-banner.h>
-#include <hildon-widgets/hildon-system-sound.h>
-#include <hildon-widgets/hildon-input-mode-hint.h>
-#endif
+
+#include "hildon-mapper.h"
 
 #include "utils.h"
 #include "gps.h"
 #include "map.h"
+#include "latlon.h"
 #include "route.h"
 #include "settings.h"
 #include "mapper-types.h"
+#include "map-download.h"
 #include "ui-common.h"
+#include "dialogs.h"
+#include "help.h"
+#include "map-repo.h"
 
-#define REPO_DEFAULT_NAME "OpenStreet"
-#define REPO_DEFAULT_CACHE_BASE "~/MyDocs/.documents/Maps/"
-#define REPO_DEFAULT_CACHE_DIR REPO_DEFAULT_CACHE_BASE"OpenStreet"
-#define REPO_DEFAULT_MAP_URI "http://tile.openstreetmap.org/%0d/%d/%d.png"
-#define REPO_DEFAULT_DL_ZOOM_STEPS (2)
-#define REPO_DEFAULT_VIEW_ZOOM_STEPS (1)
+#define MAP_REPO_LIST_URL "http://www.gnuite.com/nokia770/maemo-mapper/repos.txt"
 
 typedef struct _RepoManInfo RepoManInfo;
 struct _RepoManInfo {
@@ -91,967 +100,645 @@ struct _MapmanInfo {
 
 void set_repo_type(RepoData * repo)
 {
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, repo->url);
-
-       if (repo->url && *repo->url) {
-               gchar *url = g_utf8_strdown(repo->url, -1);
-
-               /* Determine type of repository. */
-               if (strstr(url, "service=wms"))
-                       repo->type = REPOTYPE_WMS;
-               else if (strstr(url, "%s"))
-                       repo->type = REPOTYPE_QUAD_QRST;
-               else if (strstr(url, "%0d"))
-                       repo->type = REPOTYPE_XYZ_INV;
-               else if (strstr(url, "%0s"))
-                       repo->type = REPOTYPE_QUAD_ZERO;
-               else
-                       repo->type = REPOTYPE_XYZ;
-
-               g_free(url);
-       } else
-               repo->type = REPOTYPE_NONE;
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-RepoData *config_parse_repo(gchar * str)
-{
-       /* Parse each part of a repo, delimited by newline characters:
-        * 1. name
-        * 2. url
-        * 3. cache_dir
-        * 4. dl_zoom_steps
-        * 5. view_zoom_steps
-        */
-       gchar *token, *error_check;
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, str);
-
-       RepoData *rd = g_new0(RepoData, 1);
-
-       /* Parse name. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->name = g_strdup(token);
-
-       /* Parse URL format. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->url = g_strdup(token);
-
-       /* Parse cache dir. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->cache_dir = gnome_vfs_expand_initial_tilde(token);
-
-       /* Parse download zoom steps. */
-       token = strsep(&str, "\n\t");
-       if (!token || !*token || !(rd->dl_zoom_steps = atoi(token)))
-               rd->dl_zoom_steps = 2;
-
-       /* Parse view zoom steps. */
-       token = strsep(&str, "\n\t");
-       if (!token || !*token || !(rd->view_zoom_steps = atoi(token)))
-               rd->view_zoom_steps = 1;
-
-       /* Parse double-size. */
-       token = strsep(&str, "\n\t");
-       if (token)
-               rd->double_size = atoi(token);  /* Default is zero (FALSE) */
-
-       /* Parse next-able. */
-       token = strsep(&str, "\n\t");
-       if (!token || !*token
-           || (rd->nextable = strtol(token, &error_check, 10), token == str))
-               rd->nextable = TRUE;
-
-       set_repo_type(rd);
-
-       vprintf("%s(): return %p\n", __PRETTY_FUNCTION__, rd);
-       return rd;
+if (repo->url && *repo->url) {
+       gchar *url = g_utf8_strdown(repo->url, -1);
+
+       /* Determine type of repository. */
+       if (strstr(url, "service=wms"))
+               repo->type = REPOTYPE_WMS;
+       else if (strstr(url, "%s"))
+               repo->type = REPOTYPE_QUAD_QRST;
+       else if (strstr(url, "%0d"))
+               repo->type = REPOTYPE_XYZ_INV;
+       else if (strstr(url, "%0s"))
+               repo->type = REPOTYPE_QUAD_ZERO;
+       else
+               repo->type = REPOTYPE_XYZ;
+
+       g_free(url);
+} else
+       repo->type = REPOTYPE_NONE;
 }
 
 gboolean
 repo_make_cache_dir(gchar * name, const gchar * cache_dir, GtkWidget * parent)
 {
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, cache_dir);
-       if (g_mkdir_with_parents(cache_dir, 0755)) {
-               /* Failed to create Map Cache directory. */
-               gchar buffer[BUFFER_SIZE];
-               snprintf(buffer, sizeof(buffer), "%s: %s",
-                        _("Unable to create cache directory for repository"),
-                        name);
-               popup_error(parent, buffer);
-               vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
-               return FALSE;
-       }
-       vprintf("%s(): return %d\n", __PRETTY_FUNCTION__,
-               g_file_test(cache_dir, G_FILE_TEST_EXISTS));
-       return g_file_test(cache_dir, G_FILE_TEST_EXISTS);
+if (g_mkdir_with_parents(cache_dir, 0755)) {
+       /* Failed to create Map Cache directory. */
+       gchar buffer[BUFFER_SIZE];
+       g_snprintf(buffer, sizeof(buffer), "%s: %s",
+                _("Unable to create cache directory for repository"), name);
+       popup_error(parent, buffer);
+       return FALSE;
+}
+return g_file_test(cache_dir, G_FILE_TEST_EXISTS);
 }
 
-gboolean repo_set_curr(RepoData * rd)
+gboolean 
+repo_set_curr(RepoData * rd)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       _curr_repo = rd;
-       return repo_make_cache_dir(rd->name, rd->cache_dir, _window);
+_curr_repo = rd;
+return repo_make_cache_dir(rd->name, rd->cache_dir, _window);
 }
 
-gboolean repoman_dialog_select(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_dialog_select(GtkWidget * widget, RepoManInfo * rmi)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       gint curr_index =
-           gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
-       gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi->notebook), curr_index);
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gint curr_index = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
+gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi->notebook), curr_index);
+return TRUE;
 }
 
-gboolean repoman_dialog_browse(GtkWidget * widget, BrowseInfo * browse_info)
+static gboolean 
+repoman_dialog_browse(GtkWidget * widget, BrowseInfo * browse_info)
 {
-       GtkWidget *dialog;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       dialog =
-           GTK_WIDGET(hildon_file_chooser_dialog_new
-                      (GTK_WINDOW(browse_info->dialog),
-                       GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
-
-       gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
-       gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog),
-                                           gtk_entry_get_text(GTK_ENTRY
-                                                              (browse_info->
-                                                               txt)));
-
-       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               gchar *filename =
-                   gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-               gtk_entry_set_text(GTK_ENTRY(browse_info->txt), filename);
-               g_free(filename);
-       }
+GtkWidget *dialog;
 
-       gtk_widget_destroy(dialog);
+dialog = GTK_WIDGET(hildon_file_chooser_dialog_new
+       (GTK_WINDOW(browse_info->dialog),
+               GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
+gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), gtk_entry_get_text(GTK_ENTRY(browse_info->txt)));
+
+if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(dialog))) {
+       gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+       gtk_entry_set_text(GTK_ENTRY(browse_info->txt), filename);
+       g_free(filename);
 }
 
-gboolean repoman_dialog_rename(GtkWidget * widget, RepoManInfo * rmi)
-{
-       GtkWidget *hbox;
-       GtkWidget *label;
-       GtkWidget *txt_name;
-       GtkWidget *dialog;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+gtk_widget_destroy(dialog);
 
-       dialog = gtk_dialog_new_with_buttons(_("New Name"),
-                                            GTK_WINDOW(rmi->dialog),
-                                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                            GTK_RESPONSE_ACCEPT,
-                                            GTK_STOCK_CANCEL,
-                                            GTK_RESPONSE_REJECT, NULL);
+return TRUE;
+}
 
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                          hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 4);
+static gboolean 
+repoman_dialog_rename(GtkWidget * widget, RepoManInfo * rmi)
+{
+GtkWidget *hbox;
+GtkWidget *label;
+GtkWidget *txt_name;
+GtkWidget *dialog;
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          label = gtk_label_new(_("Name")), FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          txt_name = gtk_entry_new(), TRUE, TRUE, 0);
+dialog = gtk_dialog_new_with_buttons(_("New Name"),
+                            GTK_WINDOW(rmi->dialog),
+                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
+                            GTK_RESPONSE_ACCEPT,
+                            GTK_STOCK_CANCEL,
+                            GTK_RESPONSE_REJECT, NULL);
 
-       gtk_widget_show_all(dialog);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 4);
 
-       while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               gint active =
-                   gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
-               RepoEditInfo *rei = g_list_nth_data(rmi->repo_edits, active);
-               g_free(rei->name);
-               rei->name = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_name)));
-               gtk_combo_box_insert_text(GTK_COMBO_BOX(rmi->cmb_repos),
-                                         active, g_strdup(rei->name));
-               gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), active);
-               gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos),
-                                         active + 1);
-               break;
-       }
+gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Name")), FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(hbox), txt_name = gtk_entry_new(), TRUE, TRUE, 0);
 
-       gtk_widget_destroy(dialog);
+gtk_widget_show_all(dialog);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+       gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
+       RepoEditInfo *rei = g_list_nth_data(rmi->repo_edits, active);
+       g_free(rei->name);
+       rei->name = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_name)));
+       gtk_combo_box_insert_text(GTK_COMBO_BOX(rmi->cmb_repos), active, g_strdup(rei->name));
+       gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), active);
+       gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), active + 1);
+       break;
+}
+
+gtk_widget_destroy(dialog);
+return TRUE;
 }
 
-gboolean repoman_dialog_delete(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_dialog_delete(GtkWidget * widget, RepoManInfo * rmi)
 {
-       gchar buffer[100];
-       GtkWidget *confirm;
-       gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
-       printf("%s()\n", __PRETTY_FUNCTION__);
+gchar buffer[100];
+GtkWidget *confirm;
+gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
 
-       if (gtk_tree_model_iter_n_children
-           (GTK_TREE_MODEL
-            (gtk_combo_box_get_model(GTK_COMBO_BOX(rmi->cmb_repos))),
-            NULL) <= 1) {
-               popup_error(rmi->dialog,
-                           _
-                           ("Cannot delete the last repository - there must be at"
-                            " lease one repository."));
-               vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-               return TRUE;
-       }
+if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(rmi->cmb_repos))), NULL) <= 1) {
+       popup_error(rmi->dialog, _("Cannot delete the last repository - there must be at lease one repository."));
+       return TRUE;
+}
 
-       snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
-                _("Confirm delete of repository"),
-                gtk_combo_box_get_active_text(GTK_COMBO_BOX(rmi->cmb_repos)));
-       confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
-
-       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
-               gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos),
-                                         active);
-               gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), active);
-               rmi->repo_edits = g_list_remove_link(rmi->repo_edits,
-                                                    g_list_nth(rmi->repo_edits,
-                                                               active));
-               gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos),
-                                        MAX(0, active - 1));
-       }
+g_snprintf(buffer, sizeof(buffer), "%s:\n%s\n",
+        _("Confirm delete of repository"),
+        gtk_combo_box_get_active_text(GTK_COMBO_BOX(rmi->cmb_repos)));
+confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
 
-       gtk_widget_destroy(confirm);
+if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+       gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), active);
+       gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), active);
+       rmi->repo_edits = g_list_remove_link(rmi->repo_edits, g_list_nth(rmi->repo_edits, active));
+       gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), MAX(0, active - 1));
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gtk_widget_destroy(confirm);
+
+return TRUE;
 }
 
-RepoEditInfo *repoman_dialog_add_repo(RepoManInfo * rmi, gchar * name)
+static RepoEditInfo *
+repoman_dialog_add_repo(RepoManInfo * rmi, gchar * name)
 {
-       GtkWidget *vbox;
-       GtkWidget *table;
-       GtkWidget *label;
-       GtkWidget *hbox;
-       RepoEditInfo *rei = g_new(RepoEditInfo, 1);
-       printf("%s(%s)\n", __PRETTY_FUNCTION__, name);
+GtkWidget *vbox;
+GtkWidget *table;
+GtkWidget *label;
+GtkWidget *hbox;
+RepoEditInfo *rei = g_new(RepoEditInfo, 1);
+
+rei->name = name;
+
+/* Maps page. */
+gtk_notebook_append_page(GTK_NOTEBOOK(rmi->notebook), vbox = gtk_vbox_new(FALSE, 4), gtk_label_new(name));
+
+gtk_box_pack_start(GTK_BOX(vbox), table = gtk_table_new(2, 2, FALSE), FALSE, FALSE, 0);
+/* Map download URI. */
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("URL Format")), 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), rei->txt_url = gtk_entry_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+
+/* Map Directory. */
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Cache Dir.")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
+gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
+gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
+gtk_box_pack_start(GTK_BOX(hbox), rei->txt_cache_dir = gtk_entry_new(), TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(hbox), rei->btn_browse = gtk_button_new_with_label(_("Browse...")), FALSE, FALSE, 0);
+
+/* Initialize cache dir */
+{
+       gchar *cache_base = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
+       gchar *cache_dir = gnome_vfs_uri_make_full_from_relative(cache_base, name);
+       gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), cache_dir);
+       g_free(cache_dir);
+       g_free(cache_base);
+}
 
-       rei->name = name;
+gtk_box_pack_start(GTK_BOX(vbox), table = gtk_table_new(3, 2, FALSE), FALSE, FALSE, 0);
 
-       /* Maps page. */
-       gtk_notebook_append_page(GTK_NOTEBOOK(rmi->notebook),
-                                vbox = gtk_vbox_new(FALSE, 4),
-                                gtk_label_new(name));
+/* Download Zoom Steps. */
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Download Zoom Steps")), 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), rei->num_dl_zoom_steps = hildon_controlbar_new(), 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 2, 4);
+hildon_controlbar_set_range(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), 1, 4);
+hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), REPO_DEFAULT_DL_ZOOM_STEPS);
+force_min_visible_bars(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), 1);
 
-       gtk_box_pack_start(GTK_BOX(vbox),
-                          table = gtk_table_new(2, 2, FALSE), FALSE, FALSE, 0);
-       /* Map download URI. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("URL Format")),
-                        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),
-                        rei->txt_url = gtk_entry_new(),
-                        1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-
-       /* Map Directory. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Cache Dir.")),
-                        0, 1, 1, 2, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-       gtk_table_attach(GTK_TABLE(table),
-                        hbox = gtk_hbox_new(FALSE, 4),
-                        1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          rei->txt_cache_dir = gtk_entry_new(), TRUE, TRUE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          rei->btn_browse =
-                          gtk_button_new_with_label(_("Browse...")), FALSE,
-                          FALSE, 0);
-
-       /* Initialize cache dir */
-       {
-               gchar *cache_base =
-                   gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
-               gchar *cache_dir =
-                   gnome_vfs_uri_make_full_from_relative(cache_base, name);
-               gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), cache_dir);
-               g_free(cache_dir);
-               g_free(cache_base);
-       }
+/* Download Zoom Steps. */
+gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("View Zoom Steps")), 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), rei->num_view_zoom_steps = hildon_controlbar_new(), 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 2, 4);
+hildon_controlbar_set_range(HILDON_CONTROLBAR(rei->num_view_zoom_steps), 1, 4);
+hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps), REPO_DEFAULT_VIEW_ZOOM_STEPS);
+force_min_visible_bars(HILDON_CONTROLBAR(rei->num_view_zoom_steps), 1);
 
-       gtk_box_pack_start(GTK_BOX(vbox),
-                          table = gtk_table_new(3, 2, FALSE), FALSE, FALSE, 0);
+gtk_table_attach(GTK_TABLE(table), label = gtk_vseparator_new(), 2, 3, 0, 2, GTK_FILL, GTK_FILL, 4, 4);
 
-       /* Download Zoom Steps. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("Download Zoom Steps")),
-                        0, 1, 0, 1, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f),
-                        1, 2, 0, 1, GTK_FILL, 0, 2, 4);
-       gtk_container_add(GTK_CONTAINER(label),
-                         rei->num_dl_zoom_steps = hildon_controlbar_new());
-       hildon_controlbar_set_range(HILDON_CONTROLBAR(rei->num_dl_zoom_steps),
-                                   1, 4);
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps),
-                                   REPO_DEFAULT_DL_ZOOM_STEPS);
-       force_min_visible_bars(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), 1);
-
-       /* Download Zoom Steps. */
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_label_new(_("View Zoom Steps")),
-                        0, 1, 1, 2, GTK_FILL, 0, 2, 4);
-       gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f),
-                        1, 2, 1, 2, GTK_FILL, 0, 2, 4);
-       gtk_container_add(GTK_CONTAINER(label),
-                         rei->num_view_zoom_steps = hildon_controlbar_new());
-       hildon_controlbar_set_range(HILDON_CONTROLBAR(rei->num_view_zoom_steps),
-                                   1, 4);
-       hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps),
-                                   REPO_DEFAULT_VIEW_ZOOM_STEPS);
-       force_min_visible_bars(HILDON_CONTROLBAR(rei->num_view_zoom_steps), 1);
-
-       gtk_table_attach(GTK_TABLE(table),
-                        label = gtk_vseparator_new(),
-                        2, 3, 0, 2, GTK_FILL, GTK_FILL, 4, 4);
-
-       /* Double-size. */
-       gtk_table_attach(GTK_TABLE(table),
-                        rei->chk_double_size =
-                        gtk_check_button_new_with_label(_("Double Pixels")), 3,
-                        4, 0, 1, GTK_FILL, GTK_FILL, 0, 4);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_double_size),
-                                    FALSE);
-
-       /* Next-able */
-       gtk_table_attach(GTK_TABLE(table),
-                        rei->chk_nextable =
-                        gtk_check_button_new_with_label(_("Next-able")), 3, 4,
-                        1, 2, GTK_FILL, GTK_FILL, 0, 4);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_nextable),
-                                    TRUE);
-
-       rmi->repo_edits = g_list_append(rmi->repo_edits, rei);
+/* Double-size. */
+gtk_table_attach(GTK_TABLE(table), rei->chk_double_size = gtk_check_button_new_with_label(_("Double Pixels")), 3, 4, 0, 1, GTK_FILL, GTK_FILL, 0, 4);
+gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_double_size), FALSE);
 
-       /* Connect signals. */
-       rei->browse_info.dialog = rmi->dialog;
-       rei->browse_info.txt = rei->txt_cache_dir;
-       g_signal_connect(G_OBJECT(rei->btn_browse), "clicked",
-                        G_CALLBACK(repoman_dialog_browse), &rei->browse_info);
-
-       gtk_widget_show_all(vbox);
-
-       gtk_combo_box_append_text(GTK_COMBO_BOX(rmi->cmb_repos), name);
-       gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos),
-                                gtk_tree_model_iter_n_children(GTK_TREE_MODEL
-                                                               (gtk_combo_box_get_model
-                                                                (GTK_COMBO_BOX
-                                                                 (rmi->
-                                                                  cmb_repos))),
-                                                               NULL) - 1);
-
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return rei;
+/* Next-able */
+gtk_table_attach(GTK_TABLE(table), rei->chk_nextable = gtk_check_button_new_with_label(_("Next-able")), 3, 4, 1, 2, GTK_FILL, GTK_FILL, 0, 4);
+gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_nextable), TRUE);
+
+rmi->repo_edits = g_list_append(rmi->repo_edits, rei);
+
+/* Connect signals. */
+rei->browse_info.dialog = rmi->dialog;
+rei->browse_info.txt = rei->txt_cache_dir;
+g_signal_connect(G_OBJECT(rei->btn_browse), "clicked", G_CALLBACK(repoman_dialog_browse), &rei->browse_info);
+
+gtk_widget_show_all(vbox);
+
+gtk_combo_box_append_text(GTK_COMBO_BOX(rmi->cmb_repos), name);
+gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos),
+       gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX (rmi->cmb_repos))), NULL) - 1);
+
+return rei;
 }
 
-gboolean repoman_dialog_new(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_dialog_new(GtkWidget * widget, RepoManInfo * rmi)
 {
-       GtkWidget *hbox;
-       GtkWidget *label;
-       GtkWidget *txt_name;
-       GtkWidget *dialog;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+GtkWidget *hbox;
+GtkWidget *label;
+GtkWidget *txt_name;
+GtkWidget *dialog;
 
-       dialog = gtk_dialog_new_with_buttons(_("New Repository"),
-                                            GTK_WINDOW(rmi->dialog),
-                                            GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                            GTK_RESPONSE_ACCEPT,
-                                            GTK_STOCK_CANCEL,
-                                            GTK_RESPONSE_REJECT, NULL);
+dialog = gtk_dialog_new_with_buttons(_("New Repository"),
+                                    GTK_WINDOW(rmi->dialog),
+                                    GTK_DIALOG_MODAL, GTK_STOCK_OK,
+                                    GTK_RESPONSE_ACCEPT,
+                                    GTK_STOCK_CANCEL,
+                                    GTK_RESPONSE_REJECT, NULL);
 
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                          hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 4);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 4);
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          label = gtk_label_new(_("Name")), FALSE, FALSE, 0);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          txt_name = gtk_entry_new(), TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Name")), FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(hbox), txt_name = gtk_entry_new(), TRUE, TRUE, 0);
 
-       gtk_widget_show_all(dialog);
+gtk_widget_show_all(dialog);
 
-       while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               repoman_dialog_add_repo(rmi,
-                                       g_strdup(gtk_entry_get_text
-                                                (GTK_ENTRY(txt_name))));
-               break;
-       }
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
+               repoman_dialog_add_repo(rmi, g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_name))));
+       break;
+}
 
-       gtk_widget_destroy(dialog);
+gtk_widget_destroy(dialog);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean repoman_reset(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean
+repoman_reset(GtkWidget * widget, RepoManInfo * rmi)
 {
-       GtkWidget *confirm;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
-                                              _
-                                              ("Replace all repositories with the default repository?"));
-
-       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
-               /* First, delete all existing repositories. */
-               while (rmi->repo_edits) {
-                       gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos),
-                                                 0);
-                       gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook),
-                                                0);
-                       rmi->repo_edits =
-                           g_list_remove_link(rmi->repo_edits,
-                                              g_list_first(rmi->repo_edits));
+GtkWidget *confirm;
+
+confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
+               _("Replace all repositories with the default repository?"));
+
+if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+       /* First, delete all existing repositories. */
+       while (rmi->repo_edits) {
+               gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), 0);
+                       gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), 0);
+                       rmi->repo_edits = g_list_remove_link(rmi->repo_edits, g_list_first(rmi->repo_edits));
                }
 
-               /* Now, add the default repository. */
-               repoman_dialog_add_repo(rmi, REPO_DEFAULT_NAME);
-               gtk_entry_set_text(GTK_ENTRY
-                                  (((RepoEditInfo *) rmi->repo_edits->data)->
-                                   txt_url), REPO_DEFAULT_MAP_URI);
+       /* Now, add the default repository. */
+       repoman_dialog_add_repo(rmi, REPO_DEFAULT_NAME);
+       gtk_entry_set_text(GTK_ENTRY(((RepoEditInfo *) rmi->repo_edits->data)->txt_url), REPO_DEFAULT_MAP_URI);
 
-               gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), 0);
-       }
-       gtk_widget_destroy(confirm);
+       gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), 0);
+}
+gtk_widget_destroy(confirm);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean repoman_download(GtkWidget * widget, RepoManInfo * rmi)
+static gboolean 
+repoman_download(GtkWidget * widget, RepoManInfo * rmi)
 {
-       GtkWidget *confirm;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       confirm = hildon_note_new_confirmation(GTK_WINDOW(rmi->dialog),
-                                              _
-                                              ("Maemo Mapper will now download and add a list of "
-                                               "possibly-duplicate repositories from the internet.  "
-                                               "Continue?"));
-
-       if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
-               gchar *bytes;
-               gchar *head;
-               gchar *tail;
-               gint size;
-               GnomeVFSResult vfs_result;
-               printf("%s()\n", __PRETTY_FUNCTION__);
-
-               /* Get repo config file from www.gnuite.com. */
-               if (GNOME_VFS_OK !=
-                   (vfs_result =
-                    gnome_vfs_read_entire_file
-                    ("http://www.gnuite.com/nokia770/maemo-mapper/repos.txt",
-                     &size, &bytes))) {
-                       popup_error(rmi->dialog,
-                                   _
-                                   ("An error occurred while retrieving the repositories.  "
-                                    "The web service may be temporarily down."));
-                       g_printerr("Error while download repositories: %s\n",
-                                  gnome_vfs_result_to_string(vfs_result));
-               }
+GtkWidget *confirm;
+
+confirm = hildon_note_new_confirmation(GTK_WINDOW(rmi->dialog),
+                                      _("Mapper will now download and add a list of "
+                                       "possibly-duplicate repositories from the internet.  "
+                                       "Continue?"));
+
+if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
+       gchar *bytes;
+       gchar *head;
+       gchar *tail;
+       gint size;
+       GnomeVFSResult vfs_result;
+
+       /* Get repo config file from www.gnuite.com. */
+       if (GNOME_VFS_OK != (vfs_result = gnome_vfs_read_entire_file(MAP_REPO_LIST_URL, &size, &bytes))) {
+               popup_error(rmi->dialog,
+                           _("An error occurred while retrieving the repositories.  "
+                            "The web service may be temporarily down."));
+               g_printerr("Error while download repositories: %s\n", gnome_vfs_result_to_string(vfs_result));
+       } else {
                /* Parse each line as a reposotory. */
-               else {
-                       for (head = bytes; head && *head; head = tail) {
-                               RepoData *rd;
-                               RepoEditInfo *rei;
-                               tail = strchr(head, '\n');
-                               *tail++ = '\0';
-                               rd = config_parse_repo(head);
-                               rei =
-                                   repoman_dialog_add_repo(rmi,
-                                                           g_strdup(rd->name));
-                               /* Initialize fields with data from the RepoData object. */
-                               gtk_entry_set_text(GTK_ENTRY(rei->txt_url),
-                                                  rd->url);
-                               gtk_entry_set_text(GTK_ENTRY
-                                                  (rei->txt_cache_dir),
-                                                  rd->cache_dir);
-                               hildon_controlbar_set_value(HILDON_CONTROLBAR
-                                                           (rei->
-                                                            num_dl_zoom_steps),
-                                                           rd->dl_zoom_steps);
-                               hildon_controlbar_set_value(HILDON_CONTROLBAR
-                                                           (rei->
-                                                            num_view_zoom_steps),
-                                                           rd->
-                                                           view_zoom_steps);
-                               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                                            (rei->
-                                                             chk_double_size),
-                                                            rd->double_size);
-                               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                                            (rei->
-                                                             chk_nextable),
-                                                            rd->nextable);
-                       }
-                       g_free(bytes);
+               for (head = bytes; head && *head; head = tail) {
+                       RepoData *rd;
+                       RepoEditInfo *rei;
+                       tail = strchr(head, '\n');
+                       *tail++ = '\0';
+                       rd = config_parse_repo(head);
+                       rei = repoman_dialog_add_repo(rmi, g_strdup(rd->name));
+                       /* Initialize fields with data from the RepoData object. */
+                       gtk_entry_set_text(GTK_ENTRY(rei->txt_url), rd->url);
+                       gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), rd->cache_dir);
+                       hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), rd->dl_zoom_steps);
+                       hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps), rd->view_zoom_steps);
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_double_size), rd->double_size);
+                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_nextable), rd->nextable);
                }
+               g_free(bytes);
        }
-       gtk_widget_destroy(confirm);
+}
+gtk_widget_destroy(confirm);
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+return TRUE;
 }
 
-gboolean repoman_dialog()
+gboolean 
+repoman_dialog()
 {
-       RepoManInfo rmi;
-       GtkWidget *hbox;
-       GtkWidget *btn_rename;
-       GtkWidget *btn_delete;
-       GtkWidget *btn_new;
-       GtkWidget *btn_reset;
-       GtkWidget *btn_download;
-       guint i, curr_repo_index = 0;
-       GList *curr;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       rmi.dialog = gtk_dialog_new_with_buttons(_("Manage Repositories"),
-                                                GTK_WINDOW(_window),
-                                                GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                                GTK_RESPONSE_ACCEPT, NULL);
-
-#ifdef WITH_HILDON
-       /* Enable the help button. */
-       ossohelp_dialog_help_enable(GTK_DIALOG(rmi.dialog), HELP_ID_REPOMAN,
-                                   _osso);
-#endif
-
-       /* Reset button. */
-       gtk_container_add(GTK_CONTAINER(GTK_DIALOG(rmi.dialog)->action_area),
-                         btn_reset = gtk_button_new_with_label(_("Reset...")));
-       g_signal_connect(G_OBJECT(btn_reset), "clicked",
-                        G_CALLBACK(repoman_reset), &rmi);
-
-       /* Download button. */
-       gtk_container_add(GTK_CONTAINER(GTK_DIALOG(rmi.dialog)->action_area),
-                         btn_download =
-                         gtk_button_new_with_label(_("Download...")));
-       g_signal_connect(G_OBJECT(btn_download), "clicked",
-                        G_CALLBACK(repoman_download), &rmi);
+RepoManInfo rmi;
+GtkWidget *hbox;
+GtkWidget *btn_rename;
+GtkWidget *btn_delete;
+GtkWidget *btn_new;
+GtkWidget *btn_reset;
+GtkWidget *btn_download;
+guint i, curr_repo_index = 0;
+GList *curr;
+
+rmi.dialog = gtk_dialog_new_with_buttons(_("Manage Repositories"),
+                                        GTK_WINDOW(_window),
+                                        GTK_DIALOG_MODAL, GTK_STOCK_OK,
+                                        GTK_RESPONSE_ACCEPT, NULL);
+
+help_dialog_help_enable(GTK_DIALOG(rmi.dialog), HELP_ID_REPOMAN);
+
+/* Reset button. */
+gtk_container_add(GTK_CONTAINER(GTK_DIALOG(rmi.dialog)->action_area),
+                 btn_reset = gtk_button_new_with_label(_("Reset...")));
+g_signal_connect(G_OBJECT(btn_reset), "clicked", G_CALLBACK(repoman_reset), &rmi);
+
+/* Download button. */
+gtk_container_add(GTK_CONTAINER(GTK_DIALOG(rmi.dialog)->action_area),
+                 btn_download = gtk_button_new_with_label(_("Download...")));
+g_signal_connect(G_OBJECT(btn_download), "clicked", G_CALLBACK(repoman_download), &rmi);
+
+/* Cancel button. */
+gtk_dialog_add_button(GTK_DIALOG(rmi.dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+
+hbox = gtk_hbox_new(FALSE, 4);
+
+gtk_box_pack_start(GTK_BOX(hbox), rmi.cmb_repos = gtk_combo_box_new_text(), TRUE, TRUE, 4);
+
+gtk_box_pack_start(GTK_BOX(hbox), gtk_vseparator_new(), FALSE, FALSE, 4);
+gtk_box_pack_start(GTK_BOX(hbox), btn_rename = gtk_button_new_with_label(_("Rename...")), FALSE, FALSE, 4);
+gtk_box_pack_start(GTK_BOX(hbox), btn_delete = gtk_button_new_with_label(_("Delete...")), FALSE, FALSE, 4);
+gtk_box_pack_start(GTK_BOX(hbox), btn_new = gtk_button_new_with_label(_("New...")), FALSE, FALSE, 4);
+
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox), hbox, FALSE, FALSE, 4);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox), gtk_hseparator_new(), TRUE, TRUE, 4);
+gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox), rmi.notebook = gtk_notebook_new(), TRUE, TRUE, 4);
+
+gtk_notebook_set_show_tabs(GTK_NOTEBOOK(rmi.notebook), FALSE);
+gtk_notebook_set_show_border(GTK_NOTEBOOK(rmi.notebook), FALSE);
+
+rmi.repo_edits = NULL;
+
+/* Populate combo box and pages in notebook. */
+for (i = 0, curr = _repo_list; curr; curr = curr->next, i++) {
+       RepoData *rd = (RepoData *) curr->data;
+       RepoEditInfo *rei = repoman_dialog_add_repo(&rmi, g_strdup(rd->name));
+
+       /* Initialize fields with data from the RepoData object. */
+       gtk_entry_set_text(GTK_ENTRY(rei->txt_url), rd->url);
+       gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), rd->cache_dir);
+       hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), rd->dl_zoom_steps);
+       hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps), rd->view_zoom_steps);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_double_size), rd->double_size);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_nextable), rd->nextable);
+       if (rd == _curr_repo)
+               curr_repo_index = i;
+}
 
-       /* Cancel button. */
-       gtk_dialog_add_button(GTK_DIALOG(rmi.dialog),
-                             GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+/* Connect signals. */
+g_signal_connect(G_OBJECT(btn_rename), "clicked", G_CALLBACK(repoman_dialog_rename), &rmi);
+g_signal_connect(G_OBJECT(btn_delete), "clicked", G_CALLBACK(repoman_dialog_delete), &rmi);
+g_signal_connect(G_OBJECT(btn_new), "clicked", G_CALLBACK(repoman_dialog_new), &rmi);
+g_signal_connect(G_OBJECT(rmi.cmb_repos), "changed", G_CALLBACK(repoman_dialog_select), &rmi);
+gtk_combo_box_set_active(GTK_COMBO_BOX(rmi.cmb_repos), curr_repo_index);
+gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi.notebook), curr_repo_index);
 
-       hbox = gtk_hbox_new(FALSE, 4);
+gtk_widget_show_all(rmi.dialog);
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          rmi.cmb_repos =
-                          gtk_combo_box_new_text(), TRUE, TRUE, 4);
+while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(rmi.dialog))) {
+       /* Iterate through repos and verify each. */
+       gboolean verified = TRUE;
+       gint i;
+       GList *curr;
+       gchar *old_curr_repo_name = _curr_repo->name;
 
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          gtk_vseparator_new(), FALSE, FALSE, 4);
-       gtk_box_pack_start(GTK_BOX(hbox),
-                          btn_rename =
-                          gtk_button_new_with_label(_("Rename...")), FALSE,
-                          FALSE, 4);
-       gtk_box_pack_start(GTK_BOX(hbox), btn_delete =
-                          gtk_button_new_with_label(_("Delete...")), FALSE,
-                          FALSE, 4);
-       gtk_box_pack_start(GTK_BOX(hbox), btn_new =
-                          gtk_button_new_with_label(_("New...")), FALSE, FALSE,
-                          4);
-
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox),
-                          hbox, FALSE, FALSE, 4);
-
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox),
-                          gtk_hseparator_new(), TRUE, TRUE, 4);
-       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox),
-                          rmi.notebook = gtk_notebook_new(), TRUE, TRUE, 4);
-
-       gtk_notebook_set_show_tabs(GTK_NOTEBOOK(rmi.notebook), FALSE);
-       gtk_notebook_set_show_border(GTK_NOTEBOOK(rmi.notebook), FALSE);
-
-       rmi.repo_edits = NULL;
-
-       /* Populate combo box and pages in notebook. */
-       for (i = 0, curr = _repo_list; curr; curr = curr->next, i++) {
-               RepoData *rd = (RepoData *) curr->data;
-               RepoEditInfo *rei =
-                   repoman_dialog_add_repo(&rmi, g_strdup(rd->name));
-
-               /* Initialize fields with data from the RepoData object. */
-               gtk_entry_set_text(GTK_ENTRY(rei->txt_url), rd->url);
-               gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir),
-                                  rd->cache_dir);
-               hildon_controlbar_set_value(HILDON_CONTROLBAR
-                                           (rei->num_dl_zoom_steps),
-                                           rd->dl_zoom_steps);
-               hildon_controlbar_set_value(HILDON_CONTROLBAR
-                                           (rei->num_view_zoom_steps),
-                                           rd->view_zoom_steps);
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                            (rei->chk_double_size),
-                                            rd->double_size);
-               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                            (rei->chk_nextable), rd->nextable);
-               if (rd == _curr_repo)
-                       curr_repo_index = i;
+       for (i = 0, curr = rmi.repo_edits; verified && curr; curr = curr->next, i++) {
+               RepoEditInfo *rei = curr->data;
+               gchar *expanded = gnome_vfs_expand_initial_tilde(gtk_entry_get_text(GTK_ENTRY(rei->txt_cache_dir)));
+               verified = repo_make_cache_dir(rei->name, expanded,     rmi.dialog);
+               g_free(expanded);
        }
-
-       /* Connect signals. */
-       g_signal_connect(G_OBJECT(btn_rename), "clicked",
-                        G_CALLBACK(repoman_dialog_rename), &rmi);
-       g_signal_connect(G_OBJECT(btn_delete), "clicked",
-                        G_CALLBACK(repoman_dialog_delete), &rmi);
-       g_signal_connect(G_OBJECT(btn_new), "clicked",
-                        G_CALLBACK(repoman_dialog_new), &rmi);
-       g_signal_connect(G_OBJECT(rmi.cmb_repos), "changed",
-                        G_CALLBACK(repoman_dialog_select), &rmi);
-       gtk_combo_box_set_active(GTK_COMBO_BOX(rmi.cmb_repos), curr_repo_index);
-       gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi.notebook),
-                                     curr_repo_index);
-
-       gtk_widget_show_all(rmi.dialog);
-
-       while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(rmi.dialog))) {
-               /* Iterate through repos and verify each. */
-               gboolean verified = TRUE;
-               gint i;
-               GList *curr;
-               gchar *old_curr_repo_name = _curr_repo->name;
-               for (i = 0, curr = rmi.repo_edits;
-                    verified && curr; curr = curr->next, i++) {
-                       RepoEditInfo *rei = curr->data;
-                       gchar *expanded =
-                           gnome_vfs_expand_initial_tilde(gtk_entry_get_text
-                                                          (GTK_ENTRY
-                                                           (rei->
-                                                            txt_cache_dir)));
-                       verified =
-                           repo_make_cache_dir(rei->name, expanded,
-                                               rmi.dialog);
-                       g_free(expanded);
-               }
-               if (!verified) {
-                       gtk_combo_box_set_active(GTK_COMBO_BOX(rmi.cmb_repos),
-                                                i - 1);
-                       continue;
-               }
-
-               /* We're good to replace.  Remove old _repo_list menu items. */
-               menu_maps_remove_repos();
-               /* But keep the repo list in memory, in case downloads are using it. */
-               _repo_list = NULL;
-
-               /* Write new _repo_list. */
-               curr_repo_index =
-                   gtk_combo_box_get_active(GTK_COMBO_BOX(rmi.cmb_repos));
-               _curr_repo = NULL;
-               for (i = 0, curr = rmi.repo_edits; curr; curr = curr->next, i++) {
-                       RepoEditInfo *rei = curr->data;
-                       RepoData *rd = g_new(RepoData, 1);
-                       rd->name = g_strdup(rei->name);
-                       rd->url =
-                           g_strdup(gtk_entry_get_text
-                                    (GTK_ENTRY(rei->txt_url)));
-                       rd->cache_dir =
-                           gnome_vfs_expand_initial_tilde(gtk_entry_get_text
-                                                          (GTK_ENTRY
-                                                           (rei->
-                                                            txt_cache_dir)));
-                       rd->dl_zoom_steps =
-                           hildon_controlbar_get_value(HILDON_CONTROLBAR
-                                                       (rei->
-                                                        num_dl_zoom_steps));
-                       rd->view_zoom_steps =
-                           hildon_controlbar_get_value(HILDON_CONTROLBAR
-                                                       (rei->
-                                                        num_view_zoom_steps));
-                       rd->double_size =
-                           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                                        (rei->
-                                                         chk_double_size));
-                       rd->nextable =
-                           gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                                        (rei->chk_nextable));
-                       set_repo_type(rd);
-
-                       _repo_list = g_list_append(_repo_list, rd);
-
-                       if (!_curr_repo
-                           && !strcmp(old_curr_repo_name, rd->name))
-                               repo_set_curr(rd);
-                       else if (i == curr_repo_index)
-                               repo_set_curr(rd);
-               }
-               if (!_curr_repo)
-                       repo_set_curr((RepoData *) g_list_first(_repo_list)->
-                                     data);
-               menu_maps_add_repos();
-
-               config_save_repo();
-               break;
+       if (!verified) {
+               gtk_combo_box_set_active(GTK_COMBO_BOX(rmi.cmb_repos), i - 1);
+               continue;
        }
 
-       gtk_widget_hide(rmi.dialog);    /* Destroying causes a crash (!?!?!??!) */
+       /* But keep the repo list in memory, in case downloads are using it. */
+       _repo_list = NULL;
+
+       /* Write new _repo_list. */
+       curr_repo_index = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi.cmb_repos));
+       _curr_repo = NULL;
+       for (i = 0, curr = rmi.repo_edits; curr; curr = curr->next, i++) {
+               RepoEditInfo *rei = curr->data;
+               RepoData *rd = g_new(RepoData, 1);
+               rd->name = g_strdup(rei->name);
+               rd->url = g_strdup(gtk_entry_get_text(GTK_ENTRY(rei->txt_url)));
+               rd->cache_dir = gnome_vfs_expand_initial_tilde(gtk_entry_get_text(GTK_ENTRY(rei->txt_cache_dir)));
+               rd->dl_zoom_steps = hildon_controlbar_get_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps));
+               rd->view_zoom_steps = hildon_controlbar_get_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps));
+               rd->double_size = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rei->chk_double_size));
+               rd->nextable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rei->chk_nextable));
+               set_repo_type(rd);
+
+               _repo_list = g_list_append(_repo_list, rd);
+
+               if (!_curr_repo && !strcmp(old_curr_repo_name, rd->name))
+                       repo_set_curr(rd);
+               else if (i == curr_repo_index)
+                       repo_set_curr(rd);
+       }
+       if (!_curr_repo)
+                       repo_set_curr((RepoData *) g_list_first(_repo_list)->data);
 
-       map_set_zoom(_zoom);    /* make sure we're at an appropriate zoom level. */
+       menu_maps_add_repos();
+       config_save_repo();
+       break;
+}
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+gtk_widget_hide(rmi.dialog);   /* Destroying causes a crash (!?!?!??!) */
+map_set_zoom(_zoom);   /* make sure we're at an appropriate zoom level. */
+return TRUE;
 }
 
-gboolean
+static gboolean
 mapman_by_area(gfloat start_lat, gfloat start_lon,
               gfloat end_lat, gfloat end_lon, MapmanInfo * mapman_info,
               gboolean is_deleting, gboolean is_overwriting)
 {
-       guint start_unitx, start_unity, end_unitx, end_unity;
-       guint num_maps = 0;
-       guint i;
-       gchar buffer[80];
-       GtkWidget *confirm;
-       printf("%s()\n", __PRETTY_FUNCTION__);
+guint start_unitx, start_unity, end_unitx, end_unity;
+guint num_maps = 0;
+guint i;
+gchar buffer[80];
+GtkWidget *confirm;
+
+latlon2unit(start_lat, start_lon, start_unitx, start_unity);
+latlon2unit(end_lat, end_lon, end_unitx, end_unity);
+
+/* Swap if they specified flipped lats or lons. */
+if (start_unitx > end_unitx) {
+       guint swap = start_unitx;
+       start_unitx = end_unitx;
+       end_unitx = swap;
+}
+if (start_unity > end_unity) {
+       guint swap = start_unity;
+       start_unity = end_unity;
+       end_unity = swap;
+}
 
-       latlon2unit(start_lat, start_lon, start_unitx, start_unity);
-       latlon2unit(end_lat, end_lon, end_unitx, end_unity);
+/* First, get the number of maps to download. */
+for (i = 0; i < MAX_ZOOM; i++) {
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
+               guint start_tilex, start_tiley, end_tilex, end_tiley;
+               start_tilex = unit2ztile(start_unitx, i);
+               start_tiley = unit2ztile(start_unity, i);
+               end_tilex = unit2ztile(end_unitx, i);
+               end_tiley = unit2ztile(end_unity, i);
+               num_maps += (end_tilex - start_tilex + 1) * (end_tiley - start_tiley + 1);
+               }
+}
 
-       /* Swap if they specified flipped lats or lons. */
-       if (start_unitx > end_unitx) {
-               guint swap = start_unitx;
-               start_unitx = end_unitx;
-               end_unitx = swap;
-       }
-       if (start_unity > end_unity) {
-               guint swap = start_unity;
-               start_unity = end_unity;
-               end_unity = swap;
-       }
+if (is_deleting) {
+       g_snprintf(buffer, sizeof(buffer), "%s %d %s", _("Confirm DELETION of"), num_maps, _("maps "));
+} else {
+       g_snprintf(buffer, sizeof(buffer), "%s %d %s\n(%s %.2f MB)\n", _("Confirm download of"),
+               num_maps, _("maps"), _("up to about"), num_maps * (strstr(_curr_repo->url, "%s") ? 18e-3 : 6e-3));
+}
+confirm = hildon_note_new_confirmation(GTK_WINDOW(mapman_info->dialog), buffer);
 
-       /* First, get the number of maps to download. */
-       for (i = 0; i < MAX_ZOOM; i++) {
-               if (gtk_toggle_button_get_active
-                   (GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
-                       guint start_tilex, start_tiley, end_tilex, end_tiley;
-                       start_tilex = unit2ztile(start_unitx, i);
-                       start_tiley = unit2ztile(start_unity, i);
-                       end_tilex = unit2ztile(end_unitx, i);
-                       end_tiley = unit2ztile(end_unity, i);
-                       num_maps += (end_tilex - start_tilex + 1)
-                           * (end_tiley - start_tiley + 1);
-               }
-       }
+if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) {
+       gtk_widget_destroy(confirm);
+       return FALSE;
+}
 
-       if (is_deleting) {
-               snprintf(buffer, sizeof(buffer), "%s %d %s",
-                        _("Confirm DELETION of"), num_maps, _("maps "));
-       } else {
-               snprintf(buffer, sizeof(buffer),
-                        "%s %d %s\n(%s %.2f MB)\n", _("Confirm download of"),
-                        num_maps, _("maps"), _("up to about"),
-                        num_maps *
-                        (strstr(_curr_repo->url, "%s") ? 18e-3 : 6e-3));
-       }
-       confirm =
-           hildon_note_new_confirmation(GTK_WINDOW(mapman_info->dialog),
-                                        buffer);
-
-       if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) {
-               gtk_widget_destroy(confirm);
-               vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
-               return FALSE;
+for (i = 0; i < MAX_ZOOM; i++) {
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
+               guint start_tilex, start_tiley, end_tilex, end_tiley;
+               guint tilex, tiley;
+               start_tilex = unit2ztile(start_unitx, i);
+               start_tiley = unit2ztile(start_unity, i);
+               end_tilex = unit2ztile(end_unitx, i);
+               end_tiley = unit2ztile(end_unity, i);
+
+               for (tiley = start_tiley; tiley <= end_tiley; tiley++)
+                       for (tilex = start_tilex; tilex <= end_tilex; tilex++)
+                               map_initiate_download(tilex, tiley, i, is_deleting ? 0 : (is_overwriting ?
+                                                        -INITIAL_DOWNLOAD_RETRIES : INITIAL_DOWNLOAD_RETRIES));
        }
-       for (i = 0; i < MAX_ZOOM; i++) {
-               if (gtk_toggle_button_get_active
-                   (GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
-                       guint start_tilex, start_tiley, end_tilex, end_tiley;
-                       guint tilex, tiley;
-                       start_tilex = unit2ztile(start_unitx, i);
-                       start_tiley = unit2ztile(start_unity, i);
-                       end_tilex = unit2ztile(end_unitx, i);
-                       end_tiley = unit2ztile(end_unity, i);
-                       for (tiley = start_tiley; tiley <= end_tiley; tiley++)
-                               for (tilex = start_tilex; tilex <= end_tilex;
-                                    tilex++)
-                                       map_initiate_download(tilex, tiley, i,
-                                                             is_deleting ? 0
-                                                             : (is_overwriting
-                                                                ?
-                                                                -INITIAL_DOWNLOAD_RETRIES
-                                                                :
-                                                                INITIAL_DOWNLOAD_RETRIES));
-               }
-       }
-       gtk_widget_destroy(confirm);
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+}
+gtk_widget_destroy(confirm);
+return TRUE;
 }
 
-gboolean
-mapman_by_route(MapmanInfo * mapman_info,
-               gboolean is_deleting, gboolean is_overwriting)
+static gboolean
+mapman_by_route(MapmanInfo * mapman_info, gboolean is_deleting, gboolean is_overwriting)
 {
-       GtkWidget *confirm;
-       guint prev_tilex, prev_tiley, num_maps = 0, i;
-       Point *curr;
-       gchar buffer[80];
-       guint radius =
-           hildon_number_editor_get_value(HILDON_NUMBER_EDITOR
-                                          (mapman_info->num_route_radius));
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       /* First, get the number of maps to download. */
-       for (i = 0; i < MAX_ZOOM; i++) {
-               if (gtk_toggle_button_get_active
-                   (GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
-                       prev_tilex = 0;
-                       prev_tiley = 0;
-                       for (curr = _route.head - 1; curr++ != _route.tail;) {
-                               if (curr->unity) {
-                                       guint tilex =
-                                           unit2ztile(curr->unitx, i);
-                                       guint tiley =
-                                           unit2ztile(curr->unity, i);
-                                       if (tilex != prev_tilex
-                                           || tiley != prev_tiley) {
-                                               if (prev_tiley)
-                                                       num_maps +=
-                                                           (abs
-                                                            ((gint) tilex -
-                                                             prev_tilex) + 1)
-                                                           *
-                                                           (abs
-                                                            ((gint) tiley -
-                                                             prev_tiley) + 1) -
-                                                           1;
-                                               prev_tilex = tilex;
-                                               prev_tiley = tiley;
-                                       }
+GtkWidget *confirm;
+guint prev_tilex, prev_tiley, num_maps = 0, i;
+Point *curr;
+gchar buffer[80];
+guint radius = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(mapman_info->num_route_radius));
+
+/* First, get the number of maps to download. */
+for (i = 0; i < MAX_ZOOM; i++) {
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
+               prev_tilex = 0;
+               prev_tiley = 0;
+
+               for (curr = _route.head - 1; curr++ != _route.tail;) {
+                       if (curr->unity) {
+                               guint tilex = unit2ztile(curr->unitx, i);
+                               guint tiley = unit2ztile(curr->unity, i);
+                               if (tilex != prev_tilex || tiley != prev_tiley) {
+                                       if (prev_tiley)
+                                               num_maps += (abs((gint) tilex - prev_tilex) + 1) * (abs((gint) tiley - prev_tiley) + 1) - 1;
+                                       prev_tilex = tilex;
+                                       prev_tiley = tiley;
                                }
                        }
                }
        }
-       num_maps *= 0.625 * pow(radius + 1, 1.85);
+}
+num_maps *= 0.625 * pow(radius + 1, 1.85);
+
+if (is_deleting) {
+       g_snprintf(buffer, sizeof(buffer), "%s %s %d %s",
+                _("Confirm DELETION of"), _("about"),
+                num_maps, _("maps "));
+} else {
+       g_snprintf(buffer, sizeof(buffer),
+                "%s %s %d %s\n(%s %.2f MB)\n",
+                _("Confirm download of"), _("about"), num_maps,
+                _("maps"), _("up to about"),
+                num_maps * (strstr(_curr_repo->url, "%s") ? 18e-3 : 6e-3));
+}
+confirm = hildon_note_new_confirmation(GTK_WINDOW(mapman_info->dialog), buffer);
 
-       if (is_deleting) {
-               snprintf(buffer, sizeof(buffer), "%s %s %d %s",
-                        _("Confirm DELETION of"), _("about"),
-                        num_maps, _("maps "));
-       } else {
-               snprintf(buffer, sizeof(buffer),
-                        "%s %s %d %s\n(%s %.2f MB)\n",
-                        _("Confirm download of"), _("about"), num_maps,
-                        _("maps"), _("up to about"),
-                        num_maps *
-                        (strstr(_curr_repo->url, "%s") ? 18e-3 : 6e-3));
-       }
-       confirm =
-           hildon_note_new_confirmation(GTK_WINDOW(mapman_info->dialog),
-                                        buffer);
-
-       if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) {
-               gtk_widget_destroy(confirm);
-               vprintf("%s(): return FALSE\n", __PRETTY_FUNCTION__);
-               return FALSE;
-       }
+if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) {
+       gtk_widget_destroy(confirm);
+       return FALSE;
+}
 
-       /* Now, do the actual download. */
-       for (i = 0; i < MAX_ZOOM; i++) {
-               if (gtk_toggle_button_get_active
-                   (GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
-                       prev_tilex = 0;
-                       prev_tiley = 0;
-                       for (curr = _route.head - 1; curr++ != _route.tail;) {
-                               if (curr->unity) {
-                                       guint tilex =
-                                           unit2ztile(curr->unitx, i);
-                                       guint tiley =
-                                           unit2ztile(curr->unity, i);
-                                       if (tilex != prev_tilex
-                                           || tiley != prev_tiley) {
-                                               guint minx, miny, maxx, maxy, x,
-                                                   y;
-                                               if (prev_tiley != 0) {
-                                                       minx =
-                                                           MIN(tilex,
-                                                               prev_tilex) -
-                                                           radius;
-                                                       miny =
-                                                           MIN(tiley,
-                                                               prev_tiley) -
-                                                           radius;
-                                                       maxx =
-                                                           MAX(tilex,
-                                                               prev_tilex) +
-                                                           radius;
-                                                       maxy =
-                                                           MAX(tiley,
-                                                               prev_tiley) +
-                                                           radius;
-                                               } else {
-                                                       minx = tilex - radius;
-                                                       miny = tiley - radius;
-                                                       maxx = tilex + radius;
-                                                       maxy = tiley + radius;
-                                               }
-                                               for (x = minx; x <= maxx; x++)
-                                                       for (y = miny;
-                                                            y <= maxy; y++)
-                                                               map_initiate_download
-                                                                   (x, y, i,
-                                                                    is_deleting
-                                                                    ? 0
-                                                                    :
-                                                                    (is_overwriting
-                                                                     ?
-                                                                     -INITIAL_DOWNLOAD_RETRIES
-                                                                     :
-                                                                     INITIAL_DOWNLOAD_RETRIES));
-                                               prev_tilex = tilex;
-                                               prev_tiley = tiley;
+/* Now, do the actual download. */
+for (i = 0; i < MAX_ZOOM; i++) {
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
+               prev_tilex = 0;
+               prev_tiley = 0;
+
+               for (curr = _route.head - 1; curr++ != _route.tail;) {
+                       if (curr->unity) {
+                               guint tilex = unit2ztile(curr->unitx, i);
+                               guint tiley = unit2ztile(curr->unity, i);
+                               if (tilex != prev_tilex || tiley != prev_tiley) {
+                                       guint minx, miny, maxx, maxy, x, y;
+                                       if (prev_tiley != 0) {
+                                               minx = MIN(tilex, prev_tilex) - radius;
+                                               miny = MIN(tiley, prev_tiley) - radius;
+                                               maxx = MAX(tilex, prev_tilex) + radius;
+                                               maxy = MAX(tiley, prev_tiley) + radius;
+                                       } else {
+                                               minx = tilex - radius;
+                                               miny = tiley - radius;
+                                               maxx = tilex + radius;
+                                               maxy = tiley + radius;
                                        }
+                                       for (x = minx; x <= maxx; x++)
+                                               for (y = miny; y <= maxy; y++)
+                                                       map_initiate_download(x, y, i, is_deleting ? 0
+                                                            : (is_overwriting ? -INITIAL_DOWNLOAD_RETRIES : INITIAL_DOWNLOAD_RETRIES));
+                                       prev_tilex = tilex;
+                                       prev_tiley = tiley;
                                }
                        }
                }
        }
-       _route_dl_radius = radius;
-       gtk_widget_destroy(confirm);
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
-       return TRUE;
+}
+_route_dl_radius = radius;
+gtk_widget_destroy(confirm);
+return TRUE;
 }
 
-void mapman_clear(GtkWidget * widget, MapmanInfo * mapman_info)
+static void 
+mapman_clear(GtkWidget * widget, MapmanInfo * mapman_info)
 {
-       guint i;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       if (gtk_notebook_get_current_page(GTK_NOTEBOOK(mapman_info->notebook)))
-               /* This is the second page (the "Zoom" page) - clear the checks. */
-               for (i = 0; i < MAX_ZOOM; i++)
-                       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                                    (mapman_info->
-                                                     chk_zoom_levels[i]),
-                                                    FALSE);
-       else {
-               /* This is the first page (the "Area" page) - clear the text fields. */
-               gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_topleft_lat), "");
-               gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_topleft_lon), "");
-               gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_botright_lat),
-                                  "");
-               gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_botright_lon),
-                                  "");
-       }
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+guint i;
+
+if (gtk_notebook_get_current_page(GTK_NOTEBOOK(mapman_info->notebook))) {
+       /* This is the second page (the "Zoom" page) - clear the checks. */
+       for (i = 0; i < MAX_ZOOM; i++)
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]), FALSE);
+} else {
+       /* This is the first page (the "Area" page) - clear the text fields. */
+       gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_topleft_lat), "");
+       gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_topleft_lon), "");
+       gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_botright_lat), "");
+       gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_botright_lon), "");
+}
 }
 
-void mapman_update_state(GtkWidget * widget, MapmanInfo * mapman_info)
+static void 
+mapman_update_state(GtkWidget * widget, MapmanInfo * mapman_info)
 {
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       gtk_widget_set_sensitive(mapman_info->chk_overwrite,
-                                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                                             (mapman_info->
-                                                              rad_download)));
+gtk_widget_set_sensitive(mapman_info->chk_overwrite,
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->rad_download)));
 
        if (gtk_toggle_button_get_active
            (GTK_TOGGLE_BUTTON(mapman_info->rad_by_area)))
@@ -1062,9 +749,7 @@ void mapman_update_state(GtkWidget * widget, MapmanInfo * mapman_info)
 
        gtk_widget_set_sensitive(mapman_info->num_route_radius,
                                 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                                             (mapman_info->
-                                                              rad_by_route)));
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
+                                                             (mapman_info->rad_by_route)));
 }
 
 gboolean menu_cb_mapman(GtkAction * action)
@@ -1083,18 +768,12 @@ gboolean menu_cb_mapman(GtkAction * action)
        gchar buffer[80];
        gfloat lat, lon;
        guint i;
-       printf("%s()\n", __PRETTY_FUNCTION__);
 
-       mapman_info.dialog = dialog =
-           gtk_dialog_new_with_buttons(_("Manage Maps"), GTK_WINDOW(_window),
+       mapman_info.dialog = dialog = gtk_dialog_new_with_buttons(_("Manage Maps"), GTK_WINDOW(_window),
                                        GTK_DIALOG_MODAL, GTK_STOCK_OK,
                                        GTK_RESPONSE_ACCEPT, NULL);
 
-       /* Enable the help button. */
-#ifdef WITH_HILDON
-       ossohelp_dialog_help_enable(GTK_DIALOG(mapman_info.dialog),
-                                   HELP_ID_MAPMAN, _osso);
-#endif
+       help_dialog_help_enable(GTK_DIALOG(mapman_info.dialog), HELP_ID_MAPMAN);
 
        /* Clear button. */
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
@@ -1103,12 +782,10 @@ gboolean menu_cb_mapman(GtkAction * action)
                         G_CALLBACK(mapman_clear), &mapman_info);
 
        /* Cancel button. */
-       gtk_dialog_add_button(GTK_DIALOG(dialog),
-                             GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+       gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
 
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                          mapman_info.notebook =
-                          gtk_notebook_new(), TRUE, TRUE, 0);
+                          mapman_info.notebook = gtk_notebook_new(), TRUE, TRUE, 0);
 
        /* Setup page. */
        gtk_notebook_append_page(GTK_NOTEBOOK(mapman_info.notebook),
@@ -1120,11 +797,7 @@ gboolean menu_cb_mapman(GtkAction * action)
        gtk_box_pack_start(GTK_BOX(vbox),
                           hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox),
-                          mapman_info.rad_download
-                          =
-                          gtk_radio_button_new_with_label(NULL,
-                                                          _("Download Maps")),
-                          FALSE, FALSE, 0);
+                          mapman_info.rad_download = gtk_radio_button_new_with_label(NULL, _("Download Maps")), FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), label =
                           gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE,
                           0);
@@ -1140,10 +813,7 @@ gboolean menu_cb_mapman(GtkAction * action)
 
        gtk_box_pack_start(GTK_BOX(vbox),
                           mapman_info.rad_by_area
-                          = gtk_radio_button_new_with_label(NULL,
-                                                            _
-                                                            ("By Area (see tab)")),
-                          FALSE, FALSE, 0);
+                          = gtk_radio_button_new_with_label(NULL, _("By Area (see tab)")), FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(vbox), hbox =
                           gtk_hbox_new(FALSE, 4), FALSE, FALSE, 0);
        gtk_box_pack_start(GTK_BOX(hbox), mapman_info.rad_by_route =
@@ -1171,7 +841,7 @@ gboolean menu_cb_mapman(GtkAction * action)
                         0, 4, 0, 1, GTK_FILL, 0, 4, 0);
        gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
        for (i = 0; i < MAX_ZOOM; i++) {
-               snprintf(buffer, sizeof(buffer), "%d", i);
+               g_snprintf(buffer, sizeof(buffer), "%d", i);
                gtk_table_attach(GTK_TABLE(table),
                                 mapman_info.chk_zoom_levels[i]
                                 = gtk_check_button_new_with_label(buffer),
@@ -1258,7 +928,7 @@ gboolean menu_cb_mapman(GtkAction * action)
                         2, 3, 4, 5, GTK_EXPAND | GTK_FILL, 0, 4, 0);
        gtk_entry_set_alignment(GTK_ENTRY(mapman_info.txt_botright_lon), 1.f);
 
-#ifdef WITH_HILDON
+#if defined(WITH_DEVICE_770) && !defined(WITH_HILDON_NEW)
        /* Set hildon input hints */
        g_object_set(G_OBJECT(mapman_info.txt_topleft_lon),
                     HILDON_INPUT_MODE_HINT,
@@ -1275,40 +945,36 @@ gboolean menu_cb_mapman(GtkAction * action)
 #endif
 
        /* Default action is to download by area. */
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mapman_info.rad_by_area),
-                                    TRUE);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mapman_info.rad_by_area), TRUE);
 
        /* Initialize fields.  Do no use g_ascii_formatd; these strings will be
         * output (and parsed) as locale-dependent. */
 
-       snprintf(buffer, sizeof(buffer), "%.06f", _gps.lat);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", _gps->data.lat);
        gtk_label_set_text(GTK_LABEL(lbl_gps_lat), buffer);
-       snprintf(buffer, sizeof(buffer), "%.06f", _gps.lon);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", _gps->data.lon);
        gtk_label_set_text(GTK_LABEL(lbl_gps_lon), buffer);
 
        unit2latlon(_center.unitx, _center.unity, lat, lon);
-       snprintf(buffer, sizeof(buffer), "%.06f", lat);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", lat);
        gtk_label_set_text(GTK_LABEL(lbl_center_lat), buffer);
-       snprintf(buffer, sizeof(buffer), "%.06f", lon);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", lon);
        gtk_label_set_text(GTK_LABEL(lbl_center_lon), buffer);
 
        /* Initialize to the bounds of the screen. */
        unit2latlon(x2unit(0), y2unit(0), lat, lon);
-       snprintf(buffer, sizeof(buffer), "%.06f", lat);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", lat);
        gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_topleft_lat), buffer);
-       snprintf(buffer, sizeof(buffer), "%.06f", lon);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", lon);
        gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_topleft_lon), buffer);
 
-       unit2latlon(x2unit(_screen_width_pixels), y2unit(_screen_height_pixels),
-                   lat, lon);
-       snprintf(buffer, sizeof(buffer), "%.06f", lat);
+       unit2latlon(x2unit(_screen_width_pixels), y2unit(_screen_height_pixels), lat, lon);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", lat);
        gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_botright_lat), buffer);
-       snprintf(buffer, sizeof(buffer), "%.06f", lon);
+       g_snprintf(buffer, sizeof(buffer), "%.06f", lon);
        gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_botright_lon), buffer);
 
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
-                                    (mapman_info.chk_zoom_levels[_zoom]),
-                                    TRUE);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mapman_info.chk_zoom_levels[_zoom]), TRUE);
 
        gtk_widget_show_all(dialog);
 
@@ -1316,94 +982,62 @@ gboolean menu_cb_mapman(GtkAction * action)
 
        /* Connect signals. */
        if (_curr_repo->type != REPOTYPE_NONE) {
-               g_signal_connect(G_OBJECT(mapman_info.rad_download), "clicked",
-                                G_CALLBACK(mapman_update_state), &mapman_info);
+               g_signal_connect(G_OBJECT(mapman_info.rad_download), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
                gtk_widget_set_sensitive(mapman_info.rad_download, TRUE);
        } else {
                gtk_widget_set_sensitive(mapman_info.rad_download, FALSE);
-               popup_error(dialog,
-                           _
-                           ("NOTE: You must set a Map URI in the current repository in "
-                            "order to download maps."));
+               popup_error(dialog, _("NOTE: You must set a Map URI in the current repository in order to download maps."));
        }
-       g_signal_connect(G_OBJECT(mapman_info.rad_delete), "clicked",
-                        G_CALLBACK(mapman_update_state), &mapman_info);
-       g_signal_connect(G_OBJECT(mapman_info.rad_by_area), "clicked",
-                        G_CALLBACK(mapman_update_state), &mapman_info);
-       g_signal_connect(G_OBJECT(mapman_info.rad_by_route), "clicked",
-                        G_CALLBACK(mapman_update_state), &mapman_info);
+
+       g_signal_connect(G_OBJECT(mapman_info.rad_delete), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
+       g_signal_connect(G_OBJECT(mapman_info.rad_by_area), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
+       g_signal_connect(G_OBJECT(mapman_info.rad_by_route), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
 
        while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
-               gboolean is_deleting =
-                   gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                                (mapman_info.rad_delete));
-               gboolean is_overwriting =
-                   gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                                (mapman_info.chk_overwrite));
-               if (gtk_toggle_button_get_active
-                   (GTK_TOGGLE_BUTTON(mapman_info.rad_by_route))) {
-                       if (mapman_by_route
-                           (&mapman_info, is_deleting, is_overwriting))
+               gboolean is_deleting = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.rad_delete));
+               gboolean is_overwriting = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.chk_overwrite));
+               if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.rad_by_route))) {
+                       if (mapman_by_route(&mapman_info, is_deleting, is_overwriting))
                                break;
                } else {
                        const gchar *text;
                        gchar *error_check;
                        gfloat start_lat, start_lon, end_lat, end_lon;
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
-                                              (mapman_info.txt_topleft_lat));
+                       text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_topleft_lat));
                        start_lat = strtof(text, &error_check);
-                       if (text == error_check || start_lat < -90.f
-                           || start_lat > 90.f) {
-                               popup_error(dialog,
-                                           _("Invalid Top-Left Latitude"));
+                       if (text == error_check || start_lat < -90.f || start_lat > 90.f) {
+                               popup_error(dialog, _("Invalid Top-Left Latitude"));
                                continue;
                        }
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
-                                              (mapman_info.txt_topleft_lon));
+                       text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_topleft_lon));
                        start_lon = strtof(text, &error_check);
-                       if (text == error_check || start_lon < -180.f
-                           || start_lon > 180.f) {
-                               popup_error(dialog,
-                                           _("Invalid Top-Left Longitude"));
+                       if (text == error_check || start_lon < -180.f || start_lon > 180.f) {
+                               popup_error(dialog, _("Invalid Top-Left Longitude"));
                                continue;
                        }
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
-                                              (mapman_info.txt_botright_lat));
+                       text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_botright_lat));
                        end_lat = strtof(text, &error_check);
-                       if (text == error_check || end_lat < -90.f
-                           || end_lat > 90.f) {
-                               popup_error(dialog,
-                                           _("Invalid Bottom-Right Latitude"));
+                       if (text == error_check || end_lat < -90.f || end_lat > 90.f) {
+                               popup_error(dialog, _("Invalid Bottom-Right Latitude"));
                                continue;
                        }
 
-                       text =
-                           gtk_entry_get_text(GTK_ENTRY
-                                              (mapman_info.txt_botright_lon));
+                       text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_botright_lon));
                        end_lon = strtof(text, &error_check);
-                       if (text == error_check || end_lon < -180.f
-                           || end_lon > 180.f) {
-                               popup_error(dialog,
-                                           _
-                                           ("Invalid Bottom-Right Longitude"));
+                       if (text == error_check || end_lon < -180.f || end_lon > 180.f) {
+                               popup_error(dialog, _("Invalid Bottom-Right Longitude"));
                                continue;
                        }
 
-                       if (mapman_by_area
-                           (start_lat, start_lon, end_lat, end_lon,
-                            &mapman_info, is_deleting, is_overwriting))
+                       if (mapman_by_area(start_lat, start_lon, end_lat, end_lon, &mapman_info, is_deleting, is_overwriting))
                                break;
                }
        }
 
        gtk_widget_hide(dialog);        /* Destroying causes a crash (!?!?!??!) */
 
-       vprintf("%s(): return TRUE\n", __PRETTY_FUNCTION__);
        return TRUE;
 }