X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=tools%2Fthemeupdate%2Fthemeupdate.py;h=171be0b9595d3ea73f6bb37fd98f7fd3d2150a46;hb=c73bd381fe7d4bc601ca1f8ecdb1b8bbf074aa18;hp=9bd720866a8e5b0ddd8dbdbf056dbec257092d65;hpb=48cc1758e4bd5f85140f9f52888e3eb5e3934b22;p=chaz%2Fopenbox diff --git a/tools/themeupdate/themeupdate.py b/tools/themeupdate/themeupdate.py index 9bd72086..171be0b9 100755 --- a/tools/themeupdate/themeupdate.py +++ b/tools/themeupdate/themeupdate.py @@ -3,6 +3,7 @@ import sys data = [] +valid = True def out(str): sys.stderr.write(str) @@ -21,14 +22,15 @@ def getkeyval(line): key = value = None return key, value -def find_key(data, keysubstr): +def find_key(data, keysubstr, exact = False): i = 0 n = len(data) while i < n: l = data[i] key, value = getkeyval(l) if key and value: - if key.find(keysubstr) != -1: + if (exact and key == keysubstr) or \ + (not exact and key.find(keysubstr) != -1): return i, key, value i += 1 return -1, None, None @@ -39,7 +41,6 @@ def simple_replace(data): pairs['window.unfocus.font'] = 'window.label.unfocus.font' pairs['window.justify'] = 'window.label.justify' pairs['menu.frame.disableColor'] = 'menu.disabled.textColor' - pairs['style.'] = 'info.' pairs['menu.frame'] = 'menu.items' pairs['menu.hilite'] = 'menu.selected' pairs['.picColor'] = '.imageColor' @@ -58,11 +59,22 @@ def simple_replace(data): def remove(data): invalid = [] invalid.append('toolbar') + for inv in invalid: + while 1: + i, key, nul = find_key(data, inv) + if i >= 0: + out(key + ' is no longer supported.\nRemove (Y/n)? ') + if read_bool(): + out('Removing "' + key + '"\n') + data.pop(i) + else: + break invalid.append('rootCommand') + invalid.append('menu.bullet') invalid.append('menu.frame.justify') for inv in invalid: while 1: - i, key, nul = find_key(data, inv) + i, key, nul = find_key(data, inv, True) if i >= 0: out(key + ' is no longer supported.\nRemove (Y/n)? ') if read_bool(): @@ -72,12 +84,13 @@ def remove(data): break def pressed(data): - i, nul, nul = find_key(data, 'window.button.pressed') + i, nul, nul = find_key(data, 'window.button.pressed', True) if i >= 0: out('The window.button.pressed option has been replaced by ' + 'window.button.pressed.focus and ' + 'window.button.pressed.unfocus.\nUpdate (Y/n)? ') if read_bool(): + l = data[i] out('Removing "window.button.pressed"\n') data.pop(i) out('Adding "window.button.pressed.unfocus"\n') @@ -162,22 +175,44 @@ def xft_fonts(data): out('Removing ' + key + '\n') data.pop(i) - - - - - - - - - - - +def pixelsize(data): + fonts = ('window.label.focus.font', + 'menu.items.font', + 'menu.title.font') + for f in fonts: + i, key, value = find_key(data, f, True) + if value: + if value.find('pixelsize') == -1: + out('*** ERROR *** The ' + key + ' font size is not being ' + 'specified by pixelsize. It is recommended that you use ' + 'pixelsize instead of pointsize for specifying theme ' + 'fonts. e.g. "sans:pixelsize=12"\n') + global valid + valid = False + +def warn_missing(data): + need = ('window.button.hover.focus', 'window.button.hover.unfocus', + 'menuOverlap') + for n in need: + i, nul, nul = find_key(data, n) + if i < 0: + out('The ' + n + ' value was not found in the theme, but it ' + 'can optionally be set.\n') + +def err_missing(data): + need = ('window.button.disabled.focus', 'window.button.disabled.unfocus', + 'window.frame.focusColor', 'window.frame.unfocusColor') + for n in need: + i, nul, nul = find_key(data, n) + if i < 0: + out('*** ERROR *** The ' + n + ' value was not found in the ' + 'theme, but it is required to be set.\n') + global valid + valid = False def usage(): - print 'Usage: ' + sys.argv[0] + ' /path/to/themerc > newthemerc' - print + out('Usage: themupdate.py /path/to/themerc > newthemerc\n\n') sys.exit() try: @@ -185,8 +220,7 @@ try: except IndexError: usage() except IOError: - print 'Unable to open file "' + sys.argv[1] + '"' - print + out('Unable to open file "' + sys.argv[1] + '"\n\n') usage() data = file.readlines() @@ -194,10 +228,15 @@ for i in range(len(data)): data[i] = data[i].strip() simple_replace(data) -#remove(data) -#pressed(data) -#x_fonts(data) +remove(data) +pressed(data) +x_fonts(data) xft_fonts(data) +pixelsize(data) +warn_missing(data) +err_missing(data) for l in data: print l + +sys.exit(not valid)