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.
This commit is contained in:
Vincent Sanders 2015-06-19 16:15:24 +01:00
parent 010306e1ad
commit 9ccf0cee9f

View File

@ -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);