Skip to content
This repository has been archived by the owner on May 14, 2020. It is now read-only.

Implement automatic precompilation #29

Merged
merged 10 commits into from
Sep 25, 2018
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ common/gtk-3.0/**/assets/*.png
common/gtk-2.0/assets*/*.png
common/gtk-2.0/menubar-toolbar/*.png
common/xfwm4/assets*/*.png
common/compile-gresources.sh
12 changes: 12 additions & 0 deletions common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ endif # ENABLE_DARK

endif #!ENABLE_TRANSPARENCY

@if [ "$(GTK_VERSION)" != "3.18" ]; then \
cd $(srcdir)/gtk-3.0/$(GTK3_VERSION) && cp -RL compile-gresources.sh $(ithemedir)/gtk-3.0/compile-gresources.sh;\
cd ../..;\
cd $(srcdir)/gtk-3.0/$(GTK3_VERSION) && cp -RL compile-gresources.sh $(ithemedarkdir)/gtk-3.0/compile-gresources.sh;\
cd ../..;\
cd $(srcdir)/gtk-3.0/$(GTK3_VERSION) && cp -RL compile-gresources.sh $(ithemedarkerdir)/gtk-3.0/compile-gresources.sh;\
cd ../..;\
cd $(ithemedir)/gtk-3.0/ && ./compile-gresources.sh LIGHT;\
cd $(ithemedarkdir)/gtk-3.0/ && ./compile-gresources.sh DARK;\
cd $(ithemedarkerdir)/gtk-3.0/ && ./compile-gresources.sh DARKER;\
fi

fossfreedom marked this conversation as resolved.
Show resolved Hide resolved
endif # ENABLE_GTK3


Expand Down
56 changes: 56 additions & 0 deletions common/gtk-3.0/3.20/compile-gresources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# Setup
mv gtk.css gtk-main.css
if [ "$1" != "DARK" ]; then
mv gtk-dark.css gtk-main-dark.css
fi

# 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"
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/arc-theme">
EOF
echo $RES_PART1 > gtk.gresource.xml


# Import as nodes the file assets
xargs -i echo '<file preprocess="to-pixdata">assets/{}</file>' >> gtk.gresource.xml < temp_asset_list.txt
rm -f temp_asset_list.txt


# Write the css file information to the template
if [ "$1" != "DARK" ]; then
read -d '' RES_PART2 <<"EOF"
<file>gtk-main.css</file>
<file>gtk-main-dark.css</file>
</gresource>
</gresources>
EOF
else
read -d '' RES_PART2 <<"EOFDARK"
<file>gtk-main.css</file>
</gresource>
</gresources>
EOFDARK
fi
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
if [ "$1" != "DARK" ]; then
echo '@import url("resource:///org/gnome/arc-theme/gtk-main-dark.css");' > gtk-dark.css
fi

# 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
fossfreedom marked this conversation as resolved.
Show resolved Hide resolved