From f2a468c3ccff47cad84c81f903797cc67cfc5856 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 9 Aug 2007 11:02:21 +0300 Subject: [PATCH] Rename config.c to config-gconf.c, add header. --- src/Makefile.am | 2 +- src/{config.c => config-gconf.c} | 97 ++++++++++++++++++-------------- src/config-gconf.h | 12 ++++ 3 files changed, 67 insertions(+), 44 deletions(-) rename src/{config.c => config-gconf.c} (94%) create mode 100644 src/config-gconf.h diff --git a/src/Makefile.am b/src/Makefile.am index 3a5c42d..7095dee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,7 +54,7 @@ mapper_SOURCES = utils.c \ speed-display.c \ hildon-wrappers.c \ ui-common.c \ - config.c \ + config-gconf.c \ mapper.c osm2db_CFLAGS = $(EXPAT_CFLAGS) $(SQLITE_CFLAGS) $(GLIBGTK_CFLAGS) diff --git a/src/config.c b/src/config-gconf.c similarity index 94% rename from src/config.c rename to src/config-gconf.c index cbf5446..657dab8 100644 --- a/src/config.c +++ b/src/config-gconf.c @@ -18,6 +18,7 @@ #include #include +#include "config-gconf.h" #include "utils.h" #include "mapper-types.h" #include "map.h" @@ -29,7 +30,7 @@ #include "ui-common.h" #include "settings.h" -void config_update_proxy() +void config_update_proxy(void) { GConfClient *gconf_client = gconf_client_get_default(); printf("%s()\n", __PRETTY_FUNCTION__); @@ -83,7 +84,7 @@ g_free(route_file); } gboolean -config_save_repo() +config_save_repo(void) { GConfClient *gconf_client = gconf_client_get_default(); GList *curr = _repo_list; @@ -120,10 +121,56 @@ for (curr = _repo_list; curr != NULL; curr = curr->next) { gconf_client_set_list(gconf_client, GCONF_KEY_REPOSITORIES, GCONF_VALUE_STRING, temp_list, NULL); + +g_slist_free(temp_list); + +return TRUE; +} + +static void +config_default_repo(void) +{ +/* We have no repositories - create a default one. */ +RepoData *repo = g_new(RepoData, 1); +GConfClient *gconf_client = gconf_client_get_default(); + +if (!gconf_client) + return FALSE; + +/* 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); + +if (!repo->cache_dir) + repo->cache_dir = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_DIR); + +/* Get Map Download URL Format. Default is "". */ +repo->url = gconf_client_get_string(gconf_client, + GCONF_KEY_MAP_URI_FORMAT, + NULL); +if (!repo->url) + repo->url = g_strdup(REPO_DEFAULT_MAP_URI); + +/* Get Map Download Zoom Steps. Default is 2. */ +repo->dl_zoom_steps = gconf_client_get_int(gconf_client, + GCONF_KEY_MAP_ZOOM_STEPS, + NULL); +if (!repo->dl_zoom_steps) + repo->dl_zoom_steps = REPO_DEFAULT_DL_ZOOM_STEPS; + +repo->name = g_strdup(REPO_DEFAULT_NAME); +repo->view_zoom_steps = REPO_DEFAULT_VIEW_ZOOM_STEPS; +repo->double_size = FALSE; +repo->nextable = TRUE; +set_repo_type(repo); + +_repo_list = g_list_append(_repo_list, repo); +repo_set_curr(repo); } gboolean -config_load_repo() +config_load_repo(void) { GSList *list, *curr; GConfValue *value; @@ -146,44 +193,8 @@ for (curr = list; curr != NULL; curr = curr->next) { } g_slist_free(list); -if (_repo_list == NULL) { - /* We have no repositories - create a default one. */ - RepoData *repo = g_new(RepoData, 1); - - /* Many fields can be retrieved from the "old" gconf keys. */ - - /* 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); - - if (!repo->cache_dir) - repo->cache_dir = gnome_vfs_expand_initial_tilde(REPO_DEFAULT_CACHE_DIR); - - /* Get Map Download URL Format. Default is "". */ - repo->url = gconf_client_get_string(gconf_client, - GCONF_KEY_MAP_URI_FORMAT, - NULL); - if (!repo->url) - repo->url = g_strdup(REPO_DEFAULT_MAP_URI); - - /* Get Map Download Zoom Steps. Default is 2. */ - repo->dl_zoom_steps = gconf_client_get_int(gconf_client, - GCONF_KEY_MAP_ZOOM_STEPS, - NULL); - if (!repo->dl_zoom_steps) - repo->dl_zoom_steps = REPO_DEFAULT_DL_ZOOM_STEPS; - - /* Other fields are brand new. */ - repo->name = g_strdup(REPO_DEFAULT_NAME); - repo->view_zoom_steps = REPO_DEFAULT_VIEW_ZOOM_STEPS; - repo->double_size = FALSE; - repo->nextable = TRUE; - set_repo_type(repo); - - _repo_list = g_list_append(_repo_list, repo); - repo_set_curr(repo); -} +if (_repo_list == NULL) + config_default_repo(); return TRUE; } @@ -225,7 +236,7 @@ return TRUE; * Save all configuration data to GCONF. */ gboolean -config_save() +config_save(void) { gchar *config_dir; GConfClient *gconf_client = gconf_client_get_default(); @@ -420,7 +431,7 @@ config_save() * Initialize all configuration from GCONF. This should not be called more * than once during execution. */ -void config_init() +void config_init(void) { GConfValue *value; GConfClient *gconf_client = gconf_client_get_default(); diff --git a/src/config-gconf.h b/src/config-gconf.h new file mode 100644 index 0000000..e269f71 --- /dev/null +++ b/src/config-gconf.h @@ -0,0 +1,12 @@ +#ifndef _CONFIG_GCONF_H +#define _CONFIG_GCONF_H + +void config_init(void); +gboolean config_save_repo(void); +gboolean config_load_repo(void); +gboolean config_save_home(void); +gboolean config_save_filter(void); +gboolean config_save(void); +void config_update_proxy(void); + +#endif -- 2.39.5