]>
Dogcows Code - chaz/openbox/blob - tools/themeupdate/themeupdate.py
d68a488fb75a91c3e0a5a60b0074f3aa70cabd2a
14 inp
= sys
.stdin
.readline(1).strip()
15 if inp
== 'y' or inp
== '': return True
16 if inp
== 'n': return False
19 key
= line
[:line
.find(':')].strip()
20 value
= line
[line
.find(':') + 1:].strip()
21 if not (key
and value
):
25 def find_key(data
, keysubstr
, exact
= False):
30 key
, value
= getkeyval(l
)
32 if (exact
and key
== keysubstr
) or \
33 (not exact
and key
.find(keysubstr
) != -1):
38 def simple_replace(data
):
40 pairs
['window.focus.font'] = 'window.label.focus.font'
41 pairs
['window.unfocus.font'] = 'window.label.unfocus.font'
42 pairs
['window.justify'] = 'window.label.justify'
43 pairs
['menu.frame.disableColor'] = 'menu.disabled.textColor'
44 pairs
['menu.frame'] = 'menu.items'
45 pairs
['menu.hilite'] = 'menu.selected'
46 pairs
['.picColor'] = '.imageColor'
48 for k
in pairs
.keys():
50 i
, key
, nul
= find_key(data
, k
);
52 newl
= data
[i
].replace(k
, pairs
[k
])
53 out('Updating "' + key
+
54 '" to "' + key
.replace(k
, pairs
[k
]) + '"\n')
61 invalid
.append('toolbar')
62 invalid
.append('rootCommand')
63 invalid
.append('menu.frame.justify')
66 i
, key
, nul
= find_key(data
, inv
)
68 out(key
+ ' is no longer supported.\nRemove (Y/n)? ')
70 out('Removing "' + key
+ '"\n')
76 i
, nul
, nul
= find_key(data
, 'window.button.pressed', True)
78 out('The window.button.pressed option has been replaced by ' +
79 'window.button.pressed.focus and ' +
80 'window.button.pressed.unfocus.\nUpdate (Y/n)? ')
83 out('Removing "window.button.pressed"\n')
85 out('Adding "window.button.pressed.unfocus"\n')
86 data
.insert(i
, l
.replace('window.button.pressed',
87 'window.button.pressed.unfocus'))
88 out('Adding "window.button.pressed.focus"\n')
89 data
.insert(i
, l
.replace('window.button.pressed',
90 'window.button.pressed.focus'))
93 i
, nul
, nul
= find_key(data
, 'window.font')
95 out('You appear to specify fonts using the old X fonts ' +
96 'syntax.\nShall I remove all fonts from the theme (Y/n)? ')
101 i
, key
= key_find(data
, '.font')
104 out('Removing "' + key
+ '"\n')
108 i
, nul
, nul
= find_key(data
, '.xft.')
110 out('You appear to specify fonts using the old Xft fonts ' +
111 'syntax.\nShall I update these to the new syntax (Y/n)? ')
116 fonts
['window'] = 'window.label.focus.font'
117 fonts
['menu.items'] = 'menu.items.font'
118 fonts
['menu.title'] = 'menu.title.font'
119 for f
in fonts
.keys():
120 li
, nul
, flags
= find_key(data
, f
+ '.xft.flags')
122 li
, nul
, flags
= find_key(data
, '*.xft.flags')
124 out('Removing ' + f
+ '.xft.flags\n')
126 oi
, nul
, offset
= find_key(data
, f
+ '.xft.shadow.offset')
128 oi
, nul
, offset
= find_key(data
, '*.xft.shadow.offset')
130 out('Removing ' + f
+ '.xft.shadow.offset\n')
132 ti
, nul
, tint
= find_key(data
, f
+ '.xft.shadow.tint')
134 ti
, nul
, tint
= find_key(data
, '*.xft.shadow.tint')
136 out('Removing ' + f
+ '.xft.shadow.tint\n')
138 fi
, nul
, face
= find_key(data
, f
+ '.xft.font')
140 fi
, nul
, face
= find_key(data
, '*.xft.font')
141 if fi
>= 0: fi
= len(data
) - 1
143 out('Removing ' + f
+ '.xft.font\n')
149 if flags
.find('bold'):
151 if flags
.find('shadow'):
154 s
= s
+ ':shadowoffset=' + offset
156 s
= s
+ ':shadowtint=' + tint
157 out('Adding ' + fonts
[f
] + '\n')
158 data
.insert(fi
, fonts
[f
] + ': ' + s
)
160 for stars
in ('*.xft.flags', '*.xft.shadow.offset' ,
161 '*.xft.shadow.tint', '*.xft.font'):
162 i
, key
, nul
= find_key(data
, stars
)
164 out('Removing ' + key
+ '\n')
168 fonts
= ('window.label.focus.font',
172 i
, key
, value
= find_key(data
, f
, True)
174 if value
.find('pixelsize') == -1:
175 out('*** ERROR *** The ' + key
+ ' font size is not being '
176 'specified by pixelsize. It is recommended that you use '
177 'pixelsize instead of pointsize for specifying theme '
178 'fonts. e.g. "sans:pixelsize=12"\n')
182 def warn_missing(data
):
183 need
= ('window.button.hover.focus', 'window.button.hover.unfocus',
186 i
, nul
, nul
= find_key(data
, n
)
188 out('The ' + n
+ ' value was not found in the theme, but it '
189 'can optionally be set.\n')
191 def err_missing(data
):
192 need
= ('window.button.disabled.focus', 'window.button.disabled.unfocus',
193 'window.frame.focusColor', 'window.frame.unfocusColor')
195 i
, nul
, nul
= find_key(data
, n
)
197 out('*** ERROR *** The ' + n
+ ' value was not found in the '
198 'theme, but it is required to be set.\n')
204 out('Usage: themupdate.py /path/to/themerc > newthemerc\n\n')
208 file = open(sys
.argv
[1])
212 out('Unable to open file "' + sys
.argv
[1] + '"\n\n')
215 data
= file.readlines()
216 for i
in range(len(data
)):
217 data
[i
] = data
[i
].strip()
This page took 0.04313 seconds and 4 git commands to generate.