45#ifdef WITH_BUILTIN_PIXBUF
47extern const guint8 menu_cursor_pixdata[]
__attribute__ ((__aligned__ (4)));
48extern const guint8 favicon_pixdata[]
__attribute__ ((__aligned__ (4)));
49extern const guint8 netsurf_pixdata[]
__attribute__ ((__aligned__ (4)));
51extern const guint8 menu_cursor_pixdata[];
52extern const guint8 favicon_pixdata[];
53extern const guint8 netsurf_pixdata[];
73#define RES_ENTRY(name) { name, sizeof((name)) - 1, NSGTK_RESOURCE_FILE, NULL }
100 RES_ENTRY(
"icons/24x24/actions/page-info-insecure.png"),
101 RES_ENTRY(
"icons/24x24/actions/page-info-internal.png"),
102 RES_ENTRY(
"icons/24x24/actions/page-info-local.png"),
103 RES_ENTRY(
"icons/24x24/actions/page-info-secure.png"),
104 RES_ENTRY(
"icons/24x24/actions/page-info-warning.png"),
105 RES_ENTRY(
"icons/48x48/actions/page-info-insecure.png"),
106 RES_ENTRY(
"icons/48x48/actions/page-info-internal.png"),
107 RES_ENTRY(
"icons/48x48/actions/page-info-local.png"),
108 RES_ENTRY(
"icons/48x48/actions/page-info-secure.png"),
109 RES_ENTRY(
"icons/48x48/actions/page-info-warning.png"),
150 GdkCursor *cursor = NULL;
156 cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
158 g_object_unref(pixbuf);
186 const gchar *
const *langv;
189 langv = g_get_language_names();
192 while (langv[langc] != NULL) {
194 resnamelen = snprintf(NULL, 0,
195 "/org/netsurf/%s/%s",
196 langv[langc], resource->
name);
197 resname = malloc(resnamelen + 1);
198 if (resname == NULL) {
201 snprintf(resname, resnamelen + 1,
202 "/org/netsurf/%s/%s",
203 langv[langc], resource->
name);
206 present = g_resources_get_info(resname,
207 G_RESOURCE_LOOKUP_FLAGS_NONE,
209 if (present == TRUE) {
211 resource->
path = resname;
213 NSLOG(netsurf, INFO,
"Found gresource path %s",
217 NSLOG(netsurf, DEEPDEBUG,
218 "gresource \"%s\" not found", resname);
225 resnamelen = snprintf(NULL, 0,
"/org/netsurf/%s", resource->
name);
226 resname = malloc(resnamelen + 1);
227 if (resname == NULL) {
230 snprintf(resname, resnamelen + 1,
"/org/netsurf/%s", resource->
name);
232 present = g_resources_get_info(resname,
233 G_RESOURCE_LOOKUP_FLAGS_NONE,
235 if (present == TRUE) {
237 resource->
path = resname;
239 NSLOG(netsurf, INFO,
"Found gresource path %s",
243 NSLOG(netsurf, DEEPDEBUG,
"gresource \"%s\" not found", resname);
250 if (resname != NULL) {
252 resource->
path = resname;
256 "Found file resource path %s", resource->
path);
260 NSLOG(netsurf, INFO,
"Unable to find resource %s on resource path",
289 data = g_resources_lookup_data(resource->
path,
290 G_RESOURCE_LOOKUP_FLAGS_NONE,
294 resource->
path = (
char *)data;
313#ifdef WITH_BUILTIN_PIXBUF
314 if (strncmp(resource->
name,
"menu_cursor.png", resource->
len) == 0) {
315 resource->
path = (
char *)&menu_cursor_pixdata[0];
317 NSLOG(netsurf, INFO,
"Found builtin for %s", resource->
name);
321 if (strncmp(resource->
name,
"netsurf.xpm", resource->
len) == 0) {
322 resource->
path = (
char *)&netsurf_pixdata[0];
324 NSLOG(netsurf, INFO,
"Found builtin for %s", resource->
name);
328 if (strncmp(resource->
name,
"favicon.png", resource->
len) == 0) {
329 resource->
path = (
char *)&favicon_pixdata[0];
331 NSLOG(netsurf, INFO,
"Found builtin for %s", resource->
name);
353 resnamelen = ui_res->
len + 10;
355 resname = malloc(resnamelen);
356 if (resname == NULL) {
359 snprintf(resname, resnamelen,
"%s.ui", ui_res->
name);
360 resource.
name = resname;
361 resource.
len = ui_res->
len;
362 resource.
path = NULL;
384 while ((resource->
name != NULL) &&
385 ((resname[0] != resource->
name[0]) ||
386 (strncmp(resource->
name, resname, resource->
len) != 0))) {
396static void list_gresource(
void)
398 const char *nspath =
"/org/netsurf";
401 GError* gerror = NULL;
402 reslist = g_resources_enumerate_children(nspath,
403 G_RESOURCE_LOOKUP_FLAGS_NONE,
406 NSLOG(netsurf, INFO,
"gerror %s", gerror->message);
407 g_error_free(gerror);
411 while (cur != NULL && *cur != NULL) {
412 NSLOG(netsurf, INFO,
"gres %s", *cur);
436 while (resource->
name != NULL) {
446 while (resource->
name != NULL) {
456 while (resource->
name != NULL) {
473 GdkPixbuf *new_pixbuf = NULL;
474 GError* error = NULL;
477 if (resource->
name == NULL) {
481 switch (resource->
type) {
483 new_pixbuf = gdk_pixbuf_new_from_file(resource->
path, &error);
488 new_pixbuf = gdk_pixbuf_new_from_resource(resource->
path, &error);
493#ifdef WITH_BUILTIN_PIXBUF
494 new_pixbuf = gdk_pixbuf_new_from_inline(-1, (
const guint8 *)resource->
path, FALSE, &error);
503 if (new_pixbuf == NULL) {
506 "Unable to create pixbuf from file for %s with path %s \"%s\"",
513 "Unable to create pixbuf from file for %s with path %s",
519 *pixbuf_out = new_pixbuf;
528 GtkBuilder *new_builder;
530 GError* error = NULL;
533 if (ui_res->
name == NULL) {
537 new_builder = gtk_builder_new();
540 if (!gtk_builder_add_from_file(new_builder,
544 "Unable to add UI builder from file for %s with path %s \"%s\"",
549 g_object_unref(G_OBJECT(new_builder));
557 "Unable to add UI builder from resource for %s with path %s \"%s\"",
562 g_object_unref(G_OBJECT(new_builder));
567 *builder_out = new_builder;
575 const uint8_t ** data_out,
576 size_t *data_size_out)
585 if ((resource->
name == NULL) ||
590 data = (GBytes *)resource->
path;
593 buffer = g_bytes_get_data(data, &buffer_length);
599 *data_out = (
const uint8_t *)
buffer;
600 *data_size_out = (size_t)buffer_length;
618 if ((resource->
name == NULL) ||
623 *path_out = (
const char *)resource->
path;
static const __attribute__((used))
static osspriteop_area * buffer
The buffer characteristics.
guint nsgtk_builder_add_from_resource(GtkBuilder *builder, const gchar *resource_path, GError **error)
Parses a resource file containing a GtkBuilder UI definition and merges it with the current contents ...
Compatibility functions for older GTK versions (interface)
nserror
Enumeration of error codes.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_INIT_FAILED
Initialisation failed.
@ NSERROR_NOMEM
Memory exhaustion.
char * filepath_find(char **respathv, const char *filename)
Searches an array of resource paths for a file.
Utility routines to obtain paths to file resources.
#define NSLOG(catname, level, logmsg, args...)
GdkCursor * nsgtk_create_menu_cursor(void)
Creates a menu cursor from internal resources.
nserror nsgtk_data_from_resname(const char *resname, const uint8_t **data_out, size_t *data_size_out)
Get direct pointer to resource data.
nserror nsgtk_init_resources(char **respath)
Initialise UI resource table.
nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out)
Create gtk builder object for the named ui resource.
static nserror init_pixbuf_resource(char **respath, struct nsgtk_resource_s *resource)
locate a pixbuf resource
static struct nsgtk_resource_s pixbuf_resource[]
resources that are used as pixbufs
static struct nsgtk_resource_s ui_resource[]
resources that are used for gtk builder
static struct nsgtk_resource_s direct_resource[]
resources that are used for direct data access
nsgtk_resource_type_e
log contents of gresource /org/netsource
@ NSGTK_RESOURCE_INLINE
entry is compiled in accessed by pointer
@ NSGTK_RESOURCE_DIRECT
entry is a gresource accesed by gbytes
@ NSGTK_RESOURCE_FILE
entry is a file on disc
@ NSGTK_RESOURCE_GLIB
entry is a gresource accessed by path
static nserror init_ui_resource(char **respath, struct nsgtk_resource_s *ui_res)
locate a ui resource
nserror nsgdk_pixbuf_new_from_resname(const char *resname, GdkPixbuf **pixbuf_out)
Create gdk pixbuf for the named ui resource.
nserror nsgtk_path_from_resname(const char *resname, const char **path_out)
Get path to resource data.
static struct nsgtk_resource_s * find_resource_from_name(const char *resname, struct nsgtk_resource_s *resource)
Find a resource entry by name.
static nserror init_resource(char **respath, struct nsgtk_resource_s *resource)
locate a resource
static nserror init_direct_resource(char **respath, struct nsgtk_resource_s *resource)
locate and setup a direct resource
Interface to gtk builtin resource handling.
Interface to utility string handling.
enum nsgtk_resource_type_e type