From f2e4affb59b69b20b7d19bed383721f0a5f7d085 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 12 Aug 2008 17:36:50 +0300 Subject: [PATCH] Mapper: Quick adjust for RepoData -> TileRepo rename/gobjectifying --- src/cb.c | 9 ++++----- src/config-gconf.c | 44 +++++++++++++++++++++--------------------- src/config-gconf.h | 2 +- src/map-download.c | 2 +- src/map-download.h | 4 ++-- src/map-repo-manager.c | 20 +++++++++---------- src/map-repo-manager.h | 2 +- src/ui-common.c | 2 +- 8 files changed, 42 insertions(+), 43 deletions(-) diff --git a/src/cb.c b/src/cb.c index 6cbcef5..d7414f5 100644 --- a/src/cb.c +++ b/src/cb.c @@ -1,7 +1,7 @@ /* * This file is part of mapper * - * Copyright (C) 2007 Kaj-Michael Lang + * Copyright (C) 2007-2008 Kaj-Michael Lang * Copyright (C) 2006-2007 John Costigan. * * POI and GPS-Info code originally written by Cezary Jackiewicz. @@ -691,14 +691,13 @@ switch (_action[custom_key]) { if (!curr) break; - /* Loop until we reach a next-able repo, or until we get - * back to the current repo. */ - while ((curr = (curr->next ? curr->next : _repo_list)) && !((RepoData *) curr->data)->nextable && curr->data != _curr_repo) { + /* Loop until we reach a next-able repo, or until we get back to the current repo. */ + while ((curr = (curr->next ? curr->next : _repo_list)) && !((TileRepo *) curr->data)->nextable && curr->data != _curr_repo) { } if (curr->data != _curr_repo) { repo_set_curr(curr->data); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_curr_repo->menu_item), TRUE); + /* gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(_curr_repo->menu_item), TRUE); */ } else { popup_error(_window, _("There are no other next-able repositories.")); } diff --git a/src/config-gconf.c b/src/config-gconf.c index 0e818d4..67d4e55 100644 --- a/src/config-gconf.c +++ b/src/config-gconf.c @@ -88,26 +88,23 @@ gint curr_repo_index = 0; g_assert(gconf_client); /* Save the repositories. */ for (curr = _repo_list; curr != NULL; curr = curr->next) { + gchar *repostr; + /* Build from each part of a repo, delimited by newline characters: * 1. url * 2. cache_dir * 3. dl_zoom_steps * 4. view_zoom_steps */ - RepoData *rd = curr->data; - gchar buffer[BUFFER_SIZE]; - g_snprintf(buffer, sizeof(buffer), - "%s\t%s\t%s\t%d\t%d\t%d\t%d", - rd->name, - rd->url, - rd->cache_dir, - rd->dl_zoom_steps, - rd->view_zoom_steps, - rd->double_size, rd->nextable); - temp_list = g_slist_append(temp_list, g_strdup(buffer)); - if (rd == _curr_repo) - gconf_client_set_int(gconf_client, GCONF_KEY_CURRREPO, curr_repo_index, NULL); - curr_repo_index++; + TileRepo *rd=curr->data; + + repostr=tile_repo_get_string(rd); + if (repostr) { + temp_list=g_slist_append(temp_list, repostr); + if (rd==_curr_repo) + gconf_client_set_int(gconf_client, GCONF_KEY_CURRREPO, curr_repo_index, NULL); + curr_repo_index++; + } } gconf_client_set_list(gconf_client, GCONF_KEY_REPOSITORIES, GCONF_VALUE_STRING, temp_list, NULL); @@ -116,15 +113,15 @@ g_slist_free(temp_list); return TRUE; } -static RepoData * +static TileRepo * config_default_repo(void) { -RepoData *repo; +TileRepo *repo; g_assert(gconf_client); /* We have no repositories - create a default one. */ -repo=map_tile_repo_new(); +repo=tile_repo_new(); /* Get Map Cache Dir. Default is REPO_DEFAULT_CACHE_DIR. */ repo->cache_dir=gconf_client_get_string(gconf_client, GCONF_KEY_MAP_DIR_NAME, NULL); @@ -146,7 +143,7 @@ repo->name=g_strdup(REPO_DEFAULT_NAME); repo->view_zoom_steps=REPO_DEFAULT_VIEW_ZOOM_STEPS; repo->double_size=FALSE; repo->nextable=TRUE; -map_tile_repo_set_type(repo); +tile_repo_set_type(repo); _repo_list=g_list_append(_repo_list, repo); return repo; @@ -164,10 +161,13 @@ curr_repo_index=gconf_client_get_int(gconf_client, GCONF_KEY_CURRREPO, NULL); list=gconf_client_get_list(gconf_client, GCONF_KEY_REPOSITORIES, GCONF_VALUE_STRING, NULL); for (curr = list; curr != NULL; curr = curr->next) { - RepoData *rd = map_tile_repo_new_from_string(curr->data); - _repo_list = g_list_append(_repo_list, rd); - if (!curr_repo_index--) - _curr_repo=rd; + TileRepo *rd=tile_repo_new_from_string(curr->data); + + if (rd) { + _repo_list=g_list_append(_repo_list, rd); + if (!curr_repo_index--) + _curr_repo=rd; + } g_free(curr->data); } g_slist_free(list); diff --git a/src/config-gconf.h b/src/config-gconf.h index 50acd50..a3aefa5 100644 --- a/src/config-gconf.h +++ b/src/config-gconf.h @@ -15,7 +15,7 @@ gboolean config_save(void); gboolean config_save_repo(void); gboolean config_load_repo(void); -RepoData *config_parse_repo(gchar *str); +TileRepo *config_parse_repo(gchar *str); gboolean config_load_position(Position *pos, const gchar *key); gboolean config_save_position(Position *pos, const gchar *key); diff --git a/src/map-download.c b/src/map-download.c index c890135..2f458ab 100644 --- a/src/map-download.c +++ b/src/map-download.c @@ -447,7 +447,7 @@ return FALSE; * downloading the map, then this method does nothing. */ void -map_download(RepoData *repo, guint tilex, guint tiley, guint zoom, gint retries) +map_download(TileRepo *repo, guint tilex, guint tiley, guint zoom, gint retries) { ProgressUpdateInfo *pui; diff --git a/src/map-download.h b/src/map-download.h index 97cf816..99579e9 100644 --- a/src/map-download.h +++ b/src/map-download.h @@ -23,7 +23,7 @@ typedef struct _ProgressUpdateInfo ProgressUpdateInfo; struct _ProgressUpdateInfo { gchar *src_str; gchar *dest_str; - RepoData *repo; + TileRepo *repo; guint tilex, tiley, zoom; /* for refresh. */ gint retries; /* if equal to zero, it means we're DELETING maps. */ guint priority; @@ -31,7 +31,7 @@ struct _ProgressUpdateInfo { }; void map_download_init(void); -void map_download(RepoData *repo, guint tilex, guint tiley, guint zoom, gint retries); +void map_download(TileRepo *repo, guint tilex, guint tiley, guint zoom, gint retries); gboolean map_download_stop(void); gboolean map_download_timeout(); gboolean map_download_idle_refresh(ProgressUpdateInfo * pui); diff --git a/src/map-repo-manager.c b/src/map-repo-manager.c index f860231..f4921f3 100644 --- a/src/map-repo-manager.c +++ b/src/map-repo-manager.c @@ -103,11 +103,11 @@ struct _MapmanInfo { }; gboolean -repo_set_curr(RepoData *rd) +repo_set_curr(TileRepo *rd) { _curr_repo=rd; gtk_map_set_tile_repository(_map, _curr_repo); -if (map_tile_repo_make_cache_dir(rd)==FALSE) { +if (tile_repo_make_cache_dir(rd)==FALSE) { gchar buffer[BUFFER_SIZE]; g_snprintf(buffer, sizeof(buffer), "%s: %s", _("Unable to create cache directory for repository"), rd->name); popup_error(_window, buffer); @@ -372,11 +372,11 @@ if (GTK_RESPONSE_OK == gtk_dialog_run(GTK_DIALOG(confirm))) { } else { /* Parse each line as a repository. */ for (head = bytes; head && *head; head = tail) { - RepoData *rd; + TileRepo *rd; RepoEditInfo *rei; tail = strchr(head, '\n'); *tail++ = '\0'; - rd = map_tile_repo_new_from_string(head); + rd = tile_repo_new_from_string(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); @@ -447,10 +447,10 @@ 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; + TileRepo *rd = (TileRepo *)curr->data; RepoEditInfo *rei = repoman_dialog_add_repo(&rmi, g_strdup(rd->name)); - /* Initialize fields with data from the RepoData object. */ + /* Initialize fields with data from the TileRepo 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); @@ -481,7 +481,7 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(rmi.dialog))) { 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 = map_tile_repo_make_cache_dir(rei); + verified = tile_repo_make_cache_dir(rei); g_free(expanded); } if (!verified) { @@ -497,7 +497,7 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(rmi.dialog))) { _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); + TileRepo *rd = tile_repo_new(); rd->name = g_strdup(rei->name); rd->url = g_strdup(gtk_entry_get_text(GTK_ENTRY(rei->txt_url))); @@ -507,7 +507,7 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(rmi.dialog))) { 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)); - map_tile_repo_set_type(rd); + tile_repo_set_type(rd); _repo_list = g_list_append(_repo_list, rd); @@ -517,7 +517,7 @@ while (GTK_RESPONSE_ACCEPT == gtk_dialog_run(GTK_DIALOG(rmi.dialog))) { repo_set_curr(rd); } if (!_curr_repo) - repo_set_curr((RepoData *) g_list_first(_repo_list)->data); + repo_set_curr((TileRepo *)g_list_first(_repo_list)->data); menu_maps_add_repos(); config_save_repo(); diff --git a/src/map-repo-manager.h b/src/map-repo-manager.h index d3967b6..dcea10e 100644 --- a/src/map-repo-manager.h +++ b/src/map-repo-manager.h @@ -4,7 +4,7 @@ #include "tilerepo.h" GList *_repo_list; -RepoData *_curr_repo; +TileRepo *_curr_repo; gboolean repoman_dialog(void); diff --git a/src/ui-common.c b/src/ui-common.c index 0f5c096..f28584b 100644 --- a/src/ui-common.c +++ b/src/ui-common.c @@ -398,7 +398,7 @@ gtk_ui_manager_insert_action_group(ui, map_repos_action_group, 0); gtk_ui_manager_ensure_update(ui); for (curr = g_list_last(_repo_list); curr; curr = curr->prev) { - RepoData *rd = (RepoData *) curr->data; + TileRepo *rd = (TileRepo *) curr->data; GtkAction *action; gchar *action_name; -- 2.39.5