/*
* 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.
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."));
}
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);
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);
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;
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);
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);
* 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;
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;
};
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);
};
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);
} 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);
/* 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);
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) {
_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)));
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);
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();
#include "tilerepo.h"
GList *_repo_list;
-RepoData *_curr_repo;
+TileRepo *_curr_repo;
gboolean repoman_dialog(void);
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;