summaryrefslogtreecommitdiff
path: root/gtk/gui.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-06-23 11:53:41 +0100
committerVincent Sanders <vince@kyllikki.org>2015-06-23 11:53:41 +0100
commitee74f9ac8cacc89a1f8a94f63feac662bb13cbad (patch)
treeeddc0008404293cc2f4e7b0f70c530a4f1bdd049 /gtk/gui.c
parent11dc7304d96a2ac3e2ac346e3cb6236f8e14225b (diff)
downloadnetsurf-ee74f9ac8cacc89a1f8a94f63feac662bb13cbad.tar.gz
netsurf-ee74f9ac8cacc89a1f8a94f63feac662bb13cbad.tar.bz2
Change gtk message and language handling to use resource names
The GTK resource handling can now provide the path to resources rather than having to compute them separately. This reduces run time allocation and allows for the resources to be built in if required. Additionally this tweaks the resource scheme handling to redirect favicon.ico to resource:favicon.png instead of rewriting directly to file scheme path allowing the favicon to be a compiled in resource.
Diffstat (limited to 'gtk/gui.c')
-rw-r--r--gtk/gui.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/gtk/gui.c b/gtk/gui.c
index 3a41b605e..28e5c3c90 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -74,7 +74,6 @@ bool nsgtk_complete = false;
char *toolbar_indices_file_location;
char *res_dir_location;
-char *languages_file_location;
char *themelist_file_location;
char *nsgtk_config_home; /* exported global defined in gtk/gui.h */
@@ -237,12 +236,6 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
nsurl *url;
nserror error;
- /* find the languages file */
- languages_file_location = filepath_find(respath, "languages");
- if ((languages_file_location == NULL) ||
- (strlen(languages_file_location) < 10)) {
- die("Unable to find resources.\n");
- }
/* find the theme list file */
themelist_file_location = filepath_find(respath, "themelist");
@@ -252,20 +245,21 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
themelist_file_location = NULL;
}
if (themelist_file_location == NULL) {
- LOG("Unable to find themelist - disabling");
+ LOG("Unable to find themelist - disabling themes");
+ res_dir_location = NULL;
+ } else {
+ /* Obtain resources path location.
+ *
+ * Uses the directory the theme file was found in,
+ * @todo find and slaughter all references to this!
+ */
+ res_dir_location = calloc(1, strlen(themelist_file_location) - 8);
+ memcpy(res_dir_location,
+ themelist_file_location,
+ strlen(themelist_file_location) - 9);
+ LOG("Using '%s' for resource path", res_dir_location);
}
- /* Obtain resources path location.
- *
- * Uses the directory the languages file was found in,
- * @todo find and slaughter all references to this!
- */
- res_dir_location = calloc(1, strlen(languages_file_location) - 8);
- memcpy(res_dir_location,
- languages_file_location,
- strlen(languages_file_location) - 9);
- LOG("Using '%s' for resource path", res_dir_location);
-
error = nsgtk_builder_new_from_resname("warning", &warning_builder);
if (error != NSERROR_OK) {
LOG("Unable to initialise warning dialog");
@@ -1046,7 +1040,7 @@ static struct gui_browser_table nsgtk_browser_table = {
static nserror nsgtk_messages_init(char **respaths)
{
- char *messages;
+ const char *messages;
nserror ret;
const uint8_t *data;
size_t data_size;
@@ -1056,12 +1050,9 @@ static nserror nsgtk_messages_init(char **respaths)
ret = messages_add_from_inline(data, data_size);
} else {
/* Obtain path to messages */
- messages = filepath_find(respaths, "Messages");
- if (messages != NULL) {
+ ret = nsgtk_path_from_resname("Messages", &messages);
+ if (ret == NSERROR_OK) {
ret = messages_add_from_file(messages);
- free(messages);
- } else {
- ret = NSERROR_NOT_FOUND;
}
}
return ret;