summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/BUILDING-GTK46
-rw-r--r--gtk/Makefile.defaults11
-rw-r--r--gtk/Makefile.target29
-rw-r--r--gtk/res/netsurf.gresource.xml5
-rw-r--r--gtk/resources.c2
5 files changed, 76 insertions, 17 deletions
diff --git a/Docs/BUILDING-GTK b/Docs/BUILDING-GTK
index dab2bef07..4ac0fc89e 100644
--- a/Docs/BUILDING-GTK
+++ b/Docs/BUILDING-GTK
@@ -168,12 +168,14 @@
Building and executing NetSurf
--------------------------------
- First of all, you should examine the contents of Makefile.defaults
- and enable and disable relevant features as you see fit by creating
- a Makefile.config file. Some of these options can be automatically
- detected and used, and where this is the case they are set to such.
- Others cannot be automatically detected from the Makefile, so you
- will either need to install the dependencies, or set them to NO.
+ First of all, you should examine the options in Makefile.defaults
+ and gtk/Makefile.defaults and enable and disable relevant features
+ as you see fit by editing a Makefile.config file.
+
+ Some of these options can be automatically detected and used, and
+ where this is the case they are set to such. Others cannot be
+ automatically detected from the Makefile, so you will either need to
+ install the dependencies, or set them to NO.
You should then obtain NetSurf's dependencies, keeping in mind which options
you have enabled in the configuration file. See the next section for
@@ -197,6 +199,38 @@
sets up some environment variables which enable NetSurf to find its
resources.
+ Builtin resources
+-------------------
+
+ There are numerous resources that accompany NetSurf, such as the
+ image files for icons, cursors and the ui builder files that
+ construct the browsers interface.
+
+ Some of these resources can be compiled into the browser executable
+ removing the need to install these resources separately. The GLib
+ library on which GTK is based provides this functionality to
+ NetSurf.
+
+ Up until GLib version 2.32 only the GDK pixbuf could be integrated
+ in this way and is controlled with the NETSURF_USE_INLINE_PIXBUF
+ variable (set in makefile.config).
+
+ Glib version 2.32 and later integrated support for any file to be a
+ resource while depreciating the old inline pixbuf interface. NetSurf
+ gtk executables can integrate many resources using this interface,
+ configuration is controlled with the NETSURF_USE_GRESOURCE variable.
+
+ Loading from file is the fallback if a resource has not been
+ compiled in, because of this if both of these features are
+ unavailable (or disabled) NetSurf will automatically fall back to
+ loading all its resources from files.
+
+ The resource initialisation within the browser ensures it can access
+ all the resources at start time, however it does not verify the
+ resources are valid so failures could still occur subsequently. This
+ is especially true for file based resources as they can become
+ inaccessible after initialisation.
+
Note for packagers
====================
diff --git a/gtk/Makefile.defaults b/gtk/Makefile.defaults
index 51aa02707..0f229d8c2 100644
--- a/gtk/Makefile.defaults
+++ b/gtk/Makefile.defaults
@@ -21,6 +21,17 @@ NETSURF_USE_NSSVG := AUTO
# Valid options: YES, NO, AUTO
NETSURF_USE_ROSPRITE := AUTO
+# Enable the use of GLib compiled in resource handling. This requires
+# GLib 2.32 or later
+# Valid options: YES, NO, AUTO
+NETSURF_USE_GRESOURCE := AUTO
+
+# Enable the use of compiled in inline pixbuf. This is depricated
+# since GLib 2.32. The automatic selection is disabled if GRESOURCE
+# handling is enabled
+# Valid options: YES, NO, AUTO
+NETSURF_USE_INLINE_PIXBUF := AUTO
+
# Enable building the source object cache filesystem based backing store.
NETSURF_FS_BACKING_STORE := YES
diff --git a/gtk/Makefile.target b/gtk/Makefile.target
index bbe5d5f54..cc8516264 100644
--- a/gtk/Makefile.target
+++ b/gtk/Makefile.target
@@ -87,13 +87,20 @@ S_RESOURCE :=
# Glib prior to 2.32 does not have GResource handling.
#
# This uses pkg-config to check for the minimum required version for
-# this feature. Note we check for gmodule-2.0 which is a specific
-# part of glib we require.
+# this feature in a way similar to the pkg_config_find_and_add_enabled
+# macro. Note we check for gmodule-2.0 which is a specific part of
+# glib we require.
+#
# It would be nice if we could check for this functionality rather
# than "knowing" the version but there does not appear to be a simple
# way to implement that.
-NETSURF_GRESOURCE_AVAILABLE := $(shell $(PKG_CONFIG) --atleast-version=2.32 gmodule-2.0 && echo yes)
-ifeq ($(NETSURF_GRESOURCE_AVAILABLE),yes)
+#
+NETSURF_FEATURE_GRESOURCE_AVAILABLE := $(shell $(PKG_CONFIG) --atleast-version=2.32 gmodule-2.0 && echo yes)
+ifneq (,$(filter $(NETSURF_USE_GRESOURCE),AUTO YES))
+ifeq ($(NETSURF_FEATURE_GRESOURCE_AVAILABLE),yes)
+
+# Gresource use has been enabled
+NETSURF_FEATURE_GRESOURCE_ENABLED := yes
#resource compiler tool
GLIB_COMPILE_RESOURCES := glib-compile-resources
@@ -106,10 +113,15 @@ GRESOURCE_XML := $(NSGTK_RESOURCES_DIR)/netsurf.gresource.xml
# generate the gresource source file
$(OBJROOT)/netsurf_gresource.c: $(GRESOURCE_XML) $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir $(NSGTK_RESOURCES_DIR) --generate-dependencies $(GRESOURCE_XML))
- $(GLIB_COMPILE_RESOURCES) --generate-source --sourcedir $(NSGTK_RESOURCES_DIR) --target=$@ $<
+ $(VQ)echo "GRESORCE: $<"
+ $(Q)$(GLIB_COMPILE_RESOURCES) --generate-source --sourcedir $(NSGTK_RESOURCES_DIR) --target=$@ $<
+
+endif
+endif
-else
-# No GResource available so build pixbufs as inlines instead
+# Build pixbufs as inlines if enabled
+ifneq (,$(filter $(NETSURF_USE_INLINE_PIXBUF),AUTO YES))
+ifneq ($(NETSURF_FEATURE_GRESOURCE_ENABLED),yes)
CFLAGS += -DWITH_BUILTIN_PIXBUF
@@ -124,6 +136,7 @@ define convert_image
S_RESOURCE += $(2)
$(2): $(1)
+ $(VQ)echo " INLINE: ${3}"
$(Q)echo "#include <gdk-pixbuf/gdk-pixdata.h>" > $(2)
$(Q)gdk-pixbuf-csource --extern --raw --name=$(3) $(1) >> $(2) || \
( rm -f $(2) && false )
@@ -131,7 +144,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)))
-
+endif
endif
# ----------------------------------------------------------------------------
diff --git a/gtk/res/netsurf.gresource.xml b/gtk/res/netsurf.gresource.xml
index 03e4be2f0..09683faa9 100644
--- a/gtk/res/netsurf.gresource.xml
+++ b/gtk/res/netsurf.gresource.xml
@@ -27,7 +27,8 @@
<file>password.gtk2.ui</file>
<file>tabcontents.gtk3.ui</file>
<file>warning.gtk2.ui</file>
- <file>favicon.png</file>
- <file>netsurf.xpm</file>
+ <file preprocess="to-pixdata">favicon.png</file>
+ <file preprocess="to-pixdata">netsurf.xpm</file>
+ <file preprocess="to-pixdata">menu_cursor.png</file>
</gresource>
</gresources>
diff --git a/gtk/resources.c b/gtk/resources.c
index e3e044e00..d28414d60 100644
--- a/gtk/resources.c
+++ b/gtk/resources.c
@@ -118,7 +118,6 @@ GdkCursor *nsgtk_create_menu_cursor(void)
static nserror
init_resource(char **respath, struct nsgtk_resource_s *resource)
{
- int resnamelen;
char *resname;
#ifdef WITH_BUILTIN_PIXBUF
if (strncmp(resource->name, "menu_cursor.png", resource->len) == 0) {
@@ -129,6 +128,7 @@ init_resource(char **respath, struct nsgtk_resource_s *resource)
}
#endif
#ifdef WITH_GRESOURCE
+ int resnamelen;
gboolean present;
resnamelen = snprintf(NULL, 0, "/org/netsurf/%s", resource->name);