summaryrefslogtreecommitdiff
path: root/image/toolbar/svg-to-png.sh
blob: 6796aad8d774e4624f9515c8e3708b54d2eec760 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
# svg-to-png
# Convert SVG files to 1x and 2x PNGs. Dump a list of Qt resource
# file entries upon successful completion.
#
# Copyright 2014 Gerald Combs <gerald [AT] wireshark.org>
#
# Wireshark - Network traffic analyzer
# By Gerald Combs <gerald@wireshark.org>
# Copyright 1998 Gerald Combs
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

COMMON_ARGS="--export-area-page"

set_source_svgs() {
    local out_icon=$1
    case $out_icon in
    x-capture-options)
        out_icon=x-capture-options-gear
        ;;
    x-capture-restart)
        out_icon=x-capture-restart-fin
        ;;
    x-capture-stop)
        out_icon=x-capture-stop-red
        ;;
    esac
    ONE_X_SVG=${out_icon}.svg
    TWO_X_SVG=${out_icon}@2x.svg
    if [ ! -f ${TWO_X_SVG} ] ; then
        TWO_X_SVG=$ONE_X_SVG
    fi
}

ICONS="
    edit-find
    go-first
    go-jump
    go-last
    go-next
    go-previous
    media-playback-start
    x-capture-file-close
    x-capture-file-save
    x-capture-file-reload
    x-capture-options
    x-capture-restart
    x-capture-start.on
    x-capture-start
    x-capture-stop
    x-colorize-packets
    x-resize-columns
    x-stay-last
    zoom-in
    zoom-original
    zoom-out
    "

QRC_FILES=""

# XXX Add support for 16 pixel icons.
for SIZE in 12 16 24 ; do
    SIZE_DIR=${SIZE}x${SIZE}

    TWO_X_SIZE=`expr $SIZE \* 2`
    ONE_X_ARGS="--export-width=${SIZE} --export-height=${SIZE}"
    TWO_X_ARGS="--export-width=${TWO_X_SIZE} --export-height=${TWO_X_SIZE}"

    cd $SIZE_DIR

    for ICON in $ICONS ; do
        set_source_svgs $ICON

        if [ ! -f ${ONE_X_SVG} ] ; then
            >&2 echo "Skipping ${ONE_X_SVG}"
            continue
        fi

        ONE_X_PNG=${ICON}.png
        TWO_X_PNG=${ICON}@2x.png

        if [ $ONE_X_SVG -nt $ONE_X_PNG ] ; then
            inkscape $COMMON_ARGS $ONE_X_ARGS \
                --file=$ONE_X_SVG --export-png=$ONE_X_PNG || exit 1
        fi

        if [ $TWO_X_SVG -nt $TWO_X_PNG ] ; then
            inkscape $COMMON_ARGS $TWO_X_ARGS \
                --file=$TWO_X_SVG --export-png=$TWO_X_PNG || exit 1
        fi

        QRC_FILES="${QRC_FILES} ${SIZE_DIR}/${ONE_X_PNG} ${SIZE_DIR}/${TWO_X_PNG}"
    done

    cd ..

done

for QRC_FILE in $QRC_FILES ; do
    echo "        <file>toolbar/${QRC_FILE}</file>"
done

#
# Editor modelines  -  https://www.wireshark.org/tools/modelines.html
#
# Local variables:
# c-basic-offset: 4
# tab-width: 8
# indent-tabs-mode: nil
# End:
#
# vi: set shiftwidth=4 tabstop=8 expandtab:
# :indentSize=4:tabSize=8:noTabs=true:
#