1#!/usr/local/bin/bash 2# 3# This file is part of plata-theme 4# 5# Copyright (C) 2018-2020 Tista <tista.gma500@gmail.com> 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12 13INKSCAPE="`command -v inkscape`" 14SRC_FILE="../assets-gtk2.svg" 15ASSETS_DIR="../assets-gtk2" 16INDEX_SRC="assets-gtk2.txt" 17INDEX="" 18KEY_FILE="../../sass/common/_key_colors.scss" 19 20ink_maj_ver="`$INKSCAPE --version | grep Ink | awk '{print $2}' | cut -c 1`" 21ink_mnr_ver="`$INKSCAPE --version | grep Ink | awk '{print $2}' | cut -c 3-4`" 22if [ "$ink_maj_ver"."$ink_mnr_ver" = 0.91 ]; then 23 non_scale_dpi=90 24else 25 non_scale_dpi=96 26fi 27 28if [ "$ink_maj_ver" -ge 1 ]; then 29 if [ "$ink_mnr_ver" = '0b' ]; then 30 ink_export_option="--export-file" 31 else 32 ink_export_option="--export-filename" 33 fi 34else 35 ink_export_option="--export-png" 36fi 37 38# Renderer 39render-non-scale() { 40 ID=`echo $i | tr '/' '_'` 41 $INKSCAPE --export-id=$ID \ 42 --export-dpi="$non_scale_dpi" \ 43 --export-id-only \ 44 $ink_export_option=$ASSETS_DIR/$i.png $SRC_FILE \ 45 >/dev/null 2>>../inkscape.log 46} 47 48# Generate PNG files 49case "$1" in 50 arrow) 51 INDEX=($(grep -e Arrows $INDEX_SRC)) 52 ;; 53 button) 54 INDEX=($(grep -e Buttons $INDEX_SRC)) 55 ;; 56 checkradio) 57 INDEX=($(grep -e Check-Radio $INDEX_SRC)) 58 ;; 59 column) 60 INDEX=($(grep -e Column $INDEX_SRC)) 61 ;; 62 entry) 63 INDEX=($(grep -e Entry $INDEX_SRC)) 64 ;; 65 handle) 66 INDEX=($(grep -e Handles $INDEX_SRC)) 67 ;; 68 misc) 69 INDEX=($(grep -e Lines -e Others -e ProgressBar -e Shadows -e Toolbar \ 70 $INDEX_SRC)) 71 ;; 72 range) 73 INDEX=($(grep -e Range $INDEX_SRC)) 74 ;; 75 scrollbar) 76 INDEX=($(grep -e Scrollbars $INDEX_SRC)) 77 ;; 78 spin) 79 INDEX=($(grep -e Spin $INDEX_SRC)) 80 ;; 81 all) 82 INDEX=$(<$INDEX_SRC) 83 ;; 84 *) 85 exit 1 86 ;; 87esac 88 89for i in ${INDEX[@]} 90do 91 SUB_DIR=`echo $i | cut -f1 -d '/'` 92 if [ '!' -d $ASSETS_DIR/$SUB_DIR ]; then 93 mkdir -p $ASSETS_DIR/$SUB_DIR; 94 fi 95 96 if [ -f $ASSETS_DIR/$i.png ] && [ $KEY_FILE -ot $ASSETS_DIR/$i.png ]; then 97 echo $ASSETS_DIR/$i.png exists. 98 elif [ -f $ASSETS_DIR/$i.png ] && [ $KEY_FILE -nt $ASSETS_DIR/$i.png ]; then 99 echo Re-rendering $ASSETS_DIR/$i.png 100 echo $i.png >>../inkscape.log 101 rm -f $ASSETS_DIR/$i.png 102 render-non-scale 103 else 104 echo Rendering $ASSETS_DIR/$i.png 105 echo $i.png >>../inkscape.log 106 render-non-scale 107 fi 108done 109 110exit 0 111