wok-next diff gtk+/stuff/replace-icons-paper @ rev 19988
Add qt5 - now it's look good enough
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Oct 20 03:29:40 2017 +0300 (2017-10-20) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gtk+/stuff/replace-icons-paper Fri Oct 20 03:29:40 2017 +0300 1.3 @@ -0,0 +1,132 @@ 1.4 +# Replace GTK+ stock icons by Paper icons 1.5 +# in order to strip icon theme and save some space. 1.6 + 1.7 + 1.8 +# Return shortest line 1.9 +shortest_line() { 1.10 + S=$1; shift 1.11 + for L in $@; do 1.12 + [ "${#L}" -lt "${#S}" ] && S="$L" 1.13 + done 1.14 + echo "$S" 1.15 +} 1.16 + 1.17 +# Replace the same files by symlinks, $@ - list of identical files 1.18 +make_symlinks() { 1.19 + S=$(shortest_line $@) 1.20 + for file in $@; do 1.21 + [ "$S" != "$file" ] && ln -sf $S $file 1.22 + done 1.23 +} 1.24 + 1.25 + 1.26 +echo -n "Replacing icons... " 1.27 + 1.28 +F=/usr/share/icons/Paper 1.29 + 1.30 +# copy icon 1.31 +ci() { 1.32 + icon=$(basename $1 .png) 1.33 + size="$2" 1.34 + sub='' 1.35 + case $icon in 1.36 + *-ltr) sub=${icon%-*};; 1.37 + *-rtl) 1.38 + case ${icon%-*} in 1.39 + edit-redo) sub='edit-undo';; 1.40 + edit-undo) sub='edit-redo';; 1.41 + format-indent-less) sub='format-indent-more';; 1.42 + format-indent-more) sub='format-indent-less';; 1.43 + go-first) sub='go-last';; 1.44 + go-last) sub='go-first';; 1.45 + go-next) sub='go-previous';; 1.46 + go-previous) sub='go-next';; 1.47 + media-seek-backward) sub='media-seek-forward';; 1.48 + media-seek-forward) sub='media-seek-backward';; 1.49 + media-skip-backward) sub='media-skip-forward';; 1.50 + media-skip-forward) sub='media-skip-backward';; 1.51 + esac 1.52 + sub="$sub $sub-ltr" 1.53 + ;; 1.54 + gtk-caps-lock-warning) sub='dialog-warning';; 1.55 + gtk-color-picker) sub='color-picker';; 1.56 + gtk-connect) sub='network-transmit-receive';; 1.57 + gtk-disconnect) sub='network-offline';; 1.58 + gtk-edit) sub='edit';; 1.59 + gtk-font) sub='font-x-generic';; 1.60 + gtk-page-setup) sub='document-page-setup';; 1.61 + gtk-preferences) sub='preferences-desktop';; 1.62 + gtk-select-color) sub='color-select';; 1.63 + gtk-select-font) sub='font-select';; 1.64 + gtk-apply) sub='object-select';; 1.65 + gtk-no) sub='emblem-unreadable';; 1.66 + gtk-yes) sub='emblem-default';; 1.67 + gtk-ok) sub='object-select';; 1.68 + esac 1.69 + 1.70 + found='' 1.71 + for i in png svg; do 1.72 + for j in actions apps categories devices emblems emotes mimetypes places status; do 1.73 + for k in $icon $sub; do 1.74 + if [ -f "$F/$size/$j/$k.$i" ]; then 1.75 + found="$F/$size/$j/$k.$i" 1.76 + break 3 1.77 + fi 1.78 + done 1.79 + done 1.80 + done 1.81 + case $found in 1.82 + *.png) cp -f $found $1;; 1.83 + *.svg) rm $1; rsvg-convert $found -o $1;; 1.84 + esac 1.85 +} 1.86 + 1.87 +cd $src/gtk/stock-icons/16; for a in $(ls); do ci $a 16x16; done 1.88 +cd $src/gtk/stock-icons/20; for a in $(ls); do ci $a 16x16; done # yes, using 16x16 for 20 1.89 +cd $src/gtk/stock-icons/24; for a in $(ls); do ci $a 16x16; done # too 1.90 +cd $src/gtk/stock-icons/32; for a in $(ls); do ci $a 32x32; done 1.91 +cd $src/gtk/stock-icons/48; for a in $(ls); do ci $a 48x48; done 1.92 + 1.93 +echo "Done" 1.94 + 1.95 +for folder in 16 20 24 32 48; do 1.96 + echo -n "Optimizing folder icons $folder... " 1.97 + cd $src/gtk/stock-icons/$folder 1.98 + for icon in ./*.png; do 1.99 + pngquant -f --skip-if-larger --ext .png --speed 1 "$icon" 1.100 + optipng -quiet -o7 -zm1-9 "$icon" 1.101 + done 1.102 + echo "Done" 1.103 +done 1.104 + 1.105 + 1.106 +# replace the same icons by symlinks 1.107 + 1.108 +MD5FILE=$(mktemp) 1.109 +find $src/gtk/stock-icons -type f -exec md5sum '{}' \; | sort > $MD5FILE 1.110 +for md in $(uniq -d -w32 $MD5FILE | cut -c1-32); do 1.111 + make_symlinks $(grep $md $MD5FILE | cut -c35-) 1.112 +done 1.113 +rm "$MD5FILE" 1.114 +# make all symlinks relative 1.115 +symlinks -crs $src/gtk/stock-icons >/dev/null 2>&1 1.116 + 1.117 + 1.118 + 1.119 +# missing icons: 1.120 +# 16, 24 1.121 +# ============================================================================== 1.122 +# gtk-convert 1.123 +# gtk-index 1.124 +# gtk-orientation-landscape 1.125 +# gtk-orientation-portrait 1.126 +# gtk-orientation-reverse-landscape 1.127 +# gtk-orientation-reverse-portrait 1.128 +# gtk-undelete-ltr 1.129 +# gtk-undelete-rtl 1.130 +# printer-paused 1.131 +# printer-warning 1.132 +# 32 1.133 +# ============================================================================== 1.134 +# gtk-dnd 1.135 +# gtk-dnd-multiple