summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.target45
-rw-r--r--gtk/gui.c21
-rw-r--r--gtk/res/messages.gresource.xml10
-rw-r--r--gtk/resources.c22
4 files changed, 76 insertions, 22 deletions
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index cc8516264..fbc1ecb1a 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -70,6 +70,17 @@ CFLAGS += $(GTKCFLAGS)
LDFLAGS += -lm
# ---------------------------------------------------------------------------
+# Target setup
+# ---------------------------------------------------------------------------
+
+# The gtk binary target
+EXETARGET := nsgtk
+
+# The filter and target for split messages
+MESSAGES_FILTER=gtk
+MESSAGES_TARGET=gtk/res
+
+# ---------------------------------------------------------------------------
# Windows flag setup
# ---------------------------------------------------------------------------
@@ -84,6 +95,9 @@ endif
# builtin resource sources
S_RESOURCE :=
+# Path to GTK resources
+NSGTK_RESOURCES_DIR := gtk/res
+
# Glib prior to 2.32 does not have GResource handling.
#
# This uses pkg-config to check for the minimum required version for
@@ -106,16 +120,24 @@ NETSURF_FEATURE_GRESOURCE_ENABLED := yes
GLIB_COMPILE_RESOURCES := glib-compile-resources
CFLAGS += -DWITH_GRESOURCE
-S_RESOURCE += $(OBJROOT)/netsurf_gresource.c
+NETSURF_GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/netsurf.gresource.xml
+MESSAGES_GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/messages.gresource.xml
-NSGTK_RESOURCES_DIR := gtk/res
-GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/netsurf.gresource.xml
+# generate the netsurf gresource source files
+$(OBJROOT)/netsurf_gresource.c: $(NETSURF_GRESOURCE_XML) $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir $(NSGTK_RESOURCES_DIR) --generate-dependencies $(NETSURF_GRESOURCE_XML))
+ $(VQ)echo "GRESORCE: $<"
+ $(Q)$(GLIB_COMPILE_RESOURCES) --generate-source --sourcedir $(NSGTK_RESOURCES_DIR) --target=$@ $<
+
+S_RESOURCE += $(OBJROOT)/netsurf_gresource.c
-# generate the gresource source file
-$(OBJROOT)/netsurf_gresource.c: $(GRESOURCE_XML) $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir $(NSGTK_RESOURCES_DIR) --generate-dependencies $(GRESOURCE_XML))
+# generate the messages gresource source file
+$(OBJROOT)/messages_gresource.c: $(MESSAGES_GRESOURCE_XML) $(addsuffix /Messages,$(addprefix $(MESSAGES_TARGET)/,$(MESSAGES_LANGUAGES)))
$(VQ)echo "GRESORCE: $<"
$(Q)$(GLIB_COMPILE_RESOURCES) --generate-source --sourcedir $(NSGTK_RESOURCES_DIR) --target=$@ $<
+S_RESOURCE += $(OBJROOT)/messages_gresource.c
+
+
endif
endif
@@ -125,7 +147,9 @@ ifneq ($(NETSURF_FEATURE_GRESOURCE_ENABLED),yes)
CFLAGS += -DWITH_BUILTIN_PIXBUF
-GTK_IMAGE_menu_cursor := gtk/res/menu_cursor.png
+GTK_IMAGE_favicon := favicon.png
+GTK_IMAGE_netsurf := netsurf.xpm
+GTK_IMAGE_menu_cursor := menu_cursor.png
# 1: input file
# 2: output file
@@ -143,7 +167,7 @@ $(2): $(1)
endef
-$(eval $(foreach V,$(filter GTK_IMAGE_%,$(.VARIABLES)),$(call convert_image,$($(V)),$(OBJROOT)/$(patsubst GTK_IMAGE_%,%,$(V)).c,$(patsubst GTK_IMAGE_%,%,$(V))_pixdata)))
+$(eval $(foreach V,$(filter GTK_IMAGE_%,$(.VARIABLES)),$(call convert_image,$(addprefix $(NSGTK_RESOURCES_DIR)/,$($(V))),$(OBJROOT)/$(patsubst GTK_IMAGE_%,%,$(V)).c,$(patsubst GTK_IMAGE_%,%,$(V))_pixdata)))
endif
endif
@@ -167,13 +191,6 @@ S_GTK := $(addprefix gtk/,$(S_GTK)) $(addprefix utils/,container.c)
# are not yet available
SOURCES = $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_RESOURCE) $(S_GTK)
-# The gtk binary target
-EXETARGET := nsgtk
-
-# The filter and target for split messages
-MESSAGES_FILTER=gtk
-MESSAGES_TARGET=gtk/res
-
# ----------------------------------------------------------------------------
# Install target
# ----------------------------------------------------------------------------
diff --git a/gtk/gui.c b/gtk/gui.c
index 15348b9af..3a41b605e 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -1047,13 +1047,22 @@ static struct gui_browser_table nsgtk_browser_table = {
static nserror nsgtk_messages_init(char **respaths)
{
char *messages;
- nserror ret = NSERROR_NOT_FOUND;
+ nserror ret;
+ const uint8_t *data;
+ size_t data_size;
- /* Obtain path to messages */
- messages = filepath_find(respaths, "Messages");
- if (messages != NULL) {
- ret = messages_add_from_file(messages);
- free(messages);
+ ret = nsgtk_data_from_resname("Messages", &data, &data_size);
+ if (ret == NSERROR_OK) {
+ ret = messages_add_from_inline(data, data_size);
+ } else {
+ /* Obtain path to messages */
+ messages = filepath_find(respaths, "Messages");
+ if (messages != NULL) {
+ ret = messages_add_from_file(messages);
+ free(messages);
+ } else {
+ ret = NSERROR_NOT_FOUND;
+ }
}
return ret;
}
diff --git a/gtk/res/messages.gresource.xml b/gtk/res/messages.gresource.xml
new file mode 100644
index 000000000..684a10862
--- /dev/null
+++ b/gtk/res/messages.gresource.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/netsurf">
+ <file>Messages</file>
+ <file>nl/Messages</file>
+ <file>de/Messages</file>
+ <file>fr/Messages</file>
+ <file>it/Messages</file>
+ </gresource>
+</gresources>
diff --git a/gtk/resources.c b/gtk/resources.c
index 1998034ff..c9f08f4b7 100644
--- a/gtk/resources.c
+++ b/gtk/resources.c
@@ -45,8 +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)));
#else
extern const guint8 menu_cursor_pixdata[];
+const guint8 favicon_pixdata[];
+const guint8 netsurf_pixdata[];
#endif
#endif
@@ -119,6 +123,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("Messages"),
{ NULL, 0, NSGTK_RESOURCE_FILE, NULL },
};
@@ -129,9 +134,8 @@ GdkCursor *nsgtk_create_menu_cursor(void)
GdkCursor *cursor = NULL;
GdkPixbuf *pixbuf;
nserror res;
- const char *resname = "menu_cursor.png";
- res = nsgdk_pixbuf_new_from_resname(resname, &pixbuf);
+ res = nsgdk_pixbuf_new_from_resname("menu_cursor.png", &pixbuf);
if (res == NSERROR_OK) {
cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(),
pixbuf, 0, 3);
@@ -284,6 +288,20 @@ init_pixbuf_resource(char **respath, struct nsgtk_resource_s *resource)
LOG("Found builtin for %s", resource->name);
return NSERROR_OK;
}
+
+ if (strncmp(resource->name, "netsurf.xpm", resource->len) == 0) {
+ resource->path = (char *)&netsurf_pixdata[0];
+ resource->type = NSGTK_RESOURCE_INLINE;
+ LOG("Found builtin for %s", resource->name);
+ return NSERROR_OK;
+ }
+
+ if (strncmp(resource->name, "favicon.png", resource->len) == 0) {
+ resource->path = (char *)&favicon_pixdata[0];
+ resource->type = NSGTK_RESOURCE_INLINE;
+ LOG("Found builtin for %s", resource->name);
+ return NSERROR_OK;
+ }
#endif
return init_resource(respath, resource);
}