]> err.no Git - mapper/commitdiff
Add map tile download by Track
authorKaj-Michael Lang <milang@tal.org>
Tue, 18 Mar 2008 11:17:11 +0000 (13:17 +0200)
committerKaj-Michael Lang <milang@tal.org>
Tue, 18 Mar 2008 11:17:11 +0000 (13:17 +0200)
src/config-gconf.c
src/map-repo.c
src/settings-gconf.h
src/settings.h

index 0c14e54fc6c74e5ade15aea29df253f57f94042c..9da3346073790f198f74e6dde03a90e1f03b102a 100644 (file)
@@ -391,6 +391,7 @@ gconf_client_set_string(gconf_client, GCONF_KEY_ROUTE_DL_URL, _route_dl_url, NUL
 
 /* Save Route Download Radius. */
 gconf_client_set_int(gconf_client, GCONF_KEY_ROUTE_DL_RADIUS, _route_dl_radius, NULL);
+gconf_client_set_int(gconf_client, GCONF_KEY_TRACK_DL_RADIUS, _track_dl_radius, NULL);
 
 /* Save Colors. */
 for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
@@ -736,6 +737,7 @@ if (_route_dl_url == NULL)
 
 /* Get Route Download Radius.  Default is 4. */
 _route_dl_radius = mapper_gconf_get_int(GCONF_KEY_ROUTE_DL_RADIUS, 4);
+_track_dl_radius = mapper_gconf_get_int(GCONF_KEY_TRACK_DL_RADIUS, 4);
 
 /* Get Colors. */
 for (i = 0; i < COLORABLE_ENUM_COUNT; i++) {
index 7289d0361f0152e492afb42362c0c2ea806fcb49..e8bbb9d1bcbb71b244d0bdd309b82969a5762651 100644 (file)
@@ -43,6 +43,7 @@
 #include "map.h"
 #include "latlon.h"
 #include "route.h"
+#include "track.h"
 #include "settings.h"
 #include "mapper-types.h"
 #include "map-download.h"
@@ -86,7 +87,9 @@ struct _MapmanInfo {
        GtkWidget *chk_overwrite;
        GtkWidget *rad_by_area;
        GtkWidget *rad_by_route;
+       GtkWidget *rad_by_track;
        GtkWidget *num_route_radius;
+       GtkWidget *num_track_radius;
 
        /* The "Area" tab. */
        GtkWidget *txt_topleft_lat;
@@ -629,13 +632,12 @@ return TRUE;
 }
 
 static gboolean
-mapman_by_route(MapmanInfo * mapman_info, gboolean is_deleting, gboolean is_overwriting)
+mapman_by_path(Path *path, MapmanInfo *mapman_info, guint radius, 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));
 
 /* First, get the number of maps to download. */
 for (i = 0; i < MAX_ZOOM; i++) {
@@ -643,7 +645,7 @@ for (i = 0; i < MAX_ZOOM; i++) {
                prev_tilex = 0;
                prev_tiley = 0;
 
-               for (curr = _route->head - 1; curr++ != _route->tail;) {
+               for (curr = path->head - 1; curr++ != path->tail;) {
                        if (curr->unity) {
                                guint tilex = unit2ztile(curr->unitx, i);
                                guint tiley = unit2ztile(curr->unity, i);
@@ -661,8 +663,7 @@ 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 "));
+                _("Confirm DELETION of"), _("about"), num_maps, _("maps "));
 } else {
        g_snprintf(buffer, sizeof(buffer),
                 "%s %s %d %s\n(%s %.2f MB)\n",
@@ -683,7 +684,7 @@ for (i = 0; i < MAX_ZOOM; i++) {
                prev_tilex = 0;
                prev_tiley = 0;
 
-               for (curr = _route->head - 1; curr++ != _route->tail;) {
+               for (curr = path->head - 1; curr++ != path->tail;) {
                        if (curr->unity) {
                                guint tilex = unit2ztile(curr->unitx, i);
                                guint tiley = unit2ztile(curr->unity, i);
@@ -711,7 +712,6 @@ for (i = 0; i < MAX_ZOOM; i++) {
                }
        }
 }
-_route_dl_radius = radius;
 gtk_widget_destroy(confirm);
 return TRUE;
 }
@@ -737,19 +737,15 @@ if (gtk_notebook_get_current_page(GTK_NOTEBOOK(mapman_info->notebook))) {
 static void 
 mapman_update_state(GtkWidget * widget, MapmanInfo * mapman_info)
 {
-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)))
-               gtk_widget_show(mapman_info->tbl_area);
-       else if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(mapman_info->notebook))
-                == 3)
-               gtk_widget_hide(mapman_info->tbl_area);
-
-       gtk_widget_set_sensitive(mapman_info->num_route_radius,
-                                gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
-                                                             (mapman_info->rad_by_route)));
+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)))
+       gtk_widget_show(mapman_info->tbl_area);
+else if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(mapman_info->notebook)) == 3)
+       gtk_widget_hide(mapman_info->tbl_area);
+
+gtk_widget_set_sensitive(mapman_info->num_route_radius, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->rad_by_route)));
+gtk_widget_set_sensitive(mapman_info->num_track_radius, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->rad_by_track)));
 }
 
 gboolean menu_cb_mapman(GtkAction * action)
