From 611aa243b42aa854a8a5302a634cef14a7dced90 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 14 Jul 2020 22:46:34 +0200 Subject: Created a small tool to unpack theme modules. --- python/extract.py | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 python/extract.py diff --git a/python/extract.py b/python/extract.py new file mode 100644 index 0000000..e04ba7e --- /dev/null +++ b/python/extract.py @@ -0,0 +1,71 @@ + +import gi +import os +import sys +from gi.repository import Gio + + +if len(sys.argv) != 2: + print('Usage: %s ' % sys.argv[0]) + sys.exit(1) + +res = Gio.Resource.load(sys.argv[1]) + + +# Get the name of the theme + +children = res.enumerate_children('/org/chrysalide/gui/themes', Gio.ResourceLookupFlags.NONE) + +name = children[0][:-1] + + +# Prepare the output directory + +if not(os.path.isdir(name)): + os.mkdir(name) + + +# Dump resource files + +files = '' + +children = res.enumerate_children('/org/chrysalide/gui/themes/' + name, Gio.ResourceLookupFlags.NONE) + +for child in children: + + raw = res.lookup_data('/org/chrysalide/gui/themes/' + name + '/' + child, Gio.ResourceLookupFlags.NONE) + + with open(name + os.sep + child, 'wb') as out: + out.write(raw.get_data()) + + files += '\n %s' % child + + +# Create the gresource.xml file + +xml = ''' + + %s + + +''' % (name, files) + +with open(name + os.sep + 'gresource.xml', 'w') as out: + out.write(xml) + + +# Create a Makefile + +rules = ''' +GTK3_CSS = %s + +%s.ctm: gresource.xml $(GTK3_CSS) + glib-compile-resources --target=$@ --sourcedir=. gresource.xml + +clean: + rm -f %s + +''' % (' '.join(children), name.lower(), name.lower()) + +with open(name + os.sep + 'Makefile', 'w') as out: + out.write(rules) -- cgit v0.11.2-87-g4458