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):
70 def setSize(self, sz):
79 def getIconSize(self):
82 def setIndiv(self, indiv):
88 def setLongpress(self, lp):
91 def getLongpress(self):
92 return(self.longpress)
94 def setApps(self, aps):
95 """ apps is a dictionary of (x,y)=>appname """
101 (0,0): 'rtcom-call-ui',
102 (0,1): 'rtcom-messaging-ui',
104 (1,1): 'osso-addressbook',
121 dt['data'][self.id]={
122 'size': self.getSize(),
123 'apps': self.getApps(),
124 'indiv': self.getIndiv(),
125 'longpress': self.getLongpress(),
135 def parse_v1(self, dt0):
136 """ Convert a v1 config to v2 """
142 ret['data'][self.id]={
149 def parse_v2(self, dt):
155 dt['data'][i]['indiv']=False
156 dt['data'][i]['size']=(dt['data'][i]['size'], dt['data'][i]['size'])
157 dt['data'][i]['longpress']=True
173 if ret['version']==1:
176 if ret['version']==2:
190 if dt0==None or not dt0['data'].has_key(self.id):
193 dt=dt0['data'][self.id]
195 self.setSize(dt['size'])
196 self.setApps(dt['apps'])
197 self.setIndiv(dt['indiv'])
198 self.setLongpress(dt['longpress'])
200 def check_init(self):
204 print "config.init() not done"
207 # vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: