From e5aa641a3872524e334a871b9bfcc2af6cf49e32 Mon Sep 17 00:00:00 2001 From: Andres Clari Date: Mon, 26 Sep 2016 05:09:44 +0200 Subject: [PATCH] Implement automatic precompilation of the theme Following the path of Adwaita, this commit implements the automation to automatically precompile the GTK3 theme versions to gresource binary files, to improve performance of theme rendering, and avoid unnecessary re-read and re-parsing of the theme on every app run. Given that the theme is coded in sass to begin with directly altering it is not a reasonable thing to do, and so we don't loose anything by having the installed theme in binary form, specially when accessing the sources is easy enough. --- common/Makefile.am | 17 +++++++++ common/gtk-3.0/3.20/compile-gresources.sh | 46 +++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100755 common/gtk-3.0/3.20/compile-gresources.sh diff --git a/common/Makefile.am b/common/Makefile.am index 8e496fbfc..24bb8dd2b 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -190,6 +190,23 @@ endif # ENABLE_DARK endif #!ENABLE_TRANSPARENCY + + cd $(srcdir)/gtk-3.0/$(GNOME_VERSION) && cp -R \ + compile-gresources.sh \ + $(ithemedir)/gtk-3.0/compile-gresources.sh + + cd $(srcdir)/gtk-3.0/$(GNOME_VERSION) && cp -R \ + compile-gresources.sh \ + $(ithemedarkdir)/gtk-3.0/compile-gresources.sh + + cd $(srcdir)/gtk-3.0/$(GNOME_VERSION) && cp -R \ + compile-gresources.sh \ + $(ithemedarkerdir)/gtk-3.0/compile-gresources.sh + + cd $(ithemedir)/gtk-3.0/ && ./compile-gresources.sh + cd $(ithemedarkdir)/gtk-3.0/ && ./compile-gresources.sh + cd $(ithemedarkerdir)/gtk-3.0/ && ./compile-gresources.sh + endif # ENABLE_GTK3 diff --git a/common/gtk-3.0/3.20/compile-gresources.sh b/common/gtk-3.0/3.20/compile-gresources.sh new file mode 100755 index 000000000..eb17d5c6b --- /dev/null +++ b/common/gtk-3.0/3.20/compile-gresources.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# Setup +mv gtk.css gtk-main.css +mv gtk-dark.css gtk-main-dark.css + + +# Get processed assets lists +ls ./assets | sort > temp_asset_list.txt + + +# Build dynamic gresouce xml spec from css and assets +read -d '' RES_PART1 <<"EOF" + + + +EOF +echo $RES_PART1 > gtk.gresource.xml + + +# Import as nodes the file assets +xargs -i echo 'assets/{}' >> gtk.gresource.xml < temp_asset_list.txt +rm -f temp_asset_list.txt + + +# Write the css file information to the template +read -d '' RES_PART2 <<"EOF" +gtk-main.css +gtk-main-dark.css + + +EOF +echo $RES_PART2 >> gtk.gresource.xml + +# Compile the gresource file +glib-compile-resources gtk.gresource.xml +echo '@import url("resource:///org/gnome/arc-theme/gtk-main.css");' > gtk.css +echo '@import url("resource:///org/gnome/arc-theme/gtk-main-dark.css");' > gtk-dark.css + + +# Cleanup +rm -rf assets +rm -f gtk.gresource.xml +rm -f gtk-main.css +rm -f gtk-main-dark.css +rm -f compile-gresources.sh