Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk-generate-icon.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2368 by niro, Tue Aug 25 10:27:22 2015 UTC revision 2369 by niro, Wed Aug 26 11:03:13 2015 UTC
# Line 17  die() { echo "ERROR: $@"; exit 1; } Line 17  die() { echo "ERROR: $@"; exit 1; }
17  for i in $*  for i in $*
18  do  do
19   case $1 in   case $1 in
20     --add|--del|--print) method="${1//--}" ;;
21   --resource|-r) shift; icon_resource="$1" ;;   --resource|-r) shift; icon_resource="$1" ;;
22   --name|-n) shift; argv_name="$1" ;;   --name|-n) shift; argv_name="$1" ;;
23   --command|-c) shift; argv_command="$1" ;;   --command|-c) shift; argv_command="$1" ;;
# Line 32  do Line 33  do
33  done  done
34    
35  # some sanity checks:  # some sanity checks:
36    [[ -z ${method} ]] && die "No method given"
37    
38  if [[ -n ${icon_resource} ]]  case "${method}" in
39  then   add)
40   [[ -f ${icon_resource} ]] || die "Icon resource '${icon_resource}' does not exist"   if [[ -n ${icon_resource} ]]
41  else   then
42   name="${argv_name}"   [[ -f ${icon_resource} ]] || die "Icon resource '${icon_resource}' does not exist"
43   command="${argv_command}"   else
44   filename="${argv_filename}"   name="${argv_name}"
45   xres="${argv_xres}"   command="${argv_command}"
46   yres="${argv_yres}"   filename="${argv_filename}"
47   icon="${argv_icon}"   xres="${argv_xres}"
48   deficon="${argv_deficon}"   yres="${argv_yres}"
49   iwidth="${argv_iwidth}"   icon="${argv_icon}"
50   iheight="${argv_iheight}"   deficon="${argv_deficon}"
51     iwidth="${argv_iwidth}"
52   # abort if name or command not given   iheight="${argv_iheight}"
53   [[ -z ${name} ]] && die "No name given"  
54   [[ -z ${command} ]] && die "No command given"   # abort if name or command not given
55     [[ -z ${name} ]] && die "No name given"
56   [[ -z ${filename} ]] && filename="${name}"   [[ -z ${command} ]] && die "No command given"
57    
58   # use some defaults for icon, dest, {x,y}res   [[ -z ${filename} ]] && filename="${name}"
59   [[ -z ${xres} ]] && xres=50  
60   [[ -z ${yres} ]] && yres=50   # use some defaults for icon, dest, {x,y}res
61   if [[ -z ${icon} ]]   [[ -z ${xres} ]] && xres=50
62   then   [[ -z ${yres} ]] && yres=50
63   # if no default icon is given use default.png   if [[ -z ${icon} ]]
64   [[ -z ${deficon} ]] && deficon="default.png"   then
65   icon="${deficon}"   # if no default icon is given use default.png
66   fi   [[ -z ${deficon} ]] && deficon="default.png"
67     icon="${deficon}"
68   ${MCORE_LIBDIR}/idesk-generate-icon-info \   fi
69   --name "${name}" \  
70   --command "${command}" \   ${MCORE_LIBDIR}/idesk-generate-icon-info \
71   --icon "${icon}" \   --add \
72   --filename "${filename}" \   --name "${name}" \
73   --xres "${xres}" \   --command "${command}" \
74   --yres "${yres}" \   --icon "${icon}" \
75   --icon-width "${iwidth}" \   --filename "${filename}" \
76   --icon-height "${iheight}" \   --xres "${xres}" \
77   --default-icon "${deficon}"   --yres "${yres}" \
78     --icon-width "${iwidth}" \
79   icon_resource="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}"   --icon-height "${iheight}" \
80  fi   --default-icon "${deficon}" \
81     || die "adding icon-info"
82  source "${icon_resource}"  
83     icon_resource="${ICON_INFO_PATH}/${filename}.${ICON_INFO_SUFFIX}"
84  # icon resource overrides   fi
85  [[ -n ${argv_name} ]] && name="${argv_name}"  
86  [[ -n ${argv_command} ]] && command="${argv_command}"   source "${icon_resource}"
87  [[ -n ${argv_filename} ]] && filename="${argv_filename}"  
88  [[ -n ${argv_xres} ]] && xres="${argv_xres}"   # icon resource overrides
89  [[ -n ${argv_yres} ]] && yres="${argv_yres}"   [[ -n ${argv_name} ]] && name="${argv_name}"
90  [[ -n ${argv_icon} ]] && icon="${argv_icon}"   [[ -n ${argv_command} ]] && command="${argv_command}"
91  [[ -n ${argv_deficon} ]] && deficon="${argv_deficon}"   [[ -n ${argv_filename} ]] && filename="${argv_filename}"
92  [[ -n ${argv_iwidth} ]] && iwidth="${argv_iwidth}"   [[ -n ${argv_xres} ]] && xres="${argv_xres}"
93  [[ -n ${argv_iheight} ]] && iheight="${argv_iheight}"   [[ -n ${argv_yres} ]] && yres="${argv_yres}"
94     [[ -n ${argv_icon} ]] && icon="${argv_icon}"
95  [[ -z ${filename} ]] && die "Error \$filename is empty in icon resource '${icon_resource}'"   [[ -n ${argv_deficon} ]] && deficon="${argv_deficon}"
96     [[ -n ${argv_iwidth} ]] && iwidth="${argv_iwidth}"
97  # get the right icon path, local overrides global   [[ -n ${argv_iheight} ]] && iheight="${argv_iheight}"
98  [[ -f ${GLOBAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${GLOBAL_PIXMAPS_PATH}"  
99  [[ -f ${LOCAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${LOCAL_PIXMAPS_PATH}"   [[ -z ${filename} ]] && die "Error \$filename is empty in icon resource '${icon_resource}'"
100  # no icon found, use default icon  
101  if [[ -z ${icon_path} ]]   # get the right icon path, local overrides global
102  then   [[ -f ${GLOBAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${GLOBAL_PIXMAPS_PATH}"
103   icon_path="${GLOBAL_PIXMAPS_PATH}"   [[ -f ${LOCAL_PIXMAPS_PATH}/${icon} ]] && icon_path="${LOCAL_PIXMAPS_PATH}"
104   icon="default.png"   # no icon found, use default icon
105  fi   if [[ -z ${icon_path} ]]
106     then
107  CONFIG="${MCORE_UNPRIV_HOME}/.idesktop/${filename}.${ICON_SUFFIX}"   icon_path="${GLOBAL_PIXMAPS_PATH}"
108  clearconfig   icon="default.png"
109     fi
110  addconfig 'table Icon'  
111  addconfig "  Caption: ${name}"   CONFIG="${MCORE_UNPRIV_HOME}/.idesktop/${filename}.${ICON_SUFFIX}"
112  addconfig "  Command: ${command}"   clearconfig
113  addconfig "  Icon: ${icon_path}/${icon}"  
114  addconfig "  X: ${xres}"   addconfig 'table Icon'
115  addconfig "  Y: ${yres}"   addconfig "  Caption: ${name}"
116     addconfig "  Command: ${command}"
117  # add these only if not zero   addconfig "  Icon: ${icon_path}/${icon}"
118  if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]   addconfig "  X: ${xres}"
119  then   addconfig "  Y: ${yres}"
120   addconfig "  Width: ${iwidth}"  
121   addconfig "  Height: ${iheight}"   # add these only if not zero
122  fi   if [[ ! -z ${iwidth} ]] && [[ ! -z ${iheight} ]]
123     then
124  addconfig 'end'   addconfig "  Width: ${iwidth}"
125     addconfig "  Height: ${iheight}"
126     fi
127    
128     addconfig 'end'
129     ;;
130    
131     del)
132     if [[ -n ${icon_resource} ]]
133     then
134     [[ -f ${icon_resource} ]] || die "Icon resource '${icon_resource}' does not exist"
135     source "${icon_resource}"
136     fi
137     ${MCORE_LIBDIR}/idesk-generate-icon-info --del --name "${name}" --filename "${filename}" || die "deleting icon info"
138     if [[ -f ${MCORE_UNPRIV_HOME}/.idesktop/${filename}.${ICON_SUFFIX} ]]
139     then
140     rm ${MCORE_UNPRIV_HOME}/.idesktop/${filename}.${ICON_SUFFIX}
141     fi
142     ;;
143    
144     print)
145     ${MCORE_LIBDIR}/idesk-generate-icon-info --print
146     ;;
147    esac

Legend:
Removed from v.2368  
changed lines
  Added in v.2369