]> sigrok.org Git - sigrok-meter.git/blob - icons/copy_icons.py
9edcbba6ccd00d80168b9ffdedca55101e6cee3b
[sigrok-meter.git] / icons / copy_icons.py
1 #!/usr/bin/env python3
2
3 ##
4 ## This file is part of the sigrok-meter project.
5 ##
6 ## Copyright (C) 2015 Jens Steinhauser <jens.steinhauser@gmail.com>
7 ##
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 2 of the License, or
11 ## (at your option) any later version.
12 ##
13 ## This program is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ## GNU General Public License for more details.
17 ##
18 ## You should have received a copy of the GNU General Public License
19 ## along with this program; if not, write to the Free Software
20 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
21 ##
22
23 # This scripts copies the icons that sigrok-meter uses from the icon pack,
24 # and outputs the matching entries for a Qt resource file.
25
26 import os
27 import shutil
28
29 ICONDIR = '../adwaita-icon-theme-3.18.0/Adwaita'
30 OUTDIR = 'icons/adwaita-icon-theme-3.18.0'
31
32 def find(iconname):
33     result = []
34     for root, dirs, files in os.walk(ICONDIR):
35         if iconname in files:
36             result.append(os.path.join(root[len(ICONDIR)+1:], iconname))
37     return result
38
39 def copy(alias, iconname):
40     for fn in sorted(find(iconname)):
41         inputfile = os.path.join(ICONDIR, fn)
42         outputfile = os.path.join(OUTDIR, fn)
43         outputpath = os.path.dirname(outputfile)
44         size = fn.split(os.sep)[0]
45
46         if not os.path.exists(outputpath):
47             os.makedirs(outputpath)
48
49         shutil.copy(inputfile, outputpath)
50
51         template = '<file alias="{}-{}.png">{}</file>'
52         print(template.format(alias, size, outputfile))
53
54 copy('about',       'help-about.png')
55 copy('add',         'list-add.png')
56 copy('exit',        'application-exit.png')
57 copy('graph',       'utilities-system-monitor.png')
58 copy('log',         'accessories-text-editor.png')
59 copy('preferences', 'preferences-system.png')
60 copy('start',       'media-playback-start.png')
61 copy('stop',        'media-playback-stop.png')