From: javiplx Date: Fri, 6 May 2011 11:37:48 +0000 (+0000) Subject: REFACTORING : reorganize code to relegate the method to set the label of the zoom... X-Git-Tag: hildon-wrapped~32 X-Git-Url: http://vcs.maemo.org/git/?p=wifihood;a=commitdiff_plain;h=4f44e9a0570ff3c70e7c02596a6bc614f98dd23e REFACTORING : reorganize code to relegate the method to set the label of the zoom button git-svn-id: file:///svnroot/wifihood/trunk@120 c51dfc6a-5949-4919-9c8e-f207a149c383 --- diff --git a/wifiscanner/wifimap/config.py b/wifiscanner/wifimap/config.py index 88cde96..f7caad9 100644 --- a/wifiscanner/wifimap/config.py +++ b/wifiscanner/wifimap/config.py @@ -40,7 +40,7 @@ class Configuration : class AbstractSettingsWindow : - def __init__ ( self , config , handler=None ) : + def __init__ ( self , config , handler ) : self.set_title( "Wifihood Settings" ) scrollwin = self.MainArea() @@ -136,8 +136,9 @@ if hildon : class ZoomDialog ( hildon.TouchSelector ) : - def __init__ ( self , config , handler=None , extra=None ) : + def __init__ ( self , config , handler ) : hildon.TouchSelector.__init__( self ) + self.handler = handler zooms = gtk.ListStore(str) @@ -154,21 +155,23 @@ if hildon : # 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.zoom = newzoom + class SettingsWindow ( hildon.StackableWindow , AbstractSettingsWindow ) : def __init__ ( self , config , handler=None ) : 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 ) + 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", self.zoomdialog , button , config , handler ) + button.connect_object( "value-changed", selector.zoomdialog , button , config ) return button def MainArea ( self ) : @@ -187,7 +190,7 @@ else : class ZoomDialog ( gtk.Dialog ) : - def __init__ ( self , config , handler=None , extra=None ) : + def __init__ ( self , config , handler , labelsetter=None ) : gtk.Dialog.__init__( self , "Select zoom level", None, gtk.DIALOG_MODAL, @@ -211,15 +214,16 @@ else : self.vbox.pack_start(combo , True, True, 0) - self.connect_object( "response", self.response , combo , config , handler , extra ) + self.connect_object( "response", self.response , combo , config , handler , labelsetter ) - def response ( self , combo , response , config , handler , extra=None ) : + def response ( self , combo , response , config , handler , labelsetter ) : if response == gtk.RESPONSE_ACCEPT : item = combo.get_active_iter() model = combo.get_model() - handler( model.get(item,0)[0]) - if extra : extra( model.get(item,0)[0]) - config.zoom = model.get(item,0)[0] + newzoom = model.get(item,0)[0] + if labelsetter : labelsetter( newzoom ) + if handler : handler( newzoom ) + config.zoom = newzoom self.destroy() class SettingsWindow ( gtk.Window , AbstractSettingsWindow ) : @@ -240,8 +244,8 @@ else : def Button ( self , label=None ) : return gtk.Button( label ) - def zoomdialog ( self , widget , config , extra ) : - dialog = ZoomDialog( config , widget.set_value , extra ) + def zoomdialog ( self , widget , config , handler ) : + dialog = ZoomDialog( config , handler , widget.set_value ) dialog.show_all() def ZoomButton ( self , text , config , handler ) :