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)
72 def setSize(self, sz):
81 def getIconSize(self):
84 def setIndiv(self, indiv):
90 def setLongpress(self, lp):
93 def getLongpress(self):
94 return(self.longpress)
96 def setAnimate(self, ar):
102 def setApps(self, aps):
103 """ apps is a dictionary of (x,y)=>appname """
109 (0,0): 'rtcom-call-ui',
110 (0,1): 'rtcom-messaging-ui',
112 (1,1): 'osso-addressbook',
129 dt['data'][self.id]={
130 'size': self.getSize(),
131 'apps': self.getApps(),
132 'indiv': self.getIndiv(),
133 'longpress': self.getLongpress(),
134 'animate': self.getAnimate(),
144 def parse_v1(self, dt0):
145 """ Convert a v1 config to v2 """
151 ret['data'][self.id]={
158 def parse_v2(self, dt):
164 dt['data'][i]['indiv']=False
165 dt['data'][i]['size']=(dt['data'][i]['size'], dt['data'][i]['size'])
166 dt['data'][i]['longpress']=True
170 def parse_v3(self, dt):
174 dt['data'][i]['animate']=True
190 if ret['version']==1:
193 if ret['version']==2:
196 if ret['version']==3:
210 if dt0==None or not dt0['data'].has_key(self.id):
213 dt=dt0['data'][self.id]
215 self.setSize(dt['size'])
216 self.setApps(dt['apps'])
217 self.setIndiv(dt['indiv'])
218 self.setLongpress(dt['longpress'])
219 self.setAnimate(dt['animate'])
221 def check_init(self):
225 print "config.init() not done"
228 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: