class AbstractSettingsWindow :
- def __init__ ( self , config ) :
+ def __init__ ( self , config , handler=None ) :
self.set_title( "Wifihood Settings" )
scrollwin = self.MainArea()
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, config )
+ zoomlevel.connect_object( "clicked", self.zoomdialog, zoomlevel , config , handler )
zoomlevel.show()
maps.attach(zoomlevel, 1, 2, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5)
self.show()
- def zoomdialog ( self , widget) :
- dialog = ZoomDialog( widget )
+ def zoomdialog ( self , widget , config , extra=None ) :
+ dialog = ZoomDialog( config , widget.set_value , extra )
dialog.show_all()
if hildon :
class ZoomDialog ( hildon.TouchSelector ) :
- def __init__ ( self , config ) :
+ def __init__ ( self , config , handler=None , extra=None ) :
hildon.TouchSelector.__init__( self )
zooms = gtk.ListStore(str)
class SettingsWindow ( hildon.StackableWindow , AbstractSettingsWindow ) :
- def __init__ ( self , config ) :
+ def __init__ ( self , config , handler=None ) :
hildon.StackableWindow.__init__( self )
- AbstractSettingsWindow.__init__( self , config )
+ AbstractSettingsWindow.__init__( self , config , handler )
def MainArea ( self ) :
return hildon.PannableArea()
class ZoomDialog ( gtk.Dialog ) :
- def __init__ ( self , config ) :
+ def __init__ ( self , config , handler=None , extra=None ) :
gtk.Dialog.__init__( self , "Select zoom level",
None,
gtk.DIALOG_MODAL,
self.vbox.pack_start(combo , True, True, 0)
- self.connect_object( "response", self.response , combo , config )
+ self.connect_object( "response", self.response , combo , config , handler , extra )
- def response ( self , combo , response , config ) :
+ def response ( self , combo , response , config , handler , extra=None ) :
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]
self.destroy()
class SettingsWindow ( gtk.Window , AbstractSettingsWindow ) :
- def __init__ ( self , config ) :
+ def __init__ ( self , config , handler=None ) :
gtk.Window.__init__( self )
- AbstractSettingsWindow.__init__( self , config )
+ AbstractSettingsWindow.__init__( self , config , handler )
def MainArea ( self ) :
scrollwin = gtk.ScrolledWindow()
return gtk.Entry()
def Button ( self , text , value ) :
- return gtk.Button( "%s %s" % ( text , value ) )
+ class _button ( gtk.Button ) :
+ def __init__ ( self , text , value ) :
+ gtk.Button.__init__( self )
+ self._text = text
+ self.set_value( value )
+ def set_value ( self , value ) :
+ self._value = value
+ self.set_label( "%s -- %s" % ( self._text , self._value ) )
+ return _button( text , value )
def CheckButton ( self ) :
return gtk.CheckButton()