4 # Copyright (C) 2010 Stefanos Harhalakis
6 # This file is part of wifieye.
8 # wifieye is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # wifieye is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with wifieye. If not, see <http://www.gnu.org/licenses/>.
21 # $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
23 __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
31 from glib import get_user_config_dir
33 def get_user_config_dir():
34 home=os.environ['HOME']
37 cfg="%s/.config" % (home)
42 dir0=get_user_config_dir()
44 if not os.path.exists(dir):
46 if not os.path.isdir(dir):
47 raise Exception('Failed to ensure directory' + dir)
58 def __init__(self, id):
63 # self.iconspace = 42 # For 4 icons (height)
64 self.iconspace = 36 # For 8 icons (width)
73 def setSize(self, sz):
82 def getIconSize(self):
85 def setIndiv(self, indiv):
91 def setLongpress(self, lp):
94 def getLongpress(self):
95 return(self.longpress)
97 def setAnimate(self, ar):
100 def getAnimate(self):
103 def setNoBg(self, nobg):
109 def setApps(self, aps):
110 """ apps is a dictionary of (x,y)=>appname """
116 (0,0): 'rtcom-call-ui',
117 (0,1): 'rtcom-messaging-ui',
119 (1,1): 'osso-addressbook',
136 dt['data'][self.id]={
137 'size': self.getSize(),
138 'apps': self.getApps(),
139 'indiv': self.getIndiv(),
140 'longpress': self.getLongpress(),
141 'animate': self.getAnimate(),
142 'nobg': self.getNoBg(),
152 def parse_v1(self, dt0):
153 """ Convert a v1 config to v2 """
159 ret['data'][self.id]={
166 def parse_v2(self, dt):
172 dt['data'][i]['indiv']=False
173 dt['data'][i]['size']=(dt['data'][i]['size'], dt['data'][i]['size'])
174 dt['data'][i]['longpress']=True
178 def parse_v3(self, dt):
182 dt['data'][i]['animate']=True
186 def parse_v4(self, dt):
190 dt['data'][i]['nobg']=False
206 if ret['version']==1:
209 if ret['version']==2:
212 if ret['version']==3:
215 if ret['version']==4:
229 if dt0==None or not dt0['data'].has_key(self.id):
232 dt=dt0['data'][self.id]
234 self.setSize(dt['size'])
235 self.setApps(dt['apps'])
236 self.setIndiv(dt['indiv'])
237 self.setLongpress(dt['longpress'])
238 self.setAnimate(dt['animate'])
239 self.setNoBg(dt['nobg'])
241 def check_init(self):
245 print "config.init() not done"
248 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: