]>
Commit | Line | Data |
---|---|---|
68348e5a JS |
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 | |
0b63748b | 19 | ## along with this program; if not, see <http://www.gnu.org/licenses/>. |
68348e5a JS |
20 | ## |
21 | ||
22 | # This scripts copies the icons that sigrok-meter uses from the icon pack, | |
23 | # and outputs the matching entries for a Qt resource file. | |
24 | ||
25 | import os | |
26 | import shutil | |
27 | ||
28 | ICONDIR = '../adwaita-icon-theme-3.18.0/Adwaita' | |
29 | OUTDIR = 'icons/adwaita-icon-theme-3.18.0' | |
30 | ||
31 | def find(iconname): | |
32 | result = [] | |
33 | for root, dirs, files in os.walk(ICONDIR): | |
34 | if iconname in files: | |
35 | result.append(os.path.join(root[len(ICONDIR)+1:], iconname)) | |
36 | return result | |
37 | ||
38 | def copy(alias, iconname): | |
39 | for fn in sorted(find(iconname)): | |
40 | inputfile = os.path.join(ICONDIR, fn) | |
41 | outputfile = os.path.join(OUTDIR, fn) | |
42 | outputpath = os.path.dirname(outputfile) | |
43 | size = fn.split(os.sep)[0] | |
44 | ||
45 | if not os.path.exists(outputpath): | |
46 | os.makedirs(outputpath) | |
47 | ||
48 | shutil.copy(inputfile, outputpath) | |
49 | ||
50 | template = '<file alias="{}-{}.png">{}</file>' | |
51 | print(template.format(alias, size, outputfile)) | |
52 | ||
53 | copy('about', 'help-about.png') | |
54 | copy('add', 'list-add.png') | |
55 | copy('exit', 'application-exit.png') | |
56 | copy('graph', 'utilities-system-monitor.png') | |
57 | copy('log', 'accessories-text-editor.png') | |
58 | copy('preferences', 'preferences-system.png') | |
59 | copy('start', 'media-playback-start.png') | |
60 | copy('stop', 'media-playback-stop.png') |