Extend zoomlevel settings to hildon framework
[wifihood] / wifiscanner / wifimap / config.py
index 2d18a74..88cde96 100644 (file)
@@ -95,8 +95,7 @@ class AbstractSettingsWindow :
         button.show()
         maps.attach(button, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
-        zoomlevel = self.Button( "Zoom level" , config.zoom )
-        zoomlevel.connect_object( "clicked", self.zoomdialog, zoomlevel , config , handler )
+        zoomlevel = self.ZoomButton( "Zoom level" , config , handler )
         zoomlevel.show()
         maps.attach(zoomlevel, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
 
@@ -133,10 +132,6 @@ class AbstractSettingsWindow :
 
         self.show()
 
-    def zoomdialog ( self , widget , config , extra=None ) :
-        dialog = ZoomDialog( config , widget.set_value , extra )
-        dialog.show_all()
-
 if hildon :
 
   class ZoomDialog ( hildon.TouchSelector ) :
@@ -165,6 +160,17 @@ if hildon :
         hildon.StackableWindow.__init__( self )
         AbstractSettingsWindow.__init__( self , config , handler )
 
+    def zoomdialog ( self , widget , conf , extra=None ) :
+        conf.zoom = int( widget.get_selector().get_current_text() )
+
+    def ZoomButton ( self , text , config , handler ) :
+        selector = ZoomDialog( config )
+        button = hildon.PickerButton( gtk.HILDON_SIZE_AUTO, hildon.BUTTON_ARRANGEMENT_VERTICAL)
+        button.set_title( text )
+        button.set_selector( selector )
+        button.connect_object( "value-changed", self.zoomdialog , button , config , handler )
+        return button
+
     def MainArea ( self ) :
         return hildon.PannableArea()
 
@@ -231,7 +237,14 @@ else :
     def Entry ( self ) :
         return gtk.Entry()
 
-    def Button ( self , text , value ) :
+    def Button ( self , label=None ) :
+        return gtk.Button( label )
+
+    def zoomdialog ( self , widget , config , extra ) :
+        dialog = ZoomDialog( config , widget.set_value , extra )
+        dialog.show_all()
+
+    def ZoomButton ( self , text , config , handler ) :
         class _button ( gtk.Button ) :
             def __init__ ( self , text , value ) :
                 gtk.Button.__init__( self )
@@ -240,7 +253,9 @@ else :
             def set_value ( self , value ) :
                 self._value = value
                 self.set_label( "%s -- %s" % ( self._text , self._value ) )
-        return _button( text , value )
+        button = _button( text , config.zoom )
+        button.connect_object( "clicked", self.zoomdialog , button , config , handler )
+        return button
 
     def CheckButton ( self ) :
         return gtk.CheckButton()