BUGFIX : reintroduce the fixes from commits 168 & 169, lost in the hildon-wrapper...
[wifihood] / wifiscanner / wifimap / config.py
index dfff47f..d5067c8 100644 (file)
@@ -57,7 +57,7 @@ class Configuration :
             client.set_int( "/apps/wifihood/%s-zoom" % self._type , zoom )
         self.zoom = zoom
 
-    def save ( self , widget=None ) :
+    def save ( self , widget=None , event=None ) :
         """Saves all the editable configuration elements"""
 
         client = gconf.client_get_default()
@@ -78,6 +78,8 @@ class SettingsWindow ( hildon.StackableWindow ) :
         hildon.StackableWindow.__init__( self )
         self.set_title( "Wifihood Settings" )
 
+        self.connect_object("delete_event", config.save , self )
+
         scrollwin = hildon.PannableArea()
         scrollwin.show()
         self.add(scrollwin)
@@ -88,7 +90,6 @@ class SettingsWindow ( hildon.StackableWindow ) :
 
         self.add_dataframe( vbox , config )
         self.add_mapsframe( vbox , config , handler )
-        self.add_coordsframe( vbox , config )
         self.add_dbframe( vbox , config )
 
         self.show()
@@ -110,7 +111,7 @@ class SettingsWindow ( hildon.StackableWindow ) :
         dbframe.show()
         vbox.pack_start(dbframe, True, True, 0)
 
-        database = gtk.Table(2, 2, False)
+        database = gtk.Table(4, 1, False)
         database.show()
         dbframe.add(database)
 
@@ -119,25 +120,27 @@ class SettingsWindow ( hildon.StackableWindow ) :
         database.attach(dblabel, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
         dbvalue = hildon.Entry( gtk.HILDON_SIZE_FINGER_HEIGHT )
-        dbvalue.connect( "changed" , self.entry_cb , config , "basedir" )
+        dbvalue.set_width_chars(15)
+        dbvalue.connect( "changed" , self.entry_cb , config , "homedir" )
         dbvalue.set_text( config.homedir )
         dbvalue.show()
         database.attach(dbvalue, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
         dblabel = gtk.Label( "Database name" )
         dblabel.show()
-        database.attach(dblabel, 0, 1, 1, 2, gtk.EXPAND|gtk.FILL, 0, 0, 5)
+        database.attach(dblabel, 2, 3, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
         dbvalue = hildon.Entry( gtk.HILDON_SIZE_FINGER_HEIGHT )
+        dbvalue.set_width_chars(12)
         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)
+        database.attach(dbvalue, 3, 4, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
 
     def add_mapsframe ( self , vbox , config , handler ) :
 
-        mapsframe = gtk.Frame( label="Maps" )
+        mapsframe = gtk.Frame( label="Maps & Coordinates" )
         mapsframe.set_label_align(0 , 0.1)
         mapsframe.show()
         vbox.pack_start(mapsframe, True, True, 0)
@@ -149,6 +152,7 @@ class SettingsWindow ( hildon.StackableWindow ) :
         button = hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT )
         button.set_label( "Use OpenStreet maps" )
         button.set_active( 1 )
+        button.set_sensitive(0)
         button.show()
         maps.attach(button, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
@@ -156,31 +160,19 @@ class SettingsWindow ( hildon.StackableWindow ) :
         zoomlevel.show()
         maps.attach(zoomlevel, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
-
-    def add_coordsframe ( self , vbox , config ) :
-
-        gpsframe = gtk.Frame( label="Coordinates" )
-        gpsframe.set_label_align(0 , 0.1)
-        gpsframe.show()
-        vbox.pack_start(gpsframe, True, True, 0)
-
-        gps = gtk.Table(2, 2, False)
-        gps.show()
-        gpsframe.add(gps)
-
         button = hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT )
-        button.set_label( "Take initial coordinates from maemo-mapper" )
+        button.set_label( "Use maemo-mapper coordinates" )
         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)
+        maps.attach(button, 0, 1, 1, 2, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
         button = hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT )
-        button.set_label( "Store changes in coordinates" )
+        button.set_label( "Store coordinates changes" )
         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)
+        maps.attach(button, 1, 2, 1, 2, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
 
     def add_dataframe ( self , vbox , config ) :
@@ -190,26 +182,27 @@ class SettingsWindow ( hildon.StackableWindow ) :
         dataframe.show()
         vbox.pack_start(dataframe, True, True, 0)
 
-        datatable = gtk.Table(2, 2, False)
+        datatable = gtk.Table(3, 1, False)
         datatable.show()
         dataframe.add(datatable)
 
         scanlabel = gtk.Label( "Scanning interval" )
         scanlabel.show()
-        datatable.attach(scanlabel, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL)
+        datatable.attach(scanlabel, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL)
 
         scanvalue = hildon.Entry( gtk.HILDON_SIZE_FINGER_HEIGHT )
-        scanvalue.connect( "changed" , self.float_cb , config , "scan-period" )
+        scanvalue.set_width_chars(5)
+        scanvalue.connect( "changed" , self.float_cb , config , "scan_period" )
         scanvalue.set_text( "%s" % config.scan_period )
         scanvalue.show()
-        datatable.attach(scanvalue, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL)
+        datatable.attach(scanvalue, 2, 3, 0, 1, gtk.FILL)
 
         button = hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT )
         button.set_label( "Write full logfile" )
         button.connect( "toggled" , self.checkbutton_cb , config , "store_log" )
         button.set_active( config.store_log )
         button.show()
-        datatable.attach(button, 0, 2, 1, 2, gtk.EXPAND|gtk.FILL)
+        datatable.attach(button, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL)
 
     def entry_cb ( self , entry , config , keyword ) :
         config.__dict__[ keyword ] = entry.get_text()