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)