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):
64 # self.iconspace = 42 # For 4 icons (height)
65 self.iconspace = 36 # For 8 icons (width)
75 def setSize(self, sz):
84 def getIconSize(self):
87 def setIndiv(self, indiv):
93 def setLongpress(self, lp):
96 def getLongpress(self):
97 return(self.longpress)
99 def setAnimate(self, ar):
102 def getAnimate(self):
105 def setNoBg(self, nobg):
111 def setThemeBg(self, themebg):
114 def getThemeBg(self):
117 def setApps(self, aps):
118 """ apps is a dictionary of (x,y)=>appname """
124 (0,0): 'rtcom-call-ui',
125 (0,1): 'rtcom-messaging-ui',
127 (1,1): 'osso-addressbook',
144 dt['data'][self.id]={
145 'size': self.getSize(),
146 'apps': self.getApps(),
147 'indiv': self.getIndiv(),
148 'longpress': self.getLongpress(),
149 'animate': self.getAnimate(),
150 'nobg': self.getNoBg(),
151 'themebg': self.getThemeBg(),
161 def parse_v1(self, dt0):
162 """ Convert a v1 config to v2 """
168 ret['data'][self.id]={
175 def parse_v2(self, dt):
181 dt['data'][i]['indiv']=False
182 dt['data'][i]['size']=(dt['data'][i]['size'], dt['data'][i]['size'])
183 dt['data'][i]['longpress']=True
187 def parse_v3(self, dt):
191 dt['data'][i]['animate']=True
195 def parse_v4(self, dt):
199 dt['data'][i]['nobg']=False
203 def parse_v5(self, dt):
207 dt['data'][i]['themebg']=False
223 if ret['version']==1:
226 if ret['version']==2:
229 if ret['version']==3:
232 if ret['version']==4:
235 if ret['version']==5:
249 if dt0==None or not dt0['data'].has_key(self.id):
252 dt=dt0['data'][self.id]
254 self.setSize(dt['size'])
255 self.setApps(dt['apps'])
256 self.setIndiv(dt['indiv'])
257 self.setLongpress(dt['longpress'])
258 self.setAnimate(dt['animate'])
259 self.setNoBg(dt['nobg'])
260 self.setThemeBg(dt['themebg'])
262 def check_init(self):
266 print "config.init() not done"
269 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: