summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/fetch.c6
-rw-r--r--gtk/gui.c41
-rw-r--r--gtk/gui.h3
-rw-r--r--gtk/preferences.c10
-rw-r--r--gtk/resources.c26
-rw-r--r--gtk/resources.h12
-rw-r--r--gtk/scaffolding.c1
7 files changed, 61 insertions, 38 deletions
diff --git a/gtk/fetch.c b/gtk/fetch.c
index 10b26bd48..13ffceb86 100644
--- a/gtk/fetch.c
+++ b/gtk/fetch.c
@@ -238,11 +238,11 @@ static nsurl *nsgtk_get_resource_url(const char *path)
/* favicon.ico -> favicon.png */
if (strcmp(path, "favicon.ico") == 0) {
- path = "favicon.png";
+ nsurl_create("resource:favicon.png", &url);
+ } else {
+ netsurf_path_to_nsurl(filepath_sfind(respaths, buf, path), &url);
}
- netsurf_path_to_nsurl(filepath_sfind(respaths, buf, path), &url);
-
return url;
}
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;
diff --git a/gtk/gui.h b/gtk/gui.h
index ce234c4a0..a804261de 100644
--- a/gtk/gui.h
+++ b/gtk/gui.h
@@ -21,9 +21,6 @@
struct nsurl;
-/** language list file path. */
-extern char *languages_file_location;
-
/** toolbar arrangement file path. */
extern char *toolbar_indices_file_location;
diff --git a/gtk/preferences.c b/gtk/preferences.c
index ba58bc905..5b6e332f1 100644
--- a/gtk/preferences.c
+++ b/gtk/preferences.c
@@ -548,19 +548,25 @@ nsgtk_preferences_comboboxLanguage_changed(GtkComboBox *combo,
}
}
+/**
+ * Fill content language list store.
+ */
G_MODULE_EXPORT void
nsgtk_preferences_comboboxLanguage_realize(GtkWidget *widget,
struct ppref *priv)
{
- /* Fill content language list store */
int active_language = 0;
GtkTreeIter iter;
FILE *fp;
char buf[50];
const char *default_accept_language = "en";
+ const char *languages_file_location;
+ nserror ret;
+
+ ret = nsgtk_path_from_resname("languages", &languages_file_location);
if ((priv->content_language != NULL) &&
- (languages_file_location != NULL) &&
+ (ret == NSERROR_OK) &&
((fp = fopen(languages_file_location, "r")) != NULL)) {
int combo_row_count = 0;
diff --git a/gtk/resources.c b/gtk/resources.c
index f5b13f1df..0c8c192f3 100644
--- a/gtk/resources.c
+++ b/gtk/resources.c
@@ -45,12 +45,12 @@
#ifdef WITH_BUILTIN_PIXBUF
#ifdef __GNUC__
extern const guint8 menu_cursor_pixdata[] __attribute__ ((__aligned__ (4)));
-const guint8 favicon_pixdata[] __attribute__ ((__aligned__ (4)));
-const guint8 netsurf_pixdata[] __attribute__ ((__aligned__ (4)));
+extern const guint8 favicon_pixdata[] __attribute__ ((__aligned__ (4)));
+extern const guint8 netsurf_pixdata[] __attribute__ ((__aligned__ (4)));
#else
extern const guint8 menu_cursor_pixdata[];
-const guint8 favicon_pixdata[];
-const guint8 netsurf_pixdata[];
+extern const guint8 favicon_pixdata[];
+extern const guint8 netsurf_pixdata[];
#endif
#endif
@@ -126,6 +126,7 @@ static struct nsgtk_resource_s direct_resource[] = {
RES_ENTRY("icons/hotlist-add.png"),
RES_ENTRY("icons/hotlist-rmv.png"),
RES_ENTRY("icons/search.png"),
+ RES_ENTRY("languages"),
RES_ENTRY("Messages"),
{ NULL, 0, NSGTK_RESOURCE_FILE, NULL },
};
@@ -560,3 +561,20 @@ nsgtk_data_from_resname(const char *resname,
return NSERROR_OK;
}
+
+/* exported interface documented in gtk/resources.h */
+nserror
+nsgtk_path_from_resname(const char *resname, const char **path_out)
+{
+ struct nsgtk_resource_s *resource;
+
+ resource = find_resource_from_name(resname, &direct_resource[0]);
+ if ((resource->name == NULL) ||
+ (resource->type != NSGTK_RESOURCE_FILE)) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ *path_out = (const char *)resource->path;
+
+ return NSERROR_OK;
+}
diff --git a/gtk/resources.h b/gtk/resources.h
index dd52f54f1..923031af4 100644
--- a/gtk/resources.h
+++ b/gtk/resources.h
@@ -94,4 +94,16 @@ nserror nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_ou
*/
nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out);
+/**
+ * Get path to resource data.
+ *
+ * For a named resource this obtains the on-disc path to that resource.
+ *
+ * The path is read only and remains valid untill program exit.
+ * \param resname The resource name to obtain path for.
+ * \param path_out The resulting data.
+ * \return NSERROR_OK and path_out updated or appropriate error code.
+ */
+nserror nsgtk_path_from_resname(const char *resname, const char **path_out);
+
#endif
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index c19624257..a45224c81 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -25,7 +25,6 @@
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include "utils/filepath.h"
#include "utils/messages.h"
#include "utils/corestrings.h"
#include "utils/log.h"