blob: e04ba7ed6c8de966ae8eec9f56799b941a565525 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
import gi
import os
import sys
from gi.repository import Gio
if len(sys.argv) != 2:
print('Usage: %s <theme file>' % 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 <file compressed="true">%s</file>' % child
# Create the gresource.xml file
xml = '''<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/chrysalide/gui/themes/%s">%s
</gresource>
</gresources>
''' % (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)
|