From 6651932f3f30e561377b96263fe16b0e65468c40 Mon Sep 17 00:00:00 2001 From: javiplx Date: Sat, 14 May 2011 21:03:38 +0000 Subject: [PATCH] Initial implementation of the new hildon wrappers git-svn-id: file:///svnroot/wifihood/trunk@179 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscanner/hildongtk/hildon.py | 2 +- wifiscanner/wifimap/config.py | 141 +++++++-------------------------------- wifiscanner/wifimap/gps.py | 5 +- wifiscanner/wifimap/scanner.py | 2 +- wifiscanner/wifimap/wifiscan.py | 2 +- 5 files changed, 30 insertions(+), 122 deletions(-) create mode 100644 wifiscanner/hildongtk/__init__.py diff --git a/wifiscanner/hildongtk/__init__.py b/wifiscanner/hildongtk/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wifiscanner/hildongtk/hildon.py b/wifiscanner/hildongtk/hildon.py index 46b0ac6..1deaa6b 100644 --- a/wifiscanner/hildongtk/hildon.py +++ b/wifiscanner/hildongtk/hildon.py @@ -61,7 +61,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 +# FIXME bug#6892 Add value-changed signal, with the response signal from the Dialog class PickerButton ( Button ) : def __init__ ( self , height , arrangement ) : Button.__init__( self , height , arrangement ) diff --git a/wifiscanner/wifimap/config.py b/wifiscanner/wifimap/config.py index 7dd6995..dfff47f 100644 --- a/wifiscanner/wifimap/config.py +++ b/wifiscanner/wifimap/config.py @@ -5,7 +5,7 @@ import gtk try : import hildon except : - hildon = False + from hildongtk import hildon class Configuration : @@ -71,12 +71,14 @@ class Configuration : client.set_int( "/apps/wifihood/%s-zoom" % self._type , self.zoom ) -class AbstractSettingsWindow : +class SettingsWindow ( hildon.StackableWindow ) : - def __init__ ( self , config , handler ) : + def __init__ ( self , config , handler=None ) : + + hildon.StackableWindow.__init__( self ) self.set_title( "Wifihood Settings" ) - scrollwin = self.MainArea() + scrollwin = hildon.PannableArea() scrollwin.show() self.add(scrollwin) @@ -92,6 +94,15 @@ class AbstractSettingsWindow : self.show() + 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 ) + # FIXME bug#6892 missing signal + button.connect_object( "value-changed", selector.zoomdialog , button , config ) + return button + def add_dbframe ( self , vbox , config ) : dbframe = gtk.Frame( label="Database" ) @@ -107,7 +118,7 @@ class AbstractSettingsWindow : dblabel.show() database.attach(dblabel, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL, 0, 0, 5) - dbvalue = self.Entry() + dbvalue = hildon.Entry( gtk.HILDON_SIZE_FINGER_HEIGHT ) dbvalue.connect( "changed" , self.entry_cb , config , "basedir" ) dbvalue.set_text( config.homedir ) dbvalue.show() @@ -117,7 +128,7 @@ class AbstractSettingsWindow : dblabel.show() database.attach(dblabel, 0, 1, 1, 2, gtk.EXPAND|gtk.FILL, 0, 0, 5) - dbvalue = self.Entry() + dbvalue = hildon.Entry( gtk.HILDON_SIZE_FINGER_HEIGHT ) dbvalue.connect( "changed" , self.entry_cb , config , "dbname" ) dbvalue.set_text( config.dbname ) dbvalue.show() @@ -135,7 +146,7 @@ class AbstractSettingsWindow : maps.show() mapsframe.add(maps) - button = self.CheckButton() + button = hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT ) button.set_label( "Use OpenStreet maps" ) button.set_active( 1 ) button.show() @@ -157,14 +168,14 @@ class AbstractSettingsWindow : gps.show() gpsframe.add(gps) - button = self.CheckButton() + button = hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT ) button.set_label( "Take initial coordinates from maemo-mapper" ) 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) - button = self.CheckButton() + button = hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT ) button.set_label( "Store changes in coordinates" ) button.connect( "toggled" , self.checkbutton_cb , config , "store_gps" ) button.set_active( config.store_gps ) @@ -187,13 +198,13 @@ class AbstractSettingsWindow : scanlabel.show() datatable.attach(scanlabel, 0, 1, 0, 1, gtk.EXPAND|gtk.FILL) - scanvalue = self.Entry() + scanvalue = hildon.Entry( gtk.HILDON_SIZE_FINGER_HEIGHT ) 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) - button = self.CheckButton() + 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 ) @@ -212,9 +223,7 @@ class AbstractSettingsWindow : def checkbutton_cb ( self , button , config , keyword ) : config.__dict__[ keyword ] = button.get_active() -if hildon : - - class ZoomDialog ( hildon.TouchSelector ) : +class ZoomDialog ( hildon.TouchSelector ) : def __init__ ( self , config , handler ) : hildon.TouchSelector.__init__( self ) @@ -240,110 +249,6 @@ if hildon : 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 - - def MainArea ( self ) : - return hildon.PannableArea() - - def Entry ( self ) : - return hildon.Entry( gtk.HILDON_SIZE_FINGER_HEIGHT ) - - def Button ( self , text , value ) : - return hildon.Button( gtk.HILDON_SIZE_THUMB_HEIGHT , hildon.BUTTON_ARRANGEMENT_HORIZONTAL , text , "%s" % value ) - - def CheckButton ( self ) : - return hildon.CheckButton( gtk.HILDON_SIZE_FINGER_HEIGHT ) - -else : - - class ZoomDialog ( gtk.Dialog ) : - - def __init__ ( self , config , handler , labelsetter=None ) : - gtk.Dialog.__init__( self , "Select zoom level", - None, - gtk.DIALOG_MODAL, - ( gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, - gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT - ) - ) - - zooms = gtk.ListStore(int) - combo = gtk.ComboBox( zooms ) - - for zoom in range(8,19) : - iter = zooms.append() - zooms.set( iter , 0 , zoom ) - if zoom == config.zoom : - combo.set_active_iter( iter ) - - cell = gtk.CellRendererText() - combo.pack_start(cell, True) - combo.add_attribute(cell, 'text', 0) - - self.vbox.pack_start(combo , True, True, 0) - - self.connect_object( "response", self.response , combo , config , handler , labelsetter ) - - 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() - - class SettingsWindow ( gtk.Window , AbstractSettingsWindow ) : - - def __init__ ( self , config , handler=None ) : - gtk.Window.__init__( self ) - AbstractSettingsWindow.__init__( self , config , handler ) - self.connect("unrealize", config.save ) - - def MainArea ( self ) : - scrollwin = gtk.ScrolledWindow() - scrollwin.set_size_request(-1, 290) - scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) - return scrollwin - - def Entry ( self ) : - return gtk.Entry() - - def Button ( self , label=None ) : - return gtk.Button( label ) - - def zoomdialog ( self , widget , config , handler ) : - dialog = ZoomDialog( config , handler , widget.set_value ) - dialog.show_all() - - def ZoomButton ( self , text , config , handler ) : - 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 ) ) - button = _button( text , config.zoom ) - button.connect_object( "clicked", self.zoomdialog , button , config , handler ) - return button - - def CheckButton ( self ) : - return gtk.CheckButton() if __name__ == "__main__" : config = Configuration( 'scanner' ) diff --git a/wifiscanner/wifimap/gps.py b/wifiscanner/wifimap/gps.py index 5fe2b76..33f8643 100644 --- a/wifiscanner/wifimap/gps.py +++ b/wifiscanner/wifimap/gps.py @@ -1,5 +1,8 @@ -import location +try : + import location +except : + import hildongtk.location as location import gobject diff --git a/wifiscanner/wifimap/scanner.py b/wifiscanner/wifimap/scanner.py index 423f203..574a99a 100644 --- a/wifiscanner/wifimap/scanner.py +++ b/wifiscanner/wifimap/scanner.py @@ -2,7 +2,7 @@ try : import osso except : - import osso_wrapper as osso + import hildongtk.osso as osso import time diff --git a/wifiscanner/wifimap/wifiscan.py b/wifiscanner/wifimap/wifiscan.py index 33221b0..7edc380 100644 --- a/wifiscanner/wifimap/wifiscan.py +++ b/wifiscanner/wifimap/wifiscan.py @@ -2,7 +2,7 @@ try : import osso except : - import osso_wrapper as osso + import hildongtk.osso as osso import time -- 1.7.9.5