summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-06-15 13:36:53 +0100
committerVincent Sanders <vince@kyllikki.org>2015-06-17 21:35:40 +0100
commit3e2270482f73528949746fc24a01d0f0c01baee8 (patch)
tree1d6b4914c6cf8b59aaa0c19ba322e4c56eb2a836 /gtk
parent59fbd51a77a684c15b189f666e4359bfd820f627 (diff)
downloadnetsurf-3e2270482f73528949746fc24a01d0f0c01baee8.tar.gz
netsurf-3e2270482f73528949746fc24a01d0f0c01baee8.tar.bz2
Make GTK resource handling configurable
This makes the GTK resource handling configurable in the same way as all other pkg-config style feature options. It is now possible to completely disable compiled in resources if wanted as well as forcing inline pixdata on if desired.
Diffstat (limited to 'gtk')
-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
4 files changed, 36 insertions, 11 deletions
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);