@@ -770,74 +766,59 @@ gboolean menu_cb_mapman(GtkAction * action)
        guint i;
 
        mapman_info.dialog = dialog = gtk_dialog_new_with_buttons(_("Manage Maps"), GTK_WINDOW(_window),
-                                       GTK_DIALOG_MODAL, GTK_STOCK_OK,
-                                       GTK_RESPONSE_ACCEPT, NULL);
+                                       GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
 
        help_dialog_help_enable(GTK_DIALOG(mapman_info.dialog), HELP_ID_MAPMAN);
 
        /* Clear button. */
        gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
                          button = gtk_button_new_with_label(_("Clear")));
-       g_signal_connect(G_OBJECT(button), "clicked",
-                        G_CALLBACK(mapman_clear), &mapman_info);
+       g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(mapman_clear), &mapman_info);
 
        /* Cancel button. */
        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);
+       gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), mapman_info.notebook = gtk_notebook_new(), TRUE, TRUE, 0);
 
        /* Setup page. */
-       gtk_notebook_append_page(GTK_NOTEBOOK(mapman_info.notebook),
-                                vbox = gtk_vbox_new(FALSE, 2),
-                                label = gtk_label_new(_("Setup")));
-       gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(mapman_info.notebook),
-                                          vbox, FALSE, FALSE, GTK_PACK_START);
-
-       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);
-       gtk_box_pack_start(GTK_BOX(hbox), label =
-                          gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE,
-                          0);
+       gtk_notebook_append_page(GTK_NOTEBOOK(mapman_info.notebook), vbox = gtk_vbox_new(FALSE, 2), label = gtk_label_new(_("Setup")));
+       gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(mapman_info.notebook), vbox, FALSE, FALSE, GTK_PACK_START);
+
+       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);
+       gtk_box_pack_start(GTK_BOX(hbox), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE, 0);
        gtk_container_add(GTK_CONTAINER(label), mapman_info.chk_overwrite =
                          gtk_check_button_new_with_label(_("Overwrite"))),
            gtk_box_pack_start(GTK_BOX(vbox), mapman_info.rad_delete =
-                              gtk_radio_button_new_with_label_from_widget
-                              (GTK_RADIO_BUTTON(mapman_info.rad_download),
-                               _("Delete Maps")), FALSE, FALSE, 0);
-
-       gtk_box_pack_start(GTK_BOX(vbox),
-                          gtk_hseparator_new(), FALSE, FALSE, 0);
-
-       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_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 =
-                          gtk_radio_button_new_with_label_from_widget
-                          (GTK_RADIO_BUTTON(mapman_info.rad_by_area),
-                           _("Along Route - Radius (tiles):")), FALSE, FALSE,
-                          0);
-       gtk_widget_set_sensitive(mapman_info.rad_by_route,
-                                _route->head != _route->tail);
-       gtk_box_pack_start(GTK_BOX(hbox), mapman_info.num_route_radius =
-                          hildon_number_editor_new(0, 100), FALSE, FALSE, 0);
-       hildon_number_editor_set_value(HILDON_NUMBER_EDITOR
-                                      (mapman_info.num_route_radius),
-                                      _route_dl_radius);
+                              gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(mapman_info.rad_download), _("Delete Maps")), FALSE, FALSE, 0);
+
+       gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
+
+       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_box_pack_start(GTK_BOX(vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 0);
+
+       /* Route */
+       gtk_box_pack_start(GTK_BOX(hbox), mapman_info.rad_by_route = gtk_radio_button_new_with_label_from_widget
+                          (GTK_RADIO_BUTTON(mapman_info.rad_by_area), _("Along Route - Radius (tiles):")), FALSE, FALSE, 0);
+       gtk_widget_set_sensitive(mapman_info.rad_by_route, _route->head != _route->tail);
+       gtk_box_pack_start(GTK_BOX(hbox), mapman_info.num_route_radius = hildon_number_editor_new(0, 100), FALSE, FALSE, 0);
+       hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(mapman_info.num_route_radius), _route_dl_radius);
+
+       /* Track */
+       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_track = gtk_radio_button_new_with_label_from_widget
+                          (GTK_RADIO_BUTTON(mapman_info.rad_by_area), _("Along Track - Radius (tiles):")), FALSE, FALSE, 0);
+       gtk_widget_set_sensitive(mapman_info.rad_by_track, _track->head != _track->tail);
+       gtk_box_pack_start(GTK_BOX(hbox), mapman_info.num_track_radius = hildon_number_editor_new(0, 100), FALSE, FALSE, 0);
+       hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(mapman_info.num_track_radius), _track_dl_radius);
 
        /* Zoom page. */
        gtk_notebook_append_page(GTK_NOTEBOOK(mapman_info.notebook),
                                 table = gtk_table_new(5, 5, FALSE),
                                 label = gtk_label_new(_("Zoom")));
