wok-next view gtk+/stuff/replace-icons-paper @ rev 20523
libnsgif: add missing stuff
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Mar 23 15:16:45 2018 +0200 (2018-03-23) |
parents | |
children |
line source
1 # Replace GTK+ stock icons by Paper icons
2 # in order to strip icon theme and save some space.
5 # Return shortest line
6 shortest_line() {
7 S=$1; shift
8 for L in $@; do
9 [ "${#L}" -lt "${#S}" ] && S="$L"
10 done
11 echo "$S"
12 }
14 # Replace the same files by symlinks, $@ - list of identical files
15 make_symlinks() {
16 S=$(shortest_line $@)
17 for file in $@; do
18 [ "$S" != "$file" ] && ln -sf $S $file
19 done
20 }
23 echo -n "Replacing icons... "
25 F=/usr/share/icons/Paper
27 # copy icon
28 ci() {
29 icon=$(basename $1 .png)
30 size="$2"
31 sub=''
32 case $icon in
33 *-ltr) sub=${icon%-*};;
34 *-rtl)
35 case ${icon%-*} in
36 edit-redo) sub='edit-undo';;
37 edit-undo) sub='edit-redo';;
38 format-indent-less) sub='format-indent-more';;
39 format-indent-more) sub='format-indent-less';;
40 go-first) sub='go-last';;
41 go-last) sub='go-first';;
42 go-next) sub='go-previous';;
43 go-previous) sub='go-next';;
44 media-seek-backward) sub='media-seek-forward';;
45 media-seek-forward) sub='media-seek-backward';;
46 media-skip-backward) sub='media-skip-forward';;
47 media-skip-forward) sub='media-skip-backward';;
48 esac
49 sub="$sub $sub-ltr"
50 ;;
51 gtk-caps-lock-warning) sub='dialog-warning';;
52 gtk-color-picker) sub='color-picker';;
53 gtk-connect) sub='network-transmit-receive';;
54 gtk-disconnect) sub='network-offline';;
55 gtk-edit) sub='edit';;
56 gtk-font) sub='font-x-generic';;
57 gtk-page-setup) sub='document-page-setup';;
58 gtk-preferences) sub='preferences-desktop';;
59 gtk-select-color) sub='color-select';;
60 gtk-select-font) sub='font-select';;
61 gtk-apply) sub='object-select';;
62 gtk-no) sub='emblem-unreadable';;
63 gtk-yes) sub='emblem-default';;
64 gtk-ok) sub='object-select';;
65 esac
67 found=''
68 for i in png svg; do
69 for j in actions apps categories devices emblems emotes mimetypes places status; do
70 for k in $icon $sub; do
71 if [ -f "$F/$size/$j/$k.$i" ]; then
72 found="$F/$size/$j/$k.$i"
73 break 3
74 fi
75 done
76 done
77 done
78 case $found in
79 *.png) cp -f $found $1;;
80 *.svg) rm $1; rsvg-convert $found -o $1;;
81 esac
82 }
84 cd $src/gtk/stock-icons/16; for a in $(ls); do ci $a 16x16; done
85 cd $src/gtk/stock-icons/20; for a in $(ls); do ci $a 16x16; done # yes, using 16x16 for 20
86 cd $src/gtk/stock-icons/24; for a in $(ls); do ci $a 16x16; done # too
87 cd $src/gtk/stock-icons/32; for a in $(ls); do ci $a 32x32; done
88 cd $src/gtk/stock-icons/48; for a in $(ls); do ci $a 48x48; done
90 echo "Done"
92 for folder in 16 20 24 32 48; do
93 echo -n "Optimizing folder icons $folder... "
94 cd $src/gtk/stock-icons/$folder
95 for icon in ./*.png; do
96 pngquant -f --skip-if-larger --ext .png --speed 1 "$icon"
97 optipng -quiet -o7 -zm1-9 "$icon"
98 done
99 echo "Done"
100 done
103 # replace the same icons by symlinks
105 MD5FILE=$(mktemp)
106 find $src/gtk/stock-icons -type f -exec md5sum '{}' \; | sort > $MD5FILE
107 for md in $(uniq -d -w32 $MD5FILE | cut -c1-32); do
108 make_symlinks $(grep $md $MD5FILE | cut -c35-)
109 done
110 rm "$MD5FILE"
111 # make all symlinks relative
112 symlinks -crs $src/gtk/stock-icons >/dev/null 2>&1
116 # missing icons:
117 # 16, 24
118 # ==============================================================================
119 # gtk-convert
120 # gtk-index
121 # gtk-orientation-landscape
122 # gtk-orientation-portrait
123 # gtk-orientation-reverse-landscape
124 # gtk-orientation-reverse-portrait
125 # gtk-undelete-ltr
126 # gtk-undelete-rtl
127 # printer-paused
128 # printer-warning
129 # 32
130 # ==============================================================================
131 # gtk-dnd
132 # gtk-dnd-multiple