#!/usr/bin/env python3 # # Generate gtk.gresources.xml # # Usage: gen-gtk-gresources-xml SRCDIR_GTK [OUTPUT-FILE] import os, sys srcdir = sys.argv[1] xml = ''' ''' def get_files(subdir,extension): return sorted(filter(lambda x: x.endswith((extension)), os.listdir(os.path.join(srcdir,subdir)))) xml += ''' theme/Adwaita/gtk.css theme/Adwaita/gtk-dark.css theme/Adwaita/gtk-contained.css theme/Adwaita/gtk-contained-dark.css ''' for f in get_files('theme/Adwaita/assets', '.png'): xml += ' theme/Adwaita/assets/{0}\n'.format(f) xml += '\n' for f in get_files('theme/Adwaita/assets', '.svg'): xml += ' theme/Adwaita/assets/{0}\n'.format(f) xml += ''' theme/HighContrast/gtk.css theme/HighContrast/gtk-inverse.css theme/HighContrast/gtk-contained.css theme/HighContrast/gtk-contained-inverse.css ''' for f in get_files('theme/HighContrast/assets', '.png'): xml += ' theme/HighContrast/assets/{0}\n'.format(f) xml += '\n' for f in get_files('theme/HighContrast/assets', '.svg'): xml += ' theme/HighContrast/assets/{0}\n'.format(f) xml += ''' theme/win32/gtk-win32-base.css theme/win32/gtk.css ''' for f in get_files('gesture', '.symbolic.png'): xml += ' gesture/{0}\n'.format(f) xml += '\n' for f in get_files('ui', '.ui'): xml += ' ui/{0}\n'.format(f) xml += '\n' for f in get_files('inspector', '.ui'): xml += ' inspector/{0}\n'.format(f) xml += ''' inspector/logo.png emoji/emoji.data ''' if len(sys.argv) > 2: outfile = sys.argv[2] f = open(outfile, 'w') f.write(xml) f.close() else: print(xml)