From: Kaj-Michael Lang Date: Mon, 4 Feb 2008 12:30:16 +0000 (+0200) Subject: Move repo parse to config-gconf X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=87507732ded3aaf7962e9101cc9d92c1886934bf;p=mapper Move repo parse to config-gconf --- diff --git a/src/config-gconf.c b/src/config-gconf.c index 4df36f8..9810f13 100644 --- a/src/config-gconf.c +++ b/src/config-gconf.c @@ -128,6 +128,60 @@ g_slist_free(temp_list); return TRUE; } +RepoData * +config_parse_repo(gchar * str) +{ + /* Parse each part of a repo, delimited by newline characters: + * 1. name + * 2. url + * 3. cache_dir + * 4. dl_zoom_steps + * 5. view_zoom_steps + */ +gchar *token, *error_check; + +RepoData *rd = g_new0(RepoData, 1); + +/* Parse name. */ +token = strsep(&str, "\n\t"); +if (token) + rd->name = g_strdup(token); + +/* Parse URL format. */ +token = strsep(&str, "\n\t"); +if (token) + rd->url = g_strdup(token); + +/* Parse cache dir. */ +token = strsep(&str, "\n\t"); +if (token) + rd->cache_dir = gnome_vfs_expand_initial_tilde(token); + +/* Parse download zoom steps. */ +token = strsep(&str, "\n\t"); +if (!token || !*token || !(rd->dl_zoom_steps = atoi(token))) + rd->dl_zoom_steps = 2; + +/* Parse view zoom steps. */ +token = strsep(&str, "\n\t"); +if (!token || !*token || !(rd->view_zoom_steps = atoi(token))) + rd->view_zoom_steps = 1; + +/* Parse double-size. */ +token = strsep(&str, "\n\t"); +if (token) + rd->double_size = atoi(token); /* Default is zero (FALSE) */ + +/* Parse next-able. */ +token = strsep(&str, "\n\t"); +if (!token || !*token + || (rd->nextable = strtol(token, &error_check, 10), token == str)) + rd->nextable = TRUE; + +set_repo_type(rd); +return rd; +} + static void config_default_repo(void) { diff --git a/src/config-gconf.h b/src/config-gconf.h index c8e3be5..f48d9a4 100644 --- a/src/config-gconf.h +++ b/src/config-gconf.h @@ -3,12 +3,14 @@ #include #include "filter.h" +#include "mapper-types.h" GConfClient *gconf_client; void config_init(void); gboolean config_save_repo(void); gboolean config_load_repo(void); +RepoData *config_parse_repo(gchar *str); gboolean config_save_home(void); gboolean config_save(void); void config_update_proxy(void); diff --git a/src/map-repo.c b/src/map-repo.c index e5a8d90..083d34a 100644 --- a/src/map-repo.c +++ b/src/map-repo.c @@ -119,60 +119,6 @@ if (repo->url && *repo->url) { repo->type = REPOTYPE_NONE; } -RepoData * -config_parse_repo(gchar * str) -{ - /* Parse each part of a repo, delimited by newline characters: - * 1. name - * 2. url - * 3. cache_dir - * 4. dl_zoom_steps - * 5. view_zoom_steps - */ -gchar *token, *error_check; - -RepoData *rd = g_new0(RepoData, 1); - -/* Parse name. */ -token = strsep(&str, "\n\t"); -if (token) - rd->name = g_strdup(token); - -/* Parse URL format. */ -token = strsep(&str, "\n\t"); -if (token) - rd->url = g_strdup(token); - -/* Parse cache dir. */ -token = strsep(&str, "\n\t"); -if (token) - rd->cache_dir = gnome_vfs_expand_initial_tilde(token); - -/* Parse download zoom steps. */ -token = strsep(&str, "\n\t"); -if (!token || !*token || !(rd->dl_zoom_steps = atoi(token))) - rd->dl_zoom_steps = 2; - -/* Parse view zoom steps. */ -token = strsep(&str, "\n\t"); -if (!token || !*token || !(rd->view_zoom_steps = atoi(token))) - rd->view_zoom_steps = 1; - -/* Parse double-size. */ -token = strsep(&str, "\n\t"); -if (token) - rd->double_size = atoi(token); /* Default is zero (FALSE) */ - -/* Parse next-able. */ -token = strsep(&str, "\n\t"); -if (!token || !*token - || (rd->nextable = strtol(token, &error_check, 10), token == str)) - rd->nextable = TRUE; - -set_repo_type(rd); -return rd; -} - gboolean repo_make_cache_dir(gchar * name, const gchar * cache_dir, GtkWidget * parent) {