summaryrefslogtreecommitdiff
path: root/gtk/resources.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/resources.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/resources.c')
-rw-r--r--gtk/resources.c26
1 files changed, 22 insertions, 4 deletions
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;
+}