Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/modules/idesk/idesk.control.class.in

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

revision 2543 by niro, Wed Sep 16 10:31:57 2015 UTC revision 2874 by niro, Fri Aug 14 08:43:55 2020 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3  # control_input_keymap $serial  push_config 80_idesk_icon
 control_input_keymap()  
 {  
  local serial="${CLASS_ARGV[0]}"  
  push_config_input_keymap "${serial}"  
 }  
   
 push_config_input_keymap()  
 {  
  local serial="$1"  
  local value  
   
  value=$(mysqldo "select keymap from cfg_input where serial='${serial}'")  
  control_client "${serial}" set input.keymap "${value}"  
 }  
4    
5  help_idesk_icon()  help_idesk_icon()
6  {  {
7   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
8   control_client "${serial}" help idesk.icon   control_client "${serial}" help idesk.icon
   
  mecho "get idesk.icon"  
  mecho " Shows all configured icons."  
  mecho  
  mecho "set idesk.icon [action] [name] [command] [icon] [filename] [x,y] [width,height] [default-icon]"  
  mecho " Adds or deletes an desktop icon."  
  mecho " [actions]:"  
  mecho "   add         - adds an icon"  
  mecho "   del         - deletes an icon"  
  mecho "                 if no [name] given, all desktop icons will be deleted"  
  mecho  
  mecho "   name         - Name of the icon"  
  mecho "   command      - command which will be run"  
  mecho "   icon         - icon pixmap [optional]"  
  mecho "   filename     - filename of the icon [optional]"  
  mecho "   x,y          - x,y position of the icon on the desktop [optional]"  
  mecho "   width,height - width and height of the icon [optional]"  
  mecho "   default-icon - default icon which will be selected if the icon pixmap was not found [optional]"  
9  }  }
10    
11  set_idesk_icon()  set_idesk_icon()
# Line 55  set_idesk_icon() Line 23  set_idesk_icon()
23   local ypos   local ypos
24   local width   local width
25   local height   local height
26   local ids   local id
27     local enabled
28    
29   [[ -z ${action} ]] && help_idesk_icon && return 1   [[ -z ${action} ]] && help_idesk_icon && return 1
30    
# Line 71  set_idesk_icon() Line 40  set_idesk_icon()
40   height="${widthheight#*,}"   height="${widthheight#*,}"
41   fi   fi
42    
  local id  
   
43   case "${action}" in   case "${action}" in
44   add)   add) enabled=1 ;;
45   id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';")   del) enabled=0 ;;
46   if [[ -n ${id} ]]   *)
47   then   eecho "Unknown action '${action}'"
48   mysqldo "update cfg_idesk_icon set name='${name}', command='${command}', icon='${icon}', filename='${filename}', xpos='${xpos}', ypos='${ypos}', width='${width}', height='${height}', default_icon='${default_icon}' where id=${id};"   return 1
  else  
  mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon)  
  values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}');"  
  fi  
  ;;  
  del)  
  if [[ -n ${name} ]]  
  then  
  mysqldo "delete from cfg_idesk_icon where serial='${serial}' and name='${name}';"  
  else  
  mysqldo "delete from cfg_idesk_icon where serial='${serial}';"  
  fi  
49   ;;   ;;
50   esac   esac
51    
52     if [[ -z ${name} ]]
53     then
54     eecho "No name given"
55     return 1
56     fi
57    
58     id=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}' and name='${name}';")
59     if [[ -n ${id} ]]
60     then
61     mysqldo "update cfg_idesk_icon set name='${name}', command='${command}', icon='${icon}', filename='${filename}', xpos='${xpos}', ypos='${ypos}', width='${width}', height='${height}', default_icon='${default_icon}', enabled='${enabled}' where id=${id};"
62     else
63     mysqldo "insert into cfg_idesk_icon(serial, name, command, icon, filename, xpos, ypos, width, height, default_icon, enabled)
64     values('${serial}', '${name}', '${command}', '${icon}', '${filename}', '${xpos}', '${ypos}', '${width}', '${height}', '${default_icon}', '${enabled}');"
65     fi
66  }  }
67    
68  control_idesk_icon()  control_idesk_icon()
69  {  {
70   local serial="${CLASS_ARGV[0]}"   local serial="${CLASS_ARGV[0]}"
71     push_config_80_idesk_icon "${serial}"
72    }
73    
74    push_config_80_idesk_icon()
75    {
76     local serial="$1"
77   local values   local values
78   local id   local id
79     local xypos
80     local widthheight
81    
  # first delete all icons then regen all  
  control_client "${serial}" set idesk.icon del  
82   values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';")   values=$(mysqldo "select id from cfg_idesk_icon where serial='${serial}';")
83   for id in ${values}   for id in ${values}
84   do   do
85   evaluate_table_xml cfg_idesk_icon "where serial='${serial}'"   evaluate_table_xml cfg_idesk_icon "where id='${id}'"
86   if [[ -z ${cfg_idesk_icon_name} ]]   if [[ -z ${cfg_idesk_icon_name} ]]
87   then   then
88   eecho "Name must not be empty id->'${id}'"   eecho "Name must not be empty id->'${id}'"
89   continue   continue
90   fi   fi
91   if [[ -z ${cfg_idesk_icon_command} ]]   if [[ -z ${cfg_idesk_icon_enabled} ]]
92   then   then
93   eecho "Command must not be empty id->'${id}'"   eecho "Enabled must not be empty id->'${id}'"
94   continue   continue
95   fi   fi
96   control_client "${serial}" set idesk.icon add "${cfg_idesk_icon_name}" "${cfg_idesk_icon_command}" "${cfg_idesk_icon_icon}" "${cfg_idesk_icon_filename}" "${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}" "${cfg_idesk_icon_width},${cfg_idesk_icon_height}" "${cfg_idesk_icon_default_icon}"   if [[ ${cfg_idesk_icon_enabled} = 1 ]]
97     then
98     if [[ -n ${cfg_idesk_icon_xpos} ]] && [[ -n ${cfg_idesk_icon_ypos} ]]
99     then
100     xypos="${cfg_idesk_icon_xpos},${cfg_idesk_icon_ypos}"
101     fi
102     if [[ -n ${width} ]] && [[ -n ${height} ]]
103     then
104     widthheight="${cfg_idesk_icon_width},${cfg_idesk_icon_height}"
105     fi
106     control_client "${serial}" set idesk.icon add "${cfg_idesk_icon_name}" "${cfg_idesk_icon_command}" "${cfg_idesk_icon_icon}" "${cfg_idesk_icon_filename}" "${xypos}" "${widthheight}" "${cfg_idesk_icon_default_icon}"
107     elif [[ ${cfg_idesk_icon_enabled} = 0 ]]
108     then
109     control_client "${serial}" set idesk.icon del "${cfg_idesk_icon_name}"
110     # remove from database too
111     mysqldo "delete from cfg_idesk_icon where id='${id}';"
112     else
113     eecho "unknown enabled value id->'${id}', cfg_idesk_icon_enabled -> '${cfg_idesk_icon_enabled}'"
114     return 1
115     fi
116   done   done
117  }  }

Legend:
Removed from v.2543  
changed lines
  Added in v.2874