Icon creation in only one function
[wmaker-crm.git] / WINGs / make-rgb
blobcdb407d498d0bb03265b35b733ab0689b6177236
1 #!/usr/bin/python
3 import sys
4 import re
5 from optparse import OptionParser
7 parser = OptionParser(version="%prog 1.0")
8 parser.add_option("-f", "--file", dest="rgbtxtFile", default='/etc/X11/rgb.txt',
9 help="rgb.txt file containing X11 colors (/etc/X11/rgb.txt)",
10 metavar="File")
12 (options, args) = parser.parse_args()
14 f = open(options.rgbtxtFile)
15 lines = f.readlines()
16 f.close()
18 colorLine = re.compile(r'''\s*
19 (?P<red>\d+) # red
20 \s+
21 (?P<green>\d+) # green
22 \s+
23 (?P<blue>\d+) # blue
24 \s+
25 (?P<name>[^\s]+) # name
26 ''', re.VERBOSE)
28 print '''
29 /* Automatically generated file. Do NOT edit. Regenerate it using make-rgb */
31 #ifndef RGB_H_
32 #define RGB_H_
34 #include <wraster.h>
36 typedef struct RGBColor {
37 RColor color;
38 char *name;
39 } RGBColor;
41 RGBColor rgbColors[] = {'''
43 for line in lines:
44 m = colorLine.match(line)
45 if m:
46 print ''' {{%(red)3s, %(green)3s, %(blue)3s, 0}, "%(name)s"},''' % m.groupdict()
48 print ''' {{ 0, 0, 0, 0}, NULL}
51 #endif
52 '''