Removed hildon conditionals from configuration module
authorjaviplx <javiplx@gmail.com>
Sat, 7 May 2011 03:00:31 +0000 (03:00 +0000)
committerjaviplx <javiplx@gmail.com>
Sat, 7 May 2011 03:00:31 +0000 (03:00 +0000)
git-svn-id: file:///svnroot/wifihood/branches/hildon-wrapping@126 c51dfc6a-5949-4919-9c8e-f207a149c383

hildongtk.py
wifimap/config.py

index 2ba0e1a..ab987d6 100644 (file)
@@ -7,6 +7,10 @@ gtk.HILDON_SIZE_AUTO = -1
 BUTTON_ARRANGEMENT_VERTICAL = -1
 
 
+class StackableWindow ( gtk.Window ) :
+    def __init__ ( self ) :
+        gtk.Window.__init__( self )
+
 class PannableArea ( gtk.ScrolledWindow ) :
     def __init__ ( self ) :
         gtk.ScrolledWindow.__init__( self )
@@ -34,6 +38,7 @@ class CheckButton ( gtk.CheckButton ) :
     def __init__ ( self , height ) :
         gtk.CheckButton.__init__( self )
 
+# FIXME : Add value-changed signal, with the response signal from the Dialog
 class PickerButton ( gtk.Button ) :
     def __init__ ( self , height , arrangement ) : # , text=None , value=None ) :
         gtk.Button.__init__( self )
@@ -54,17 +59,6 @@ class PickerButton ( gtk.Button ) :
         self.connect_object( "clicked", self._selector.muestra , self._selector )
         self._build_label()
 
-#def hildon_ZoomButton ( self , text , config , handler ) :
-#    selector = ZoomDialog( config , handler )
-#    button = hildon.PickerButton( gtk.HILDON_SIZE_AUTO, hildon.BUTTON_ARRANGEMENT_VERTICAL)
-#    button.set_title( text )
-#    button.set_selector( selector )
-#    return button
-
-#def ported_ZoomButton ( self , text , config , handler ) :
-#    button = PickerButton( text , config.zoom )
-#    return button
-
 class TouchSelector ( gtk.Dialog ) :
 
     def __init__ ( self ) :
@@ -97,17 +91,9 @@ class TouchSelector ( gtk.Dialog ) :
     def muestra ( self , widget ) :
         self.show_all()
 
-## O nos sirve el active como indice, o tendremos que transformar el indice en un iterador
-## # ... iter = self.combo.get( active )
-##        combo.set_active_iter( iter )
-#
-##    def response ( self , combo , response  , config , handler , labelsetter ) :
-##        if response == gtk.RESPONSE_ACCEPT :
-##            item = combo.get_active_iter()
-##            model = combo.get_model()
-##            newzoom = model.get(item,0)[0]
-##            if labelsetter : labelsetter( newzoom )
-##            if handler : handler( newzoom )
-##            config.set_zoom( newzoom )
-##        self.destroy()
-#
+    def response ( self , widget , response , config ) :
+        if response == gtk.RESPONSE_ACCEPT :
+            self.zoomdialog( widget , config )
+            widget._build_label()
+        self.hide()
+
index 0f3b99a..e51f3bd 100644 (file)
@@ -135,51 +135,7 @@ class AbstractSettingsWindow :
 
         self.show()
 
-if hildon :
-
-  class ZoomDialog ( hildon.TouchSelector ) :
-
-    def __init__ ( self , config , handler ) :
-        hildon.TouchSelector.__init__( self )
-        self.handler = handler
-
-        zooms = gtk.ListStore(str)
-
-        active = index = 0
-        for zoom in range(8,19) :
-            iter = zooms.append()
-            zooms.set( iter , 0 , "%2d" % zoom )
-            if zoom == config.zoom :
-                active = index
-            index += 1
-
-        column = self.append_text_column( zooms , True )
-
-        # NOTE : with text=True, we must use 1 instead of 0
-        self.set_active( 0 , active )
-
-    def zoomdialog ( self , widget , conf ) :
-        newzoom = int( widget.get_selector().get_current_text() )
-        if self.handler : self.handler( newzoom )
-        conf.set_zoom( newzoom )
-
-  class SettingsWindow ( hildon.StackableWindow , AbstractSettingsWindow ) :
-
-    def __init__ ( self , config , handler=None ) :
-        hildon.StackableWindow.__init__( self )
-        AbstractSettingsWindow.__init__( self , config , handler )
-
-    def ZoomButton ( self , text , config , handler ) :
-        selector = ZoomDialog( config , handler )
-        button = hildon.PickerButton( gtk.HILDON_SIZE_AUTO, hildon.BUTTON_ARRANGEMENT_VERTICAL)
-        button.set_title( text )
-        button.set_selector( selector )
-        button.connect_object( "value-changed", selector.zoomdialog , button , config )
-        return button
-
-else :
-
-  class ZoomDialog ( hildongtk.TouchSelector ) :
+class ZoomDialog ( hildongtk.TouchSelector ) :
 
     def __init__ ( self , config , handler ) :
         hildongtk.TouchSelector.__init__( self )
@@ -190,6 +146,7 @@ else :
         active = index = 0
         for zoom in range(8,19) :
             iter = zooms.append()
+#            zooms.set( iter , 0 , "%2d" % zoom )
             zooms.set( iter , 0 , zoom )
             if zoom == config.zoom :
                 active = index
@@ -205,16 +162,10 @@ else :
         if self.handler : self.handler( newzoom )
         conf.set_zoom( newzoom )
 
-    def response ( self , widget , response , config ) :
-        if response == gtk.RESPONSE_ACCEPT :
-            self.zoomdialog( widget , config )
-            widget._build_label()
-        self.hide()
-
-  class SettingsWindow ( gtk.Window , AbstractSettingsWindow ) :
+class SettingsWindow ( hildongtk.StackableWindow , AbstractSettingsWindow ) :
 
     def __init__ ( self , config , handler=None ) :
-        gtk.Window.__init__( self )
+        hildongtk.StackableWindow.__init__( self )
         AbstractSettingsWindow.__init__( self , config , handler )
 
     def ZoomButton ( self , text , config , handler ) :
@@ -223,7 +174,6 @@ else :
         button.set_title( text )
         button.set_selector( selector )
 #        button.connect_object( "value-changed", selector.zoomdialog , button , config )
-# event does not exists !!!
         selector.connect_object( "response", selector.response , button , config )
         return button