From 94e676de05a10d73cd5e78f84ab5e7bb4e19bd58 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Fri, 25 Jan 2008 13:19:00 +0200 Subject: [PATCH] Formating --- src/map-repo.c | 909 +++++++++++++++++++++++-------------------------- 1 file changed, 418 insertions(+), 491 deletions(-) diff --git a/src/map-repo.c b/src/map-repo.c index 13a4802..ef60a37 100644 --- a/src/map-repo.c +++ b/src/map-repo.c @@ -234,32 +234,29 @@ GtkWidget *txt_name; GtkWidget *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); - - 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_widget_show_all(dialog); - - 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_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(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); + +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; @@ -272,31 +269,26 @@ 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.")); - 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; +} - 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); +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); - 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)); - } +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)); +} - gtk_widget_destroy(confirm); +gtk_widget_destroy(confirm); - return TRUE; +return TRUE; } static RepoEditInfo * @@ -311,118 +303,106 @@ 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_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); +} - 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); +gtk_box_pack_start(GTK_BOX(vbox), table = gtk_table_new(3, 2, FALSE), FALSE, FALSE, 0); - /* 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(_("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.5f, 0.5f, 0.f, 0.f), 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 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); - gtk_box_pack_start(GTK_BOX(vbox), table = gtk_table_new(3, 2, FALSE), FALSE, FALSE, 0); +/* 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.5f, 0.5f, 0.f, 0.f), 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 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); - /* 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.5f, 0.5f, 0.f, 0.f), 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 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.5f, 0.5f, 0.f, 0.f), 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 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); - 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); - /* 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); - /* 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); - 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); - /* 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; +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; } static gboolean repoman_dialog_new(GtkWidget * widget, RepoManInfo * rmi) { - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *txt_name; - GtkWidget *dialog; +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); - return TRUE; +return TRUE; } static gboolean @@ -430,32 +410,26 @@ repoman_reset(GtkWidget * widget, RepoManInfo * rmi) { 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)); +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); - return TRUE; +return TRUE; } static gboolean @@ -463,188 +437,180 @@ repoman_download(GtkWidget * widget, RepoManInfo * rmi) { 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)); - } +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); - return TRUE; +return TRUE; } 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; - - 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); +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; +} - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(rmi.notebook), FALSE); - gtk_notebook_set_show_border(GTK_NOTEBOOK(rmi.notebook), FALSE); +/* 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); - rmi.repo_edits = NULL; +gtk_widget_show_all(rmi.dialog); - /* 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)); +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; - /* 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; - } - - /* ** */ - - /* 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; +} - 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; } static gboolean @@ -652,196 +618,157 @@ 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; +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); +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; - } +/* 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; +} - /* 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); +/* 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 (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); +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); - if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) { - gtk_widget_destroy(confirm); - 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)); - } - } +if (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) { gtk_widget_destroy(confirm); - return TRUE; + 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)); + } +} +gtk_widget_destroy(confirm); +return TRUE; } static gboolean -mapman_by_route(MapmanInfo * mapman_info, - gboolean is_deleting, gboolean is_overwriting) +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)); - - /* 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) { + 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 (GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(confirm))) { - gtk_widget_destroy(confirm); - 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); - return TRUE; +} +_route_dl_radius = radius; +gtk_widget_destroy(confirm); +return TRUE; } static void -- 2.39.5