2 * This file is part of mapper
4 * Copyright (C) 2007 Kaj-Michael Lang
5 * Copyright (C) 2006-2007 John Costigan.
7 * POI and GPS-Info code originally written by Cezary Jackiewicz.
9 * Default map data provided by http://www.openstreetmap.org/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
37 #include <libgnomevfs/gnome-vfs.h>
39 #include "hildon-mapper.h"
47 #include "mapper-types.h"
48 #include "map-download.h"
49 #include "ui-common.h"
53 #include "map-tile-repo.h"
56 #define MAP_REPO_LIST_URL "http://www.gnuite.com/nokia770/maemo-mapper/repos.txt"
58 typedef struct _RepoManInfo RepoManInfo;
66 typedef struct _RepoEditInfo RepoEditInfo;
67 struct _RepoEditInfo {
70 GtkWidget *txt_cache_dir;
71 GtkWidget *num_dl_zoom_steps;
72 GtkWidget *num_view_zoom_steps;
73 GtkWidget *chk_double_size;
74 GtkWidget *chk_nextable;
75 GtkWidget *btn_browse;
76 BrowseInfo browse_info;
79 typedef struct _MapmanInfo MapmanInfo;
85 /* The "Setup" tab. */
86 GtkWidget *rad_download;
87 GtkWidget *rad_delete;
88 GtkWidget *chk_overwrite;
89 GtkWidget *rad_by_area;
90 GtkWidget *rad_by_route;
91 GtkWidget *rad_by_track;
92 GtkWidget *num_route_radius;
93 GtkWidget *num_track_radius;
96 GtkWidget *txt_topleft_lat;
97 GtkWidget *txt_topleft_lon;
98 GtkWidget *txt_botright_lat;
99 GtkWidget *txt_botright_lon;
101 /* The "Zoom" tab. */
102 GtkWidget *chk_zoom_levels[20];
106 repo_set_curr(RepoData *rd)
109 if (map_tile_repo_make_cache_dir(rd)==FALSE) {
110 gchar buffer[BUFFER_SIZE];
111 g_snprintf(buffer, sizeof(buffer), "%s: %s", _("Unable to create cache directory for repository"), rd->name);
112 popup_error(_window, buffer);
119 repoman_dialog_select(GtkWidget * widget, RepoManInfo * rmi)
121 gint curr_index = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
122 gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi->notebook), curr_index);
127 repoman_dialog_browse(GtkWidget * widget, BrowseInfo * browse_info)
131 dialog = GTK_WIDGET(hildon_file_chooser_dialog_new(GTK_WINDOW(browse_info->dialog), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER));
133 gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), TRUE);
134 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), gtk_entry_get_text(GTK_ENTRY(browse_info->txt)));
136 if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(dialog))) {
137 gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
138 gtk_entry_set_text(GTK_ENTRY(browse_info->txt), filename);
142 gtk_widget_destroy(dialog);
148 repoman_dialog_rename(GtkWidget * widget, RepoManInfo * rmi)
155 dialog = gtk_dialog_new_with_buttons(_("New Name"),
156 GTK_WINDOW(rmi->dialog),
157 GTK_DIALOG_MODAL, GTK_STOCK_OK,
160 GTK_RESPONSE_REJECT, NULL);
162 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 4);
164 gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Name")), FALSE, FALSE, 0);
165 gtk_box_pack_start(GTK_BOX(hbox), txt_name = gtk_entry_new(), TRUE, TRUE, 0);
167 gtk_widget_show_all(dialog);
169 while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
170 gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
171 RepoEditInfo *rei = g_list_nth_data(rmi->repo_edits, active);
173 rei->name = g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_name)));
174 gtk_combo_box_insert_text(GTK_COMBO_BOX(rmi->cmb_repos), active, g_strdup(rei->name));
175 gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), active);
176 gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), active + 1);
180 gtk_widget_destroy(dialog);
185 repoman_dialog_delete(GtkWidget * widget, RepoManInfo * rmi)
189 gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi->cmb_repos));
191 if (gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(rmi->cmb_repos))), NULL) <= 1) {
192 popup_error(rmi->dialog, _("Cannot delete the last repository - there must be at lease one repository."));
196 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)));
197 confirm = hildon_note_new_confirmation(GTK_WINDOW(_window), buffer);
199 if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
200 gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), active);
201 gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), active);
202 rmi->repo_edits = g_list_remove_link(rmi->repo_edits, g_list_nth(rmi->repo_edits, active));
203 gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), MAX(0, active - 1));
206 gtk_widget_destroy(confirm);
211 static RepoEditInfo *
212 repoman_dialog_add_repo(RepoManInfo * rmi, gchar * name)
218 RepoEditInfo *rei = g_new(RepoEditInfo, 1);
223 gtk_notebook_append_page(GTK_NOTEBOOK(rmi->notebook), vbox = gtk_vbox_new(FALSE, 4), gtk_label_new(name));
225 gtk_box_pack_start(GTK_BOX(vbox), table = gtk_table_new(2, 2, FALSE), FALSE, FALSE, 0);
226 /* Map download URI. */
227 gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("URL Format")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
228 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
229 gtk_table_attach(GTK_TABLE(table), rei->txt_url = gtk_entry_new(), 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, 0, 2, 4);
232 gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Cache Dir.")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
233 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
234 gtk_table_attach(GTK_TABLE(table), hbox = gtk_hbox_new(FALSE, 4), 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, 0, 2, 4);
235 gtk_box_pack_start(GTK_BOX(hbox), rei->txt_cache_dir = gtk_entry_new(), TRUE, TRUE, 0);
236 gtk_box_pack_start(GTK_BOX(hbox), rei->btn_browse = gtk_button_new_with_label(_("Browse...")), FALSE, FALSE, 0);
238 /* Initialize cache dir */
240 gchar *cache_base = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_BASE);
241 gchar *cache_dir = gnome_vfs_uri_make_full_from_relative(cache_base, name);
242 gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), cache_dir);
247 gtk_box_pack_start(GTK_BOX(vbox), table = gtk_table_new(3, 2, FALSE), FALSE, FALSE, 0);
249 /* Download Zoom Steps. */
250 gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Download Zoom Steps")), 0, 1, 0, 1, GTK_FILL, 0, 2, 4);
251 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
252 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);
253 hildon_controlbar_set_range(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), 1, 4);
254 hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), REPO_DEFAULT_DL_ZOOM_STEPS);
255 force_min_visible_bars(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), 1);
257 /* Download Zoom Steps. */
258 gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("View Zoom Steps")), 0, 1, 1, 2, GTK_FILL, 0, 2, 4);
259 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
260 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);
261 hildon_controlbar_set_range(HILDON_CONTROLBAR(rei->num_view_zoom_steps), 1, 4);
262 hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps), REPO_DEFAULT_VIEW_ZOOM_STEPS);
263 force_min_visible_bars(HILDON_CONTROLBAR(rei->num_view_zoom_steps), 1);
265 gtk_table_attach(GTK_TABLE(table), label = gtk_vseparator_new(), 2, 3, 0, 2, GTK_FILL, GTK_FILL, 4, 4);
268 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);
269 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_double_size), FALSE);
272 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);
273 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_nextable), TRUE);
275 rmi->repo_edits = g_list_append(rmi->repo_edits, rei);
277 /* Connect signals. */
278 rei->browse_info.dialog = rmi->dialog;
279 rei->browse_info.txt = rei->txt_cache_dir;
280 g_signal_connect(G_OBJECT(rei->btn_browse), "clicked", G_CALLBACK(repoman_dialog_browse), &rei->browse_info);
282 gtk_widget_show_all(vbox);
284 gtk_combo_box_append_text(GTK_COMBO_BOX(rmi->cmb_repos), name);
285 gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos),
286 gtk_tree_model_iter_n_children(GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX (rmi->cmb_repos))), NULL) - 1);
292 repoman_dialog_new(GtkWidget * widget, RepoManInfo * rmi)
299 dialog = gtk_dialog_new_with_buttons(_("New Repository"),
300 GTK_WINDOW(rmi->dialog),
301 GTK_DIALOG_MODAL, GTK_STOCK_OK,
304 GTK_RESPONSE_REJECT, NULL);
306 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 4);
308 gtk_box_pack_start(GTK_BOX(hbox), label = gtk_label_new(_("Name")), FALSE, FALSE, 0);
309 gtk_box_pack_start(GTK_BOX(hbox), txt_name = gtk_entry_new(), TRUE, TRUE, 0);
311 gtk_widget_show_all(dialog);
313 while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
314 repoman_dialog_add_repo(rmi, g_strdup(gtk_entry_get_text(GTK_ENTRY(txt_name))));
318 gtk_widget_destroy(dialog);
324 repoman_reset(GtkWidget * widget, RepoManInfo * rmi)
328 confirm = hildon_note_new_confirmation(GTK_WINDOW(_window),
329 _("Replace all repositories with the default repository?"));
331 if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
332 /* First, delete all existing repositories. */
333 while (rmi->repo_edits) {
334 gtk_combo_box_remove_text(GTK_COMBO_BOX(rmi->cmb_repos), 0);
335 gtk_notebook_remove_page(GTK_NOTEBOOK(rmi->notebook), 0);
336 rmi->repo_edits = g_list_remove_link(rmi->repo_edits, g_list_first(rmi->repo_edits));
339 /* Now, add the default repository. */
340 repoman_dialog_add_repo(rmi, REPO_DEFAULT_NAME);
341 gtk_entry_set_text(GTK_ENTRY(((RepoEditInfo *) rmi->repo_edits->data)->txt_url), REPO_DEFAULT_MAP_URI);
343 gtk_combo_box_set_active(GTK_COMBO_BOX(rmi->cmb_repos), 0);
345 gtk_widget_destroy(confirm);
351 repoman_download(GtkWidget * widget, RepoManInfo * rmi)
355 confirm = hildon_note_new_confirmation(GTK_WINDOW(rmi->dialog),
356 _("Mapper will now download and add a list of "
357 "possibly-duplicate repositories from the internet. "
360 if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) {
365 GnomeVFSResult vfs_result;
367 /* Get repo config file from www.gnuite.com. */
368 if (GNOME_VFS_OK != (vfs_result = gnome_vfs_read_entire_file(MAP_REPO_LIST_URL, &size, &bytes))) {
369 popup_error(rmi->dialog, _("An error occurred while retrieving the repositories. The web service may be temporarily down."));
370 g_printerr("Error while download repositories: %s\n", gnome_vfs_result_to_string(vfs_result));
372 /* Parse each line as a repository. */
373 for (head = bytes; head && *head; head = tail) {
376 tail = strchr(head, '\n');
378 rd = map_tile_repo_new_from_string(head);
379 rei = repoman_dialog_add_repo(rmi, g_strdup(rd->name));
380 /* Initialize fields with data from the RepoData object. */
381 gtk_entry_set_text(GTK_ENTRY(rei->txt_url), rd->url);
382 gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), rd->cache_dir);
383 hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), rd->dl_zoom_steps);
384 hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps), rd->view_zoom_steps);
385 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_double_size), rd->double_size);
386 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_nextable), rd->nextable);
391 gtk_widget_destroy(confirm);
401 GtkWidget *btn_rename;
402 GtkWidget *btn_delete;
404 GtkWidget *btn_reset;
405 GtkWidget *btn_download;
406 guint i, curr_repo_index = 0;
409 rmi.dialog = gtk_dialog_new_with_buttons(_("Manage Repositories"),
411 GTK_DIALOG_MODAL, GTK_STOCK_OK,
412 GTK_RESPONSE_ACCEPT, NULL);
414 help_dialog_help_enable(GTK_DIALOG(rmi.dialog), HELP_ID_REPOMAN);
417 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(rmi.dialog)->action_area),
418 btn_reset = gtk_button_new_with_label(_("Reset...")));
419 g_signal_connect(G_OBJECT(btn_reset), "clicked", G_CALLBACK(repoman_reset), &rmi);
421 /* Download button. */
422 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(rmi.dialog)->action_area),
423 btn_download = gtk_button_new_with_label(_("Download...")));
424 g_signal_connect(G_OBJECT(btn_download), "clicked", G_CALLBACK(repoman_download), &rmi);
427 gtk_dialog_add_button(GTK_DIALOG(rmi.dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
429 hbox = gtk_hbox_new(FALSE, 4);
431 gtk_box_pack_start(GTK_BOX(hbox), rmi.cmb_repos = gtk_combo_box_new_text(), TRUE, TRUE, 4);
433 gtk_box_pack_start(GTK_BOX(hbox), gtk_vseparator_new(), FALSE, FALSE, 4);
434 gtk_box_pack_start(GTK_BOX(hbox), btn_rename = gtk_button_new_with_label(_("Rename...")), FALSE, FALSE, 4);
435 gtk_box_pack_start(GTK_BOX(hbox), btn_delete = gtk_button_new_with_label(_("Delete...")), FALSE, FALSE, 4);
436 gtk_box_pack_start(GTK_BOX(hbox), btn_new = gtk_button_new_with_label(_("New...")), FALSE, FALSE, 4);
438 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox), hbox, FALSE, FALSE, 4);
439 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox), gtk_hseparator_new(), TRUE, TRUE, 4);
440 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(rmi.dialog)->vbox), rmi.notebook = gtk_notebook_new(), TRUE, TRUE, 4);
442 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(rmi.notebook), FALSE);
443 gtk_notebook_set_show_border(GTK_NOTEBOOK(rmi.notebook), FALSE);
445 rmi.repo_edits = NULL;
447 /* Populate combo box and pages in notebook. */
448 for (i = 0, curr = _repo_list; curr; curr = curr->next, i++) {
449 RepoData *rd = (RepoData *) curr->data;
450 RepoEditInfo *rei = repoman_dialog_add_repo(&rmi, g_strdup(rd->name));
452 /* Initialize fields with data from the RepoData object. */
453 gtk_entry_set_text(GTK_ENTRY(rei->txt_url), rd->url);
454 gtk_entry_set_text(GTK_ENTRY(rei->txt_cache_dir), rd->cache_dir);
455 hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps), rd->dl_zoom_steps);
456 hildon_controlbar_set_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps), rd->view_zoom_steps);
457 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_double_size), rd->double_size);
458 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rei->chk_nextable), rd->nextable);
459 if (rd == _curr_repo)
463 /* Connect signals. */
464 g_signal_connect(G_OBJECT(btn_rename), "clicked", G_CALLBACK(repoman_dialog_rename), &rmi);
465 g_signal_connect(G_OBJECT(btn_delete), "clicked", G_CALLBACK(repoman_dialog_delete), &rmi);
466 g_signal_connect(G_OBJECT(btn_new), "clicked", G_CALLBACK(repoman_dialog_new), &rmi);
467 g_signal_connect(G_OBJECT(rmi.cmb_repos), "changed", G_CALLBACK(repoman_dialog_select), &rmi);
468 gtk_combo_box_set_active(GTK_COMBO_BOX(rmi.cmb_repos), curr_repo_index);
469 gtk_notebook_set_current_page(GTK_NOTEBOOK(rmi.notebook), curr_repo_index);
471 gtk_widget_show_all(rmi.dialog);
473 while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(rmi.dialog))) {
474 /* Iterate through repos and verify each. */
475 gboolean verified = TRUE;
478 gchar *old_curr_repo_name = _curr_repo->name;
480 for (i = 0, curr = rmi.repo_edits; verified && curr; curr = curr->next, i++) {
481 RepoEditInfo *rei = curr->data;
482 gchar *expanded = gnome_vfs_expand_initial_tilde(gtk_entry_get_text(GTK_ENTRY(rei->txt_cache_dir)));
483 verified = map_tile_repo_make_cache_dir(rei);
487 gtk_combo_box_set_active(GTK_COMBO_BOX(rmi.cmb_repos), i - 1);
491 /* But keep the repo list in memory, in case downloads are using it. */
494 /* Write new _repo_list. */
495 curr_repo_index = gtk_combo_box_get_active(GTK_COMBO_BOX(rmi.cmb_repos));
497 for (i = 0, curr = rmi.repo_edits; curr; curr = curr->next, i++) {
498 RepoEditInfo *rei = curr->data;
499 RepoData *rd = g_new(RepoData, 1);
501 rd->name = g_strdup(rei->name);
502 rd->url = g_strdup(gtk_entry_get_text(GTK_ENTRY(rei->txt_url)));
503 rd->cache_dir = gnome_vfs_expand_initial_tilde(gtk_entry_get_text(GTK_ENTRY(rei->txt_cache_dir)));
504 rd->dl_zoom_steps = hildon_controlbar_get_value(HILDON_CONTROLBAR(rei->num_dl_zoom_steps));
505 rd->view_zoom_steps = hildon_controlbar_get_value(HILDON_CONTROLBAR(rei->num_view_zoom_steps));
506 rd->double_size = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rei->chk_double_size));
507 rd->nextable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(rei->chk_nextable));
509 map_tile_repo_set_type(rd);
511 _repo_list = g_list_append(_repo_list, rd);
513 if (!_curr_repo && !strcmp(old_curr_repo_name, rd->name))
515 else if (i == curr_repo_index)
519 repo_set_curr((RepoData *) g_list_first(_repo_list)->data);
521 menu_maps_add_repos();
526 gtk_widget_hide(rmi.dialog); /* Destroying causes a crash (!?!?!??!) */
531 mapman_by_area(gdouble start_lat, gdouble start_lon,
532 gdouble end_lat, gdouble end_lon, MapmanInfo * mapman_info,
533 gboolean is_deleting, gboolean is_overwriting)
535 guint start_unitx, start_unity, end_unitx, end_unity;
541 latlon2unit(start_lat, start_lon, &start_unitx, &start_unity);
542 latlon2unit(end_lat, end_lon, &end_unitx, &end_unity);
544 /* Swap if they specified flipped lats or lons. */
545 if (start_unitx > end_unitx) {
546 guint swap = start_unitx;
547 start_unitx = end_unitx;
550 if (start_unity > end_unity) {
551 guint swap = start_unity;
552 start_unity = end_unity;
556 /* First, get the number of maps to download. */
557 for (i = 0; i < _curr_repo->max_zoom; i++) {
558 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
559 guint start_tilex, start_tiley, end_tilex, end_tiley;
560 start_tilex = unit2ztile(start_unitx, i);
561 start_tiley = unit2ztile(start_unity, i);
562 end_tilex = unit2ztile(end_unitx, i);
563 end_tiley = unit2ztile(end_unity, i);
564 num_maps += (end_tilex - start_tilex + 1) * (end_tiley - start_tiley + 1);
569 g_snprintf(buffer, sizeof(buffer), "%s %d %s", _("Confirm DELETION of"), num_maps, _("maps "));
571 g_snprintf(buffer, sizeof(buffer), "%s %d %s\n(%s %.2f MB)\n", _("Confirm download of"),
572 num_maps, _("maps"), _("up to about"), num_maps * (strstr(_curr_repo->url, "%s") ? 18e-3 : 6e-3));
574 confirm = hildon_note_new_confirmation(GTK_WINDOW(mapman_info->dialog), buffer);
576 if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) {
577 gtk_widget_destroy(confirm);
581 for (i = 0; i < _curr_repo->max_zoom; i++) {
582 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
583 guint start_tilex, start_tiley, end_tilex, end_tiley;
585 start_tilex = unit2ztile(start_unitx, i);
586 start_tiley = unit2ztile(start_unity, i);
587 end_tilex = unit2ztile(end_unitx, i);
588 end_tiley = unit2ztile(end_unity, i);
590 for (tiley = start_tiley; tiley <= end_tiley; tiley++)
591 for (tilex = start_tilex; tilex <= end_tilex; tilex++)
592 map_initiate_download(tilex, tiley, i, is_deleting ? 0 : (is_overwriting ?
593 -INITIAL_DOWNLOAD_RETRIES : INITIAL_DOWNLOAD_RETRIES));
596 gtk_widget_destroy(confirm);
601 mapman_by_path(Path *path, MapmanInfo *mapman_info, guint radius, gboolean is_deleting, gboolean is_overwriting)
604 guint prev_tilex, prev_tiley, num_maps = 0, i;
608 /* First, get the number of maps to download. */
609 for (i = 0; i < _curr_repo->max_zoom; i++) {
610 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
614 for (curr = path->head - 1; curr++ != path->tail;) {
616 guint tilex = unit2ztile(curr->unitx, i);
617 guint tiley = unit2ztile(curr->unity, i);
618 if (tilex != prev_tilex || tiley != prev_tiley) {
620 num_maps += (abs((gint) tilex - prev_tilex) + 1) * (abs((gint) tiley - prev_tiley) + 1) - 1;
628 num_maps *= 0.625 * pow(radius + 1, 1.85);
631 g_snprintf(buffer, sizeof(buffer), "%s %s %d %s",
632 _("Confirm DELETION of"), _("about"), num_maps, _("maps "));
634 g_snprintf(buffer, sizeof(buffer),
635 "%s %s %d %s\n(%s %.2f MB)\n",
636 _("Confirm download of"), _("about"), num_maps,
637 _("maps"), _("up to about"),
638 num_maps * (strstr(_curr_repo->url, "%s") ? 18e-3 : 6e-3));
640 confirm = hildon_note_new_confirmation(GTK_WINDOW(mapman_info->dialog), buffer);
642 if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) {
643 gtk_widget_destroy(confirm);
647 /* Now, do the actual download. */
648 for (i = 0; i < _curr_repo->max_zoom; i++) {
649 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]))) {
653 for (curr = path->head - 1; curr++ != path->tail;) {
655 guint tilex = unit2ztile(curr->unitx, i);
656 guint tiley = unit2ztile(curr->unity, i);
657 if (tilex != prev_tilex || tiley != prev_tiley) {
658 guint minx, miny, maxx, maxy, x, y;
659 if (prev_tiley != 0) {
660 minx = MIN(tilex, prev_tilex) - radius;
661 miny = MIN(tiley, prev_tiley) - radius;
662 maxx = MAX(tilex, prev_tilex) + radius;
663 maxy = MAX(tiley, prev_tiley) + radius;
665 minx = tilex - radius;
666 miny = tiley - radius;
667 maxx = tilex + radius;
668 maxy = tiley + radius;
670 for (x = minx; x <= maxx; x++)
671 for (y = miny; y <= maxy; y++)
672 map_initiate_download(x, y, i, is_deleting ? 0
673 : (is_overwriting ? -INITIAL_DOWNLOAD_RETRIES : INITIAL_DOWNLOAD_RETRIES));
681 gtk_widget_destroy(confirm);
686 mapman_clear(GtkWidget * widget, MapmanInfo * mapman_info)
690 if (gtk_notebook_get_current_page(GTK_NOTEBOOK(mapman_info->notebook))) {
691 /* This is the second page (the "Zoom" page) - clear the checks. */
692 for (i = 0; i < _curr_repo->max_zoom; i++)
693 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mapman_info->chk_zoom_levels[i]), FALSE);
695 /* This is the first page (the "Area" page) - clear the text fields. */
696 gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_topleft_lat), "");
697 gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_topleft_lon), "");
698 gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_botright_lat), "");
699 gtk_entry_set_text(GTK_ENTRY(mapman_info->txt_botright_lon), "");
704 mapman_update_state(GtkWidget * widget, MapmanInfo * mapman_info)
706 gtk_widget_set_sensitive(mapman_info->chk_overwrite, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->rad_download)));
708 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->rad_by_area)))
709 gtk_widget_show(mapman_info->tbl_area);
710 else if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(mapman_info->notebook)) == 3)
711 gtk_widget_hide(mapman_info->tbl_area);
713 gtk_widget_set_sensitive(mapman_info->num_route_radius, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->rad_by_route)));
714 gtk_widget_set_sensitive(mapman_info->num_track_radius, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info->rad_by_track)));
717 gboolean menu_cb_mapman(GtkAction * action)
725 GtkWidget *lbl_gps_lat;
726 GtkWidget *lbl_gps_lon;
727 GtkWidget *lbl_center_lat;
728 GtkWidget *lbl_center_lon;
729 MapmanInfo mapman_info;
734 mapman_info.dialog = dialog = gtk_dialog_new_with_buttons(_("Manage Maps"), GTK_WINDOW(_window),
735 GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
737 help_dialog_help_enable(GTK_DIALOG(mapman_info.dialog), HELP_ID_MAPMAN);
740 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area),
741 button = gtk_button_new_with_label(_("Clear")));
742 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(mapman_clear), &mapman_info);
745 gtk_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
747 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), mapman_info.notebook = gtk_notebook_new(), TRUE, TRUE, 0);
750 gtk_notebook_append_page(GTK_NOTEBOOK(mapman_info.notebook), vbox = gtk_vbox_new(FALSE, 2), label = gtk_label_new(_("Setup")));
751 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(mapman_info.notebook), vbox, FALSE, FALSE, GTK_PACK_START);
753 gtk_box_pack_start(GTK_BOX(vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 0);
754 gtk_box_pack_start(GTK_BOX(hbox), mapman_info.rad_download = gtk_radio_button_new_with_label(NULL, _("Download Maps")), FALSE, FALSE, 0);
755 gtk_box_pack_start(GTK_BOX(hbox), label = gtk_alignment_new(0.f, 0.5f, 0.f, 0.f), FALSE, FALSE, 0);
756 mapman_info.chk_overwrite = gtk_check_button_new_with_label(_("Overwrite"));
757 gtk_toggle_button_set_active(mapman_info.chk_overwrite, TRUE);
758 mapman_info.rad_delete = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(mapman_info.rad_download), _("Delete Maps"));
760 gtk_container_add(GTK_CONTAINER(label), mapman_info.chk_overwrite);
761 gtk_box_pack_start(GTK_BOX(vbox), mapman_info.rad_delete, FALSE, FALSE, 0);
763 gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
765 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);
766 gtk_box_pack_start(GTK_BOX(vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 0);
769 gtk_box_pack_start(GTK_BOX(hbox), mapman_info.rad_by_route = gtk_radio_button_new_with_label_from_widget
770 (GTK_RADIO_BUTTON(mapman_info.rad_by_area), _("Along Route - Radius (tiles):")), FALSE, FALSE, 0);
771 gtk_widget_set_sensitive(mapman_info.rad_by_route, _route->head != _route->tail);
772 gtk_box_pack_start(GTK_BOX(hbox), mapman_info.num_route_radius = hildon_number_editor_new(0, 100), FALSE, FALSE, 0);
773 hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(mapman_info.num_route_radius), _route_dl_radius);
776 gtk_box_pack_start(GTK_BOX(vbox), hbox = gtk_hbox_new(FALSE, 4), FALSE, FALSE, 0);
777 gtk_box_pack_start(GTK_BOX(hbox), mapman_info.rad_by_track = gtk_radio_button_new_with_label_from_widget
778 (GTK_RADIO_BUTTON(mapman_info.rad_by_area), _("Along Track - Radius (tiles):")), FALSE, FALSE, 0);
779 gtk_widget_set_sensitive(mapman_info.rad_by_track, _track->head != _track->tail);
780 gtk_box_pack_start(GTK_BOX(hbox), mapman_info.num_track_radius = hildon_number_editor_new(0, 100), FALSE, FALSE, 0);
781 hildon_number_editor_set_value(HILDON_NUMBER_EDITOR(mapman_info.num_track_radius), _track_dl_radius);
784 gtk_notebook_append_page(GTK_NOTEBOOK(mapman_info.notebook),
785 table = gtk_table_new(5, 5, FALSE),
786 label = gtk_label_new(_("Zoom")));
787 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(mapman_info.notebook), table, FALSE, FALSE, GTK_PACK_START);
788 gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Zoom Levels to Download: (0 = most detail)")), 0, 4, 0, 1, GTK_FILL, 0, 4, 0);
789 gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
790 for (i = 0; i < _curr_repo->max_zoom; i++) {
791 g_snprintf(buffer, sizeof(buffer), "%d", i);
792 gtk_table_attach(GTK_TABLE(table),
793 mapman_info.chk_zoom_levels[i] = gtk_check_button_new_with_label(buffer),
794 i % 4, i % 4 + 1, i / 4 + 1, i / 4 + 2, GTK_EXPAND | GTK_FILL, 0, 4, 0);
798 gtk_notebook_append_page(GTK_NOTEBOOK(mapman_info.notebook),
799 mapman_info.tbl_area =
800 gtk_table_new(3, 4, FALSE), label =
801 gtk_label_new(_("Area")));
804 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
805 label = gtk_label_new(_("Latitude")),
806 1, 2, 0, 1, GTK_FILL, 0, 4, 0);
807 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
808 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
809 label = gtk_label_new(_("Longitude")),
810 2, 3, 0, 1, GTK_FILL, 0, 4, 0);
811 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
814 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
815 label = gtk_label_new(_("GPS Location")),
816 0, 1, 1, 2, GTK_FILL, 0, 4, 0);
817 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
818 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
819 lbl_gps_lat = gtk_label_new(""),
820 1, 2, 1, 2, GTK_FILL, 0, 4, 0);
821 gtk_label_set_selectable(GTK_LABEL(lbl_gps_lat), TRUE);
822 gtk_misc_set_alignment(GTK_MISC(lbl_gps_lat), 1.f, 0.5f);
823 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
824 lbl_gps_lon = gtk_label_new(""),
825 2, 3, 1, 2, GTK_FILL, 0, 4, 0);
826 gtk_label_set_selectable(GTK_LABEL(lbl_gps_lon), TRUE);
827 gtk_misc_set_alignment(GTK_MISC(lbl_gps_lon), 1.f, 0.5f);
830 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
831 label = gtk_label_new(_("View Center")),
832 0, 1, 2, 3, GTK_FILL, 0, 4, 0);
833 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
834 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
835 lbl_center_lat = gtk_label_new(""),
836 1, 2, 2, 3, GTK_FILL, 0, 4, 0);
837 gtk_label_set_selectable(GTK_LABEL(lbl_center_lat), TRUE);
838 gtk_misc_set_alignment(GTK_MISC(lbl_center_lat), 1.f, 0.5f);
839 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
840 lbl_center_lon = gtk_label_new(""),
841 2, 3, 2, 3, GTK_FILL, 0, 4, 0);
842 gtk_label_set_selectable(GTK_LABEL(lbl_center_lon), TRUE);
843 gtk_misc_set_alignment(GTK_MISC(lbl_center_lon), 1.f, 0.5f);
845 /* default values for Top Left and Bottom Right are defined by the
846 * rectangle of the current and the previous Center */
849 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
850 label = gtk_label_new(_("Top-Left")),
851 0, 1, 3, 4, GTK_FILL, 0, 4, 0);
852 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
853 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
854 mapman_info.txt_topleft_lat = gtk_entry_new(),
855 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 4, 0);
856 gtk_entry_set_alignment(GTK_ENTRY(mapman_info.txt_topleft_lat), 1.f);
857 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
858 mapman_info.txt_topleft_lon = gtk_entry_new(),
859 2, 3, 3, 4, GTK_EXPAND | GTK_FILL, 0, 4, 0);
860 gtk_entry_set_alignment(GTK_ENTRY(mapman_info.txt_topleft_lon), 1.f);
863 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
864 label = gtk_label_new(_("Bottom-Right")),
865 0, 1, 4, 5, GTK_FILL, 0, 4, 0);
866 gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
867 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
868 mapman_info.txt_botright_lat = gtk_entry_new(),
869 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 4, 0);
870 gtk_entry_set_alignment(GTK_ENTRY(mapman_info.txt_botright_lat), 1.f);
871 gtk_table_attach(GTK_TABLE(mapman_info.tbl_area),
872 mapman_info.txt_botright_lon = gtk_entry_new(),
873 2, 3, 4, 5, GTK_EXPAND | GTK_FILL, 0, 4, 0);
874 gtk_entry_set_alignment(GTK_ENTRY(mapman_info.txt_botright_lon), 1.f);
876 #if defined(WITH_DEVICE_770) && !defined(WITH_HILDON_NEW)
877 /* Set hildon input hints */
878 g_object_set(G_OBJECT(mapman_info.txt_topleft_lon),
879 HILDON_INPUT_MODE_HINT,
880 HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
881 g_object_set(G_OBJECT(mapman_info.txt_topleft_lat),
882 HILDON_INPUT_MODE_HINT,
883 HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
884 g_object_set(G_OBJECT(mapman_info.txt_botright_lon),
885 HILDON_INPUT_MODE_HINT,
886 HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
887 g_object_set(G_OBJECT(mapman_info.txt_botright_lat),
888 HILDON_INPUT_MODE_HINT,
889 HILDON_INPUT_MODE_HINT_NUMERICSPECIAL, NULL);
892 /* Default action is to download by area. */
893 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mapman_info.rad_by_area), TRUE);
895 /* Initialize fields. Do no use g_ascii_formatd; these strings will be
896 * output (and parsed) as locale-dependent. */
898 g_snprintf(buffer, sizeof(buffer), "%.06f", _gps->data.lat);
899 gtk_label_set_text(GTK_LABEL(lbl_gps_lat), buffer);
900 g_snprintf(buffer, sizeof(buffer), "%.06f", _gps->data.lon);
901 gtk_label_set_text(GTK_LABEL(lbl_gps_lon), buffer);
903 gtk_map_get_center_latlon(_map, &lat, &lon);
904 g_snprintf(buffer, sizeof(buffer), "%.06f", lat);
905 gtk_label_set_text(GTK_LABEL(lbl_center_lat), buffer);
906 g_snprintf(buffer, sizeof(buffer), "%.06f", lon);
907 gtk_label_set_text(GTK_LABEL(lbl_center_lon), buffer);
909 /* Initialize to the bounds of the screen. */
910 g_object_get(_map, "min-lat", &lat, "max-lon", &lon);
911 g_snprintf(buffer, sizeof(buffer), "%.06f", lat);
912 gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_topleft_lat), buffer);
913 g_snprintf(buffer, sizeof(buffer), "%.06f", lon);
914 gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_topleft_lon), buffer);
916 g_object_get(_map, "max-lat", &lat, "min-lon", &lon);
917 g_snprintf(buffer, sizeof(buffer), "%.06f", lat);
918 gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_botright_lat), buffer);
919 g_snprintf(buffer, sizeof(buffer), "%.06f", lon);
920 gtk_entry_set_text(GTK_ENTRY(mapman_info.txt_botright_lon), buffer);
922 czoom=gtk_map_get_zoom(_map);
923 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mapman_info.chk_zoom_levels[czoom]), TRUE);
925 gtk_widget_show_all(dialog);
927 mapman_update_state(NULL, &mapman_info);
929 /* Connect signals. */
930 if (_curr_repo->type != REPOTYPE_NONE) {
931 g_signal_connect(G_OBJECT(mapman_info.rad_download), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
932 gtk_widget_set_sensitive(mapman_info.rad_download, TRUE);
934 gtk_widget_set_sensitive(mapman_info.rad_download, FALSE);
935 popup_error(dialog, _("NOTE: You must set a Map URI in the current repository in order to download maps."));
938 g_signal_connect(G_OBJECT(mapman_info.rad_delete), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
939 g_signal_connect(G_OBJECT(mapman_info.rad_by_area), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
940 g_signal_connect(G_OBJECT(mapman_info.rad_by_route), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
941 g_signal_connect(G_OBJECT(mapman_info.rad_by_track), "clicked", G_CALLBACK(mapman_update_state), &mapman_info);
943 while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(dialog))) {
944 gboolean is_deleting = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.rad_delete));
945 gboolean is_overwriting = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.chk_overwrite));
946 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.rad_by_route))) {
947 _route_dl_radius = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(mapman_info.num_route_radius));
948 if (mapman_by_path(_route, &mapman_info, _route_dl_radius, is_deleting, is_overwriting))
950 } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mapman_info.rad_by_track))) {
951 _track_dl_radius = hildon_number_editor_get_value(HILDON_NUMBER_EDITOR(mapman_info.num_track_radius));
952 if (mapman_by_path(_track, &mapman_info, _track_dl_radius, is_deleting, is_overwriting))
957 gdouble start_lat, start_lon, end_lat, end_lon;
959 text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_topleft_lat));
960 start_lat = strtof(text, &error_check);
961 if (text == error_check || start_lat < -90.f || start_lat > 90.f) {
962 popup_error(dialog, _("Invalid Top-Left Latitude"));
966 text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_topleft_lon));
967 start_lon = strtof(text, &error_check);
968 if (text == error_check || start_lon < -180.f || start_lon > 180.f) {
969 popup_error(dialog, _("Invalid Top-Left Longitude"));
973 text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_botright_lat));
974 end_lat = strtof(text, &error_check);
975 if (text == error_check || end_lat < -90.f || end_lat > 90.f) {
976 popup_error(dialog, _("Invalid Bottom-Right Latitude"));
980 text = gtk_entry_get_text(GTK_ENTRY(mapman_info.txt_botright_lon));
981 end_lon = strtof(text, &error_check);
982 if (text == error_check || end_lon < -180.f || end_lon > 180.f) {
983 popup_error(dialog, _("Invalid Bottom-Right Longitude"));
987 if (mapman_by_area(start_lat, start_lon, end_lat, end_lon, &mapman_info, is_deleting, is_overwriting))
992 gtk_widget_hide(dialog); /* Destroying causes a crash (!?!?!??!) */