summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk/fetch.c18
-rw-r--r--gtk/gui.c43
-rw-r--r--gtk/res/netsurf.gresource.xml22
-rw-r--r--gtk/resources.c318
-rw-r--r--gtk/resources.h48
-rw-r--r--gtk/throbber.c1
6 files changed, 346 insertions, 104 deletions
diff --git a/gtk/fetch.c b/gtk/fetch.c
index f68f203d5..0e5a37c5a 100644
--- a/gtk/fetch.c
+++ b/gtk/fetch.c
@@ -34,6 +34,7 @@
#include "desktop/gui_fetch.h"
#include "gtk/gui.h"
+#include "gtk/resources.h"
#include "gtk/fetch.h"
static struct hash_table *mime_hash = NULL;
@@ -172,13 +173,13 @@ const char *fetch_filetype(const char *unix_path)
const char *type;
int l;
- if (stat(unix_path, &statbuf) != 0) {
- /* stat failed */
- return "text/plain";
- }
+ /* stat the path to attempt to determine if the file is special */
+ if (stat(unix_path, &statbuf) == 0) {
+ /* stat suceeded so can check for directory */
- if (S_ISDIR(statbuf.st_mode)) {
- return "application/x-netsurf-directory";
+ if (S_ISDIR(statbuf.st_mode)) {
+ return "application/x-netsurf-directory";
+ }
}
l = strlen(unix_path);
@@ -230,7 +231,7 @@ const char *fetch_filetype(const char *unix_path)
}
-static nsurl *gui_get_resource_url(const char *path)
+static nsurl *nsgtk_get_resource_url(const char *path)
{
char buf[PATH_MAX];
nsurl *url = NULL;
@@ -253,7 +254,8 @@ static nsurl *gui_get_resource_url(const char *path)
static struct gui_fetch_table fetch_table = {
.filetype = fetch_filetype,
- .get_resource_url = gui_get_resource_url,
+ .get_resource_url = nsgtk_get_resource_url,
+ .get_resource_data = nsgtk_data_from_resname,
};
struct gui_fetch_table *nsgtk_fetch_table = &fetch_table;
diff --git a/gtk/gui.c b/gtk/gui.c
index 1df7bfc56..4986f425f 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -99,14 +99,15 @@ static void die(const char * const error)
exit(EXIT_FAILURE);
}
-/** Create an array of valid paths to search for resources.
+/**
+ * Create an array of valid paths to search for resources.
*
* The idea is that all the complex path computation to find resources
* is performed here, once, rather than every time a resource is
* searched for.
*/
static char **
-nsgtk_init_resource(const char *resource_path)
+nsgtk_init_resource_path(const char *resource_path)
{
const gchar * const *langv;
char **pathv; /* resource path string vector */
@@ -234,13 +235,6 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
strlen(languages_file_location) - 9);
LOG("Using '%s' for resource path", res_dir_location);
- /* initialise the gtk resource handling */
- error = nsgtk_init_resources(respath);
- if (error != NSERROR_OK) {
- LOG("Unable to initialise resources");
- return error;
- }
-
error = nsgtk_builder_new_from_resname("warning", &warning_builder);
if (error != NSERROR_OK) {
LOG("Unable to initialise warning dialog");
@@ -268,12 +262,15 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
/* Default favicon */
error = nsgdk_pixbuf_new_from_resname("favicon.png", &favicon_pixbuf);
if (error != NSERROR_OK) {
- favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 16,16);
+ favicon_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+ false, 8, 16,16);
}
/* Toolbar inicies file */
- toolbar_indices_file_location = filepath_find(respath, "toolbarIndices");
- LOG("Using '%s' as custom toolbar settings file", toolbar_indices_file_location);
+ toolbar_indices_file_location = filepath_find(respath,
+ "toolbarIndices");
+ LOG("Using '%s' as custom toolbar settings file",
+ toolbar_indices_file_location);
/* initialise throbber */
error = nsgtk_throbber_init();
@@ -1011,7 +1008,7 @@ static struct gui_browser_table nsgtk_browser_table = {
.quit = gui_quit,
.launch_url = gui_launch_url,
.cert_verify = gtk_cert_verify,
- .login = gui_401login_open,
+ .login = gui_401login_open,
.pdf_password = nsgtk_pdf_password,
};
@@ -1035,13 +1032,10 @@ int main(int argc, char** argv)
.bitmap = nsgtk_bitmap_table,
};
- ret = netsurf_register(&nsgtk_table);
- if (ret != NSERROR_OK) {
+ ret = netsurf_register(&nsgtk_table);
+ if (ret != NSERROR_OK) {
die("NetSurf operation table failed registration\n");
- }
-
- /* build the common resource path list */
- respaths = nsgtk_init_resource("${HOME}/.netsurf/:${NETSURFRES}:"GTK_RESPATH":./gtk/res");
+ }
/* Locate the correct user configuration directory path */
ret = get_config_home(&nsgtk_config_home);
@@ -1062,6 +1056,17 @@ 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");
+
+ /* initialise the gtk resource handling */
+ ret = nsgtk_init_resources(respaths);
+ if (ret != NSERROR_OK) {
+ fprintf(stderr, "GTK resources failed to initialise (%s)\n",
+ messages_get_errorcode(ret));
+ return 1;
+ }
+
/* Initialise user options */
ret = nsgtk_option_init(&argc, argv);
if (ret != NSERROR_OK) {
diff --git a/gtk/res/netsurf.gresource.xml b/gtk/res/netsurf.gresource.xml
index 55f3a3dc8..ca4c9e326 100644
--- a/gtk/res/netsurf.gresource.xml
+++ b/gtk/res/netsurf.gresource.xml
@@ -39,5 +39,27 @@
<file preprocess="to-pixdata">throbber/throbber6.png</file>
<file preprocess="to-pixdata">throbber/throbber7.png</file>
<file preprocess="to-pixdata">throbber/throbber8.png</file>
+ <file>credits.html</file>
+ <file>it/credits.html</file>
+ <file>nl/credits.html</file>
+ <file>licence.html</file>
+ <file>it/licence.html</file>
+ <file>nl/licence.html</file>
+ <file>welcome.html</file>
+ <file>de/welcome.html</file>
+ <file>it/welcome.html</file>
+ <file>ja/welcome.html</file>
+ <file>nl/welcome.html</file>
+ <file>maps.html</file>
+ <file>internal.css</file>
+ <file>netsurf.png</file>
+ <file>default.ico</file>
+ <file>icons/arrow-l.png</file>
+ <file>icons/content.png</file>
+ <file>icons/directory2.png</file>
+ <file>icons/directory.png</file>
+ <file>icons/hotlist-add.png</file>
+ <file>icons/hotlist-rmv.png</file>
+ <file>icons/search.png</file>
</gresource>
</gresources>
diff --git a/gtk/resources.c b/gtk/resources.c
index d1c3c86fc..1998034ff 100644
--- a/gtk/resources.c
+++ b/gtk/resources.c
@@ -36,6 +36,12 @@
#include "gtk/compat.h"
#include "gtk/resources.h"
+/** log contents of gresource /org/netsource */
+#ifdef WITH_GRESOURCE
+#define SHOW_GRESOURCE
+#undef SHOW_GRESOURCE
+#endif
+
#ifdef WITH_BUILTIN_PIXBUF
#ifdef __GNUC__
extern const guint8 menu_cursor_pixdata[] __attribute__ ((__aligned__ (4)));
@@ -44,12 +50,15 @@ extern const guint8 menu_cursor_pixdata[];
#endif
#endif
+/** type of resource entry */
enum nsgtk_resource_type_e {
- NSGTK_RESOURCE_FILE,
- NSGTK_RESOURCE_GLIB,
- NSGTK_RESOURCE_INLINE,
+ NSGTK_RESOURCE_FILE, /**< entry is a file on disc */
+ NSGTK_RESOURCE_GLIB, /**< entry is a gresource accessed by path */
+ NSGTK_RESOURCE_DIRECT, /**< entry is a gresource accesed by gbytes */
+ NSGTK_RESOURCE_INLINE, /**< entry is compiled in accessed by pointer */
};
+/** resource entry */
struct nsgtk_resource_s {
const char *name;
unsigned int len;
@@ -57,39 +66,63 @@ struct nsgtk_resource_s {
char *path;
};
+#define RES_ENTRY(name) { name, sizeof((name)) - 1, NSGTK_RESOURCE_FILE, NULL }
+
+/** resources that are used for gtk builder */
static struct nsgtk_resource_s ui_resource[] = {
- { "netsurf", 7, NSGTK_RESOURCE_FILE, NULL },
- { "tabcontents", 10, NSGTK_RESOURCE_FILE, NULL },
- { "password", 8, NSGTK_RESOURCE_FILE, NULL },
- { "login", 5, NSGTK_RESOURCE_FILE, NULL },
- { "ssl", 3, NSGTK_RESOURCE_FILE, NULL },
- { "toolbar", 7, NSGTK_RESOURCE_FILE, NULL },
- { "downloads", 9, NSGTK_RESOURCE_FILE, NULL },
- { "history", 7, NSGTK_RESOURCE_FILE, NULL },
- { "options", 7, NSGTK_RESOURCE_FILE, NULL },
- { "hotlist", 7, NSGTK_RESOURCE_FILE, NULL },
- { "cookies", 7, NSGTK_RESOURCE_FILE, NULL },
- { "viewdata", 8, NSGTK_RESOURCE_FILE, NULL },
- { "warning", 7, NSGTK_RESOURCE_FILE, NULL },
+ RES_ENTRY("netsurf"),
+ RES_ENTRY("tabcontents"),
+ RES_ENTRY("password"),
+ RES_ENTRY("login"),
+ RES_ENTRY("ssl"),
+ RES_ENTRY("toolbar"),
+ RES_ENTRY("downloads"),
+ RES_ENTRY("history"),
+ RES_ENTRY("options"),
+ RES_ENTRY("hotlist"),
+ RES_ENTRY("cookies"),
+ RES_ENTRY("viewdata"),
+ RES_ENTRY("warning"),
{ NULL, 0, NSGTK_RESOURCE_FILE, NULL },
};
-static struct nsgtk_resource_s gen_resource[] = {
- { "favicon.png", 11, NSGTK_RESOURCE_FILE, NULL },
- { "netsurf.xpm", 11, NSGTK_RESOURCE_FILE, NULL },
- { "menu_cursor.png", 15, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber0.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber1.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber2.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber3.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber4.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber5.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber6.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber7.png", 22, NSGTK_RESOURCE_FILE, NULL },
- { "throbber/throbber8.png", 22, NSGTK_RESOURCE_FILE, NULL },
+/** resources that are used as pixbufs */
+static struct nsgtk_resource_s pixbuf_resource[] = {
+ RES_ENTRY("favicon.png"),
+ RES_ENTRY("netsurf.xpm"),
+ RES_ENTRY("menu_cursor.png"),
+ RES_ENTRY("throbber/throbber0.png"),
+ RES_ENTRY("throbber/throbber1.png"),
+ RES_ENTRY("throbber/throbber2.png"),
+ RES_ENTRY("throbber/throbber3.png"),
+ RES_ENTRY("throbber/throbber4.png"),
+ RES_ENTRY("throbber/throbber5.png"),
+ RES_ENTRY("throbber/throbber6.png"),
+ RES_ENTRY("throbber/throbber7.png"),
+ RES_ENTRY("throbber/throbber8.png"),
{ NULL, 0, NSGTK_RESOURCE_FILE, NULL },
};
+/** resources that are used for direct data access */
+static struct nsgtk_resource_s direct_resource[] = {
+ RES_ENTRY("welcome.html"),
+ RES_ENTRY("credits.html"),
+ RES_ENTRY("licence.html"),
+ RES_ENTRY("maps.html"),
+ RES_ENTRY("internal.css"),
+ RES_ENTRY("netsurf.png"),
+ RES_ENTRY("default.ico"),
+ RES_ENTRY("icons/arrow-l.png"),
+ RES_ENTRY("icons/content.png"),
+ RES_ENTRY("icons/directory2.png"),
+ RES_ENTRY("icons/directory.png"),
+ RES_ENTRY("icons/hotlist-add.png"),
+ RES_ENTRY("icons/hotlist-rmv.png"),
+ RES_ENTRY("icons/search.png"),
+ { NULL, 0, NSGTK_RESOURCE_FILE, NULL },
+};
+
+
/* exported interface documented in gtk/resources.h */
GdkCursor *nsgtk_create_menu_cursor(void)
{
@@ -98,7 +131,6 @@ GdkCursor *nsgtk_create_menu_cursor(void)
nserror res;
const char *resname = "menu_cursor.png";
-
res = nsgdk_pixbuf_new_from_resname(resname, &pixbuf);
if (res == NSERROR_OK) {
cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
@@ -110,7 +142,7 @@ GdkCursor *nsgtk_create_menu_cursor(void)
}
-/*
+/**
* locate a resource
*
* The way GTK accesses resource files has changed greatly between
@@ -122,24 +154,48 @@ GdkCursor *nsgtk_create_menu_cursor(void)
* instead.
*
* \param respath A string vector containing the valid resource search paths
- * \param ui_res A resource entry to initialise
+ * \param resource A resource entry to initialise
*/
static nserror
init_resource(char **respath, struct nsgtk_resource_s *resource)
{
char *resname;
-#ifdef WITH_BUILTIN_PIXBUF
- if (strncmp(resource->name, "menu_cursor.png", resource->len) == 0) {
- resource->path = (char *)&menu_cursor_pixdata[0];
- resource->type = NSGTK_RESOURCE_INLINE;
- LOG("Found builtin for %s", resource->name);
- return NSERROR_OK;
- }
-#endif
#ifdef WITH_GRESOURCE
int resnamelen;
gboolean present;
+ const gchar * const *langv;
+ int langc = 0;
+
+ langv = g_get_language_names();
+
+ while (langv[langc] != NULL) {
+ resnamelen = snprintf(NULL, 0,
+ "/org/netsurf/%s/%s",
+ langv[langc], resource->name);
+
+ resname = malloc(resnamelen + 1);
+ if (resname == NULL) {
+ return NSERROR_NOMEM;
+ }
+ snprintf(resname, resnamelen + 1,
+ "/org/netsurf/%s/%s",
+ langv[langc], resource->name);
+
+ present = g_resources_get_info(resname,
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ NULL, NULL, NULL);
+ if (present == TRUE) {
+ /* found an entry in the resources */
+ resource->path = resname;
+ resource->type = NSGTK_RESOURCE_GLIB;
+ LOG("Found gresource path %s", resource->path);
+ return NSERROR_OK;
+ }
+ /*LOG("gresource \"%s\" not found", resname);*/
+ free(resname);
+ langc++;
+ }
resnamelen = snprintf(NULL, 0, "/org/netsurf/%s", resource->name);
resname = malloc(resnamelen + 1);
@@ -158,8 +214,9 @@ init_resource(char **respath, struct nsgtk_resource_s *resource)
LOG("Found gresource path %s", resource->path);
return NSERROR_OK;
}
- LOG("gresource \"%s\" not found", resname);
+ /*LOG("gresource \"%s\" not found", resname);*/
free(resname);
+
#endif
resname = filepath_find(respath, resource->name);
@@ -177,7 +234,61 @@ init_resource(char **respath, struct nsgtk_resource_s *resource)
return NSERROR_OK;
}
-/*
+/**
+ * locate and setup a direct resource
+ *
+ * Direct resources have general type of NSGTK_RESOURCE_GLIB but have
+ * g_resources_lookup_data() applied and the result stored so the data
+ * can be directly accessed without additional processing.
+ *
+ * \param respath A string vector containing the valid resource search paths
+ * \param resource A resource entry to initialise
+ */
+static nserror
+init_direct_resource(char **respath, struct nsgtk_resource_s *resource)
+{
+ nserror res;
+ GBytes *data;
+
+ res = init_resource(respath, resource);
+ if ((res == NSERROR_OK) &&
+ (resource->type == NSGTK_RESOURCE_GLIB)) {
+ /* found gresource we can convert */
+ data = g_resources_lookup_data(resource->path,
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ NULL);
+ if (data != NULL) {
+ resource->type = NSGTK_RESOURCE_DIRECT;
+ resource->path = (char *)data;
+ }
+ }
+
+ return res;
+}
+
+/**
+ * locate a pixbuf resource
+ *
+ * Pixbuf resources can be compiled inline
+ *
+ * \param respath A string vector containing the valid resource search paths
+ * \param resource A resource entry to initialise
+ */
+static nserror
+init_pixbuf_resource(char **respath, struct nsgtk_resource_s *resource)
+{
+#ifdef WITH_BUILTIN_PIXBUF
+ if (strncmp(resource->name, "menu_cursor.png", resource->len) == 0) {
+ resource->path = (char *)&menu_cursor_pixdata[0];
+ resource->type = NSGTK_RESOURCE_INLINE;
+ LOG("Found builtin for %s", resource->name);
+ return NSERROR_OK;
+ }
+#endif
+ return init_resource(respath, resource);
+}
+
+/**
* locate a ui resource
*
* UI resources need their resource name changing to account for gtk versions
@@ -218,38 +329,67 @@ static nserror init_ui_resource(char **respath, struct nsgtk_resource_s *ui_res)
return res;
}
-#define SHOW_GRESOURCE
-
/**
- * Initialise UI resource table
+ * Find a resource entry by name.
*
+ * \param resname The resource name to match.
+ * \param resource The list of resources entries to search.
*/
-nserror nsgtk_init_resources(char **respath)
+static struct nsgtk_resource_s *
+find_resource_from_name(const char *resname, struct nsgtk_resource_s *resource)
{
- struct nsgtk_resource_s *resource;
- nserror res;
+ /* find resource from name */
+ while ((resource->name != NULL) &&
+ ((resname[0] != resource->name[0]) ||
+ (strncmp(resource->name, resname, resource->len) != 0))) {
+ resource++;
+ }
+ return resource;
+}
#ifdef SHOW_GRESOURCE
+/**
+ * Debug dump of all resources compile din via GResource.
+ */
+static void list_gresource(void)
+{
const char *nspath = "/org/netsurf";
char **reslist;
char **cur;
GError* gerror = NULL;
- reslist = g_resources_enumerate_children(nspath,G_RESOURCE_LOOKUP_FLAGS_NONE, &gerror);
+ reslist = g_resources_enumerate_children(nspath,
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ &gerror);
if (gerror) {
LOG("gerror %s", gerror->message);
g_error_free(gerror);
} else {
- cur = reslist;
- while (cur != NULL && *cur != NULL) {
- LOG("gres %s", *cur);
- cur++;
- }
- g_strfreev(reslist);
+ cur = reslist;
+ while (cur != NULL && *cur != NULL) {
+ LOG("gres %s", *cur);
+ cur++;
+ }
+ g_strfreev(reslist);
}
+}
#endif
- /* walk the ui resource table and initialise all its members */
+/**
+ * Initialise UI resource table
+ *
+ */
+/* exported interface documented in gtk/resources.h */
+nserror nsgtk_init_resources(char **respath)
+{
+ struct nsgtk_resource_s *resource;
+ nserror res;
+
+#ifdef SHOW_GRESOURCE
+ list_gresource();
+#endif
+
+ /* iterate the ui resource table and initialise all its members */
resource = &ui_resource[0];
while (resource->name != NULL) {
res = init_ui_resource(respath, resource);
@@ -259,31 +399,29 @@ nserror nsgtk_init_resources(char **respath)
resource++;
}
- /* walk the general resource table and initialise all its members */
- resource = &gen_resource[0];
+ /* iterate the pixbuf resource table and initialise all its members */
+ resource = &pixbuf_resource[0];
while (resource->name != NULL) {
- res = init_resource(respath, resource);
+ res = init_pixbuf_resource(respath, resource);
if (res != NSERROR_OK) {
return res;
}
resource++;
}
+ /* iterate the direct resource table and initialise all its members */
+ resource = &direct_resource[0];
+ while (resource->name != NULL) {
+ res = init_direct_resource(respath, resource);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+ resource++;
+ }
return NSERROR_OK;
}
-static struct nsgtk_resource_s *
-find_resource_from_name(const char *resname, struct nsgtk_resource_s *resource)
-{
- /* find resource from name */
- while ((resource->name != NULL) &&
- ((resname[0] != resource->name[0]) ||
- (strncmp(resource->name, resname, resource->len) != 0))) {
- resource++;
- }
- return resource;
-}
/* exported interface documented in gtk/resources.h */
nserror
@@ -293,7 +431,7 @@ nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out)
GdkPixbuf *new_pixbuf = NULL;
GError* error = NULL;
- resource = find_resource_from_name(resname, &gen_resource[0]);
+ resource = find_resource_from_name(resname, &pixbuf_resource[0]);
if (resource->name == NULL) {
return NSERROR_NOT_FOUND;
}
@@ -309,9 +447,13 @@ nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out)
case NSGTK_RESOURCE_INLINE:
#ifdef WITH_BUILTIN_PIXBUF
- new_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)resource->path, FALSE, NULL);
+ new_pixbuf = gdk_pixbuf_new_from_inline(-1, (const guint8 *)resource->path, FALSE, &error);
#endif
break;
+
+ case NSGTK_RESOURCE_DIRECT:
+ /* pixbuf resources are not currently direct */
+ break;
}
if (new_pixbuf == NULL) {
LOG("Unable to create pixbuf from file for %s with path %s \"%s\"",
@@ -365,3 +507,35 @@ nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out)
return NSERROR_OK;
}
+
+/* exported interface documented in gtk/resources.h */
+nserror
+nsgtk_data_from_resname(const char *resname,
+ const uint8_t ** data_out,
+ size_t *data_size_out)
+{
+ struct nsgtk_resource_s *resource;
+ GBytes *data;
+ const gchar *buffer;
+ gsize buffer_length;
+
+ resource = find_resource_from_name(resname, &direct_resource[0]);
+ if ((resource->name == NULL) ||
+ (resource->type != NSGTK_RESOURCE_DIRECT)) {
+ return NSERROR_NOT_FOUND;
+ }
+
+ data = (GBytes *)resource->path;
+
+ buffer_length = 0;
+ buffer = g_bytes_get_data(data, &buffer_length);
+
+ if (buffer == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ *data_out = (const uint8_t *)buffer;
+ *data_size_out = (size_t)buffer_length;
+
+ return NSERROR_OK;
+}
diff --git a/gtk/resources.h b/gtk/resources.h
index 7c3e73d9e..dd52f54f1 100644
--- a/gtk/resources.h
+++ b/gtk/resources.h
@@ -16,18 +16,40 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Interface to gtk builtin resource handling.
+ *
+ * This presents a unified interface to the rest of the codebase to
+ * obtain resources. Note this is not anything to do with the resource
+ * scheme handling beyond possibly providing the underlying data.
+ *
+ */
+
#ifndef NETSURF_GTK_RESOURCES_H
#define NETSURF_GTK_RESOURCES_H 1
/**
- * Creates a menu cursor from internal resources
+ * Initialise GTK resources handling.
+ *
+ * Must be called before attempting to retrieve any resources but
+ * after logging is initialised as it logs.
+ *
+ * \param respath A string vector of paths to search for resources.
+ * \return NSERROR_OK if all resources were located else an
+ * appropriate error code.
*/
-GdkCursor *nsgtk_create_menu_cursor(void);
-
nserror nsgtk_init_resources(char **respath);
/**
- * Create gtk builder object for the named ui resource
+ * Creates a menu cursor from internal resources.
+ *
+ * \return Cursor object or NULL on error.
+ */
+GdkCursor *nsgtk_create_menu_cursor(void);
+
+/**
+ * Create gtk builder object for the named ui resource.
*
* Creating gtk builder objects from a named resource requires the
* source xml resource to be parsed.
@@ -44,7 +66,7 @@ nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder
/**
- * Create gdk pixbuf for the named ui resource
+ * Create gdk pixbuf for the named ui resource.
*
* This creates a pixbuf using an identifier name which is mapped to
* the ui_resource table which must be initialised with
@@ -56,4 +78,20 @@ nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder
*/
nserror nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out);
+/**
+ * Get direct pointer to resource data.
+ *
+ * For a named resource this obtains a direct acesss pointer to the
+ * data and its length.
+ *
+ * The data is read only through this pointer and remains valid until
+ * program exit.
+ *
+ * \param resname The resource name to obtain data for.
+ * \param data_out The resulting data.
+ * \param data_size_out The resulting data size.
+ * \return NSERROR_OK and data_out updated or appropriate error code.
+ */
+nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out);
+
#endif
diff --git a/gtk/throbber.c b/gtk/throbber.c
index 725df4626..9392c3909 100644
--- a/gtk/throbber.c
+++ b/gtk/throbber.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <gtk/gtk.h>
+#include <stdint.h>
#include "utils/log.h"