mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 22:20:24 +00:00
7eeeb3f229
Provide a fallback cursor of last resort. Otherwise, we end up with no visible cursor if there is no cursor theme installed, wihch is less than helpful.
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
#
|
|
# Generate gdk.gresources.xml
|
|
#
|
|
# Usage: gen-gdk-gresources-xml SRCDIR_GDK [OUTPUT-FILE]
|
|
|
|
import os, sys
|
|
import filecmp
|
|
|
|
def replace_if_changed(new, old):
|
|
'''
|
|
Compare contents and only replace if changed to avoid triggering a rebuild.
|
|
'''
|
|
try:
|
|
changed = not filecmp.cmp(new, old, shallow=False)
|
|
except FileNotFoundError:
|
|
changed = True
|
|
if changed:
|
|
os.replace(new, old)
|
|
else:
|
|
os.remove(new)
|
|
|
|
srcdir = sys.argv[1]
|
|
|
|
xml = '''<?xml version='1.0' encoding='UTF-8'?>
|
|
<gresources>
|
|
<gresource prefix='/org/gtk/libgdk'>
|
|
<file alias='cursor/default'>default_cursor.png</file>
|
|
'''
|
|
|
|
def get_files(subdir,extension):
|
|
return sorted(filter(lambda x: x.endswith((extension)), os.listdir(os.path.join(srcdir,subdir))))
|
|
|
|
for f in get_files('resources/glsl', '.glsl'):
|
|
xml += ' <file alias=\'glsl/{0}\'>resources/glsl/{0}</file>\n'.format(f)
|
|
|
|
xml += '''
|
|
</gresource>
|
|
</gresources>'''
|
|
|
|
if len(sys.argv) > 2:
|
|
outfile = sys.argv[2]
|
|
tmpfile = outfile + '~'
|
|
with open(tmpfile, 'w') as f:
|
|
f.write(xml)
|
|
replace_if_changed(tmpfile, outfile)
|
|
else:
|
|
print(xml)
|