-       gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(mapman_info.notebook),
-                                          table, FALSE, FALSE, GTK_PACK_START);
+       gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(mapman_info.notebook), table, FALSE, FALSE, GTK_PACK_START);
        gtk_table_attach(GTK_TABLE(table), label =
-                        gtk_label_new(_
-                                      ("Zoom Levels to Download: (0 = most detail)")),
+                        gtk_label_new(_("Zoom Levels to Download: (0 = most detail)")),
                         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++) {
@@ -992,12 +973,18 @@ gboolean menu_cb_mapman(GtkAction * action)
        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_by_track), "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))
+                       _route_dl_radius = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(mapman_info.num_route_radius));
+                       if (mapman_by_path(_route, &mapman_info, _route_dl_radius, is_deleting, is_overwriting))
+                               break;
+               } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.rad_by_track))) {
+                       _track_dl_radius = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(mapman_info.num_track_radius));
+                       if (mapman_by_path(_track, &mapman_info, _track_dl_radius, is_deleting, is_overwriting))
                                break;
                } else {
                        const gchar *text;
index f13d391cecd16e62ae519a7299160d5e283b19a6..fd91b582493021d53ca815c260733a0871554ed9 100644 (file)
@@ -89,6 +89,7 @@
 #define GCONF_KEY_ROUTE_DL_URL GCONF_KEY_PREFIX"/route_dl_url"
 #define GCONF_KEY_ROUTE_DL_RADIUS GCONF_KEY_PREFIX"/route_dl_radius"
 
+#define GCONF_KEY_TRACK_DL_RADIUS GCONF_KEY_PREFIX"/track_dl_radius"
 #define GCONF_KEY_TRACKFILE GCONF_KEY_PREFIX"/track_file"
 #define GCONF_KEY_DEG_FORMAT GCONF_KEY_PREFIX"/deg_format"
 
index 8058c03f8ac5c72becb2847ffe9225d3999760f5..46ca45d289c3dc47a2fc301fd2820cee427cf4e8 100644 (file)
@@ -12,7 +12,9 @@
 gchar *_route_dir_uri;
 gchar *_track_file_uri;
 gchar *_route_dl_url;
+
 guint _route_dl_radius;
+guint _track_dl_radius;
 
 gboolean _track_store;