From: javiplx Date: Sat, 7 May 2011 22:09:24 +0000 (+0000) Subject: First implementation of persistent setting changes X-Git-Tag: hildon-wrapped~27 X-Git-Url: http://vcs.maemo.org/git/?p=wifihood;a=commitdiff_plain;h=9f902636e9348afeaf954975b95e4928418d2b2f First implementation of persistent setting changes git-svn-id: file:///svnroot/wifihood/trunk@137 c51dfc6a-5949-4919-9c8e-f207a149c383 --- diff --git a/wifiscanner/wifimap/config.py b/wifiscanner/wifimap/config.py index deeb098..5b60f14 100644 --- a/wifiscanner/wifimap/config.py +++ b/wifiscanner/wifimap/config.py @@ -12,17 +12,34 @@ class Configuration : def __init__ ( self , type ) : self._type = type self._client = gconf.client_get_default() + self.homedir = self._client.get_string( "/apps/wifihood/basedir" ) or "/home/user/MyDocs" - self.homedir = "/tmp" self.dbname = self._client.get_string( "/apps/wifihood/dbname" ) or "wifiscanner.db" self.mapsdir = self._client.get_string( "/apps/wifihood/maps" ) or "/home/user/MyDocs/.maps" self.mapclass = self._client.get_string( "/apps/wifihood/maptype" ) or "OpenStreetMap I" - self.lat = self._client.get_float( "/apps/wifihood/latitude" ) or self._client.get_float( "/apps/maemo/maemo-mapper/center_latitude" ) or 40.416 - self.lon = self._client.get_float( "/apps/wifihood/longitude" ) or self._client.get_float( "/apps/maemo/maemo-mapper/center_longitude" ) or -3.683 - if self._type == 'map' : - self.zoom = self._client.get_int( "/apps/wifihood/map-zoom" ) or self._client.get_float( "/apps/maemo/maemo-mapper/zoom" ) or 15 + + self.store_log = self._client.get_bool( "/apps/wifihood/store-logfile" ) + + self.use_mapper = self._client.get_bool( "/apps/wifihood/use-mapper" ) + self.store_gps = self._client.get_bool( "/apps/wifihood/store-gps" ) + if self.use_mapper : + # FIXME : This will reset the stored default + self.store_gps = False + self.lat = self._client.get_float( "/apps/maemo/maemo-mapper/center_latitude" ) + self.lon = self._client.get_float( "/apps/maemo/maemo-mapper/center_longitude" ) + self.zoom = self._client.get_int( "/apps/maemo/maemo-mapper/zoom" ) else : - self.zoom = self._client.get_int( "/apps/wifihood/%s-zoom" % self._type ) or 16 + self.lat = self._client.get_float( "/apps/wifihood/latitude" ) + self.lon = self._client.get_float( "/apps/wifihood/longitude" ) + self.zoom = self._client.get_int( "/apps/wifihood/map-zoom" ) + + if self._type == 'scanner' : + self.zoom = self._client.get_int( "/apps/wifihood/%s-zoom" % self._type ) + + if self.lat == 0.0 and self.lon == 0.0 : + self.lat , self.lon = 40.416 , -3.683 + if self.zoom == 0 : + self.zoom = 15 def set_latlon ( self , ( lat , lon ) ) : self._client.set_float( "/apps/wifihood/latitude" , lat ) @@ -68,6 +85,7 @@ class AbstractSettingsWindow : database.attach(dblabel, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5) dbvalue = self.Entry() + dbvalue.connect( "changed" , self.entry_cb , config , "basedir" ) dbvalue.set_text( config.homedir ) dbvalue.show() database.attach(dbvalue, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5) @@ -77,6 +95,7 @@ class AbstractSettingsWindow : database.attach(dblabel, 0, 1, 1, 2, gtk.EXPAND|gtk.FILL, 0, 0, 5) dbvalue = self.Entry() + dbvalue.connect( "changed" , self.entry_cb , config , "dbname" ) dbvalue.set_text( config.dbname ) dbvalue.show() database.attach(dbvalue, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, 0, 0, 5) @@ -113,11 +132,15 @@ class AbstractSettingsWindow : button = self.CheckButton() button.set_label( "Take initial coordinates from maemo-mapper" ) + button.connect( "toggled" , self.checkbutton_cb , config , "use-mapper" ) + button.set_active( config.use_mapper ) button.show() gps.attach(button, 0, 2, 0, 1, gtk.EXPAND|gtk.FILL) #, 0, 0, 5) button = self.CheckButton() button.set_label( "Store changes in coordinates" ) + button.connect( "toggled" , self.checkbutton_cb , config , "store-gps" ) + button.set_active( config.store_gps ) button.show() gps.attach(button, 0, 2, 1, 2, gtk.EXPAND|gtk.FILL) #, 0, 0, 5) @@ -129,11 +152,19 @@ class AbstractSettingsWindow : button = self.CheckButton() button.set_label( "Write full logfile" ) + button.connect( "toggled" , self.checkbutton_cb , config , "store-logfile" ) + button.set_active( config.store_log ) button.show() dataframe.add(button) self.show() + def entry_cb ( self , entry , config , keyword ) : + config._client.set_string( "%s/%s" % ( "/apps/wifihood" , keyword ) , entry.get_text() ) + + def checkbutton_cb ( self , button , config , keyword ) : + config._client.set_bool( "%s/%s" % ( "/apps/wifihood" , keyword ) , button.get_active() ) + if hildon : class ZoomDialog ( hildon.TouchSelector ) :