diff options
author | Vincent Sanders <vince@kyllikki.org> | 2015-06-19 16:15:24 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2015-06-21 23:27:21 +0100 |
commit | 9ccf0cee9f4c070146a225fc633591436b1a88eb (patch) | |
tree | 4dcea6c1047d8b9a3103b8abb788a82ba64b8799 | |
parent | 010306e1ad48c66650bff68ec0e4e485f6518a65 (diff) | |
download | netsurf-9ccf0cee9f4c070146a225fc633591436b1a88eb.tar.gz netsurf-9ccf0cee9f4c070146a225fc633591436b1a88eb.tar.bz2 |
Change GTK resource path to use the users netsurf directory
This changes the path used to find resources from containg a hard
coded ${HOME}/.netsurf to using the computed path to the users netsurf
config.
-rw-r--r-- | gtk/gui.c | 39 |
1 files changed, 37 insertions, 2 deletions
@@ -107,12 +107,41 @@ static void die(const char * const error) * searched for. */ static char ** -nsgtk_init_resource_path(const char *resource_path) +nsgtk_init_resource_path(const char *config_home) { + char *resource_path; + int resource_path_len; const gchar * const *langv; char **pathv; /* resource path string vector */ char **respath; /* resource paths vector */ + if (config_home != NULL) { + resource_path_len = snprintf(NULL, 0, + "%s:${NETSURFRES}:%s:./gtk/res", + config_home, + GTK_RESPATH); + resource_path = malloc(resource_path_len + 1); + if (resource_path == NULL) { + return NULL; + } + snprintf(resource_path, resource_path_len + 1, + "%s:${NETSURFRES}:%s:./gtk/res", + config_home, + GTK_RESPATH); + } else { + resource_path_len = snprintf(NULL, 0, + "${NETSURFRES}:%s:./gtk/res", + GTK_RESPATH); + resource_path = malloc(resource_path_len + 1); + if (resource_path == NULL) { + return NULL; + } + snprintf(resource_path, + resource_path_len + 1, + "${NETSURFRES}:%s:./gtk/res", + GTK_RESPATH); + } + pathv = filepath_path_to_strvec(resource_path); langv = g_get_language_names(); @@ -121,6 +150,8 @@ nsgtk_init_resource_path(const char *resource_path) filepath_free_strvec(pathv); + free(resource_path); + return respath; } @@ -1057,7 +1088,11 @@ int main(int argc, char** argv) nslog_init(nslog_stream_configure, &argc, argv); /* build the common resource path list */ - respaths = nsgtk_init_resource_path("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res"); + respaths = nsgtk_init_resource_path(nsgtk_config_home); + if (respaths == NULL) { + fprintf(stderr, "Unable to locate resources\n"); + return 1; + } /* initialise the gtk resource handling */ ret = nsgtk_init_resources(respaths); |