From 97dc7f8e87184766224837d3e1ad2ef136aa7e70 Mon Sep 17 00:00:00 2001 From: javiplx Date: Wed, 13 Oct 2010 11:42:47 +0000 Subject: [PATCH] Move scanner UI out of the main package git-svn-id: file:///svnroot/wifihood/trunk@58 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscanner/MANIFEST | 3 +- wifiscanner/wifimap/ui.py | 173 -------------------------------------------- wifiscanner/wifiscanner | 4 +- wifiscanner/wifiscanner.py | 173 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 177 insertions(+), 176 deletions(-) delete mode 100755 wifiscanner/wifimap/ui.py create mode 100755 wifiscanner/wifiscanner.py diff --git a/wifiscanner/MANIFEST b/wifiscanner/MANIFEST index 4b7b5d1..21ebfb2 100644 --- a/wifiscanner/MANIFEST +++ b/wifiscanner/MANIFEST @@ -1,7 +1,9 @@ setup.py wifiscanner +wifiscanner.py wifiscanner.desktop wifiview +wifiview.py wifiview.desktop wifimap/__init__.py wifimap/gps.py @@ -9,4 +11,3 @@ wifimap/wifiscan.py wifimap/osso_wrapper.py wifimap/db.py wifimap/config.py -wifimap/ui.py diff --git a/wifiscanner/wifimap/ui.py b/wifiscanner/wifimap/ui.py deleted file mode 100755 index 06c9616..0000000 --- a/wifiscanner/wifimap/ui.py +++ /dev/null @@ -1,173 +0,0 @@ - -import wifimap - -import gtk , pango -try : - import hildon -except : - hildon = False - -import gobject - -def hello(widget, data): - data.do_start() - if widget.handler_id : - widget.disconnect( widget.handler_id ) - widget.handler_id = widget.connect("clicked", bye, data) - widget.set_label("Switch Off!") - -def bye(widget, data): - data.do_stop() - if widget.handler_id : - widget.disconnect( widget.handler_id ) - widget.handler_id = widget.connect("clicked", hello, data) - widget.set_label("Switch On!") - -def enable_agps(widget): - if widget.get_active() : - print "%s state is active" % widget - -def scana(widget, data): - if not data._timer : - data._timer = gobject.timeout_add( 5000 , data.scan ) - else : - if hildon : - hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning was already active" ) - if widget.handler_id : - widget.disconnect( widget.handler_id ) - widget.handler_id = widget.connect("clicked", scano, data) - widget.set_label("Stop scanning now !!") - -def scano(widget, data): - if data._timer : - if hildon : - hildon.hildon_banner_show_information( widget , "icon_path" , "Timer was running, stopping it" ) - gobject.source_remove( data._timer ) - data._timer = None - data.stop() - else : - if hildon : - hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning is not active" ) - if widget.handler_id : - widget.disconnect( widget.handler_id ) - widget.handler_id = widget.connect("clicked", scana, data) - widget.set_label("Start scanning now !!") - -class AbstractWifiscanner : - - def __init__ ( self ) : - - self.gpsdev = wifimap.Scanner( self ) - - self.connect("delete_event", gtk.main_quit, None) - - vbox = gtk.VBox(homogeneous=False, spacing=0) - self.add(vbox) - - # Top frame creation - top_frame = gtk.Frame() - vbox.pack_start(top_frame) - - hbox = gtk.HBox(homogeneous=False, spacing=0) - top_frame.add(hbox) - - # Bottom frame creation - bottom_frame = gtk.Frame() - vbox.pack_end(bottom_frame, expand=False) - - bottom_box = gtk.HBox(homogeneous=False, spacing=0) - bottom_frame.add( bottom_box ) - - # Top frame population - scrollview = gtk.ScrolledWindow() - hbox.pack_start( scrollview ) - - buttons = gtk.VBox(homogeneous=False, spacing=0) - hbox.pack_end(buttons, expand=False) - - textview = self.TextView( "Scan results ..." ) - scrollview.add( textview ) - scrollview.set_policy( gtk.POLICY_NEVER , gtk.POLICY_AUTOMATIC ) - - # Buttons creation - button = self.Button( "Switch On!") - button.handler_id = button.connect("clicked", hello, self.gpsdev) - buttons.pack_start(button, expand=False) - - button_scan = self.Button( "Start scanning now !!") - button_scan.handler_id = button_scan.connect("clicked", scana, self.gpsdev) - buttons.pack_start(button_scan, expand=False) - - toggle_button = self.CheckButton( "Use Assisted GPS" ) - toggle_button.connect("toggled", enable_agps) - buttons.pack_start(toggle_button, expand=False) - - # Bottom frame population - status = gtk.Label( "status bar ..." ) - self.gpsdev.set_infowin( status , textview.get_buffer() ) - bottom_box.pack_start( status , expand=False , padding=20 ) - - def run ( self ) : - self.show_all() - self.gpsdev.start() - gtk.main() - -if hildon : - - class Wifiscanner ( AbstractWifiscanner , hildon.Window ) : - - def __init__ ( self ) : - hildon.Window.__init__( self ) - program = hildon.Program.get_instance() - program.add_window(self) - - AbstractWifiscanner.__init__( self ) - - def TextView ( self , placeholder=None ) : - textview = hildon.TextView() - if placeholder : - textview.set_placeholder( placeholder ) - textview.set_editable( False ) - textview.set_cursor_visible( False ) - textview.modify_font( pango.FontDescription("Courier 12") ) - return textview - - def Button ( self , label="" ) : - button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL, label) - return button - - def CheckButton ( self , label=None ) : - toggle_button = hildon.CheckButton( gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT ) - if label : - toggle_button.set_label( label ) - return toggle_button - -else : - - class Wifiscanner ( AbstractWifiscanner , gtk.Window ) : - - def __init__ ( self ) : - gtk.Window.__init__( self ) - self.resize(640,400) - - AbstractWifiscanner.__init__( self ) - - def TextView ( self , placeholder=None ) : - textview = gtk.TextView() - if placeholder : - textview.get_buffer().set_text( placeholder ) - textview.set_editable( False ) - textview.set_cursor_visible( False ) - textview.modify_font( pango.FontDescription("Courier 12") ) - return textview - - def Button ( self , label="" ) : - button = gtk.Button( label ) - return button - - def CheckButton ( self , label=None ) : - toggle_button = gtk.CheckButton() - if label : - toggle_button.set_label( label ) - return toggle_button - diff --git a/wifiscanner/wifiscanner b/wifiscanner/wifiscanner index a9bf8d2..03ff1ad 100755 --- a/wifiscanner/wifiscanner +++ b/wifiscanner/wifiscanner @@ -1,8 +1,8 @@ #!/usr/bin/python -import wifimap.ui +import wifiscanner if __name__ == "__main__": - window = wifimap.ui.Wifiscanner() + window = wifiscanner.Wifiscanner() window.run() diff --git a/wifiscanner/wifiscanner.py b/wifiscanner/wifiscanner.py new file mode 100755 index 0000000..06c9616 --- /dev/null +++ b/wifiscanner/wifiscanner.py @@ -0,0 +1,173 @@ + +import wifimap + +import gtk , pango +try : + import hildon +except : + hildon = False + +import gobject + +def hello(widget, data): + data.do_start() + if widget.handler_id : + widget.disconnect( widget.handler_id ) + widget.handler_id = widget.connect("clicked", bye, data) + widget.set_label("Switch Off!") + +def bye(widget, data): + data.do_stop() + if widget.handler_id : + widget.disconnect( widget.handler_id ) + widget.handler_id = widget.connect("clicked", hello, data) + widget.set_label("Switch On!") + +def enable_agps(widget): + if widget.get_active() : + print "%s state is active" % widget + +def scana(widget, data): + if not data._timer : + data._timer = gobject.timeout_add( 5000 , data.scan ) + else : + if hildon : + hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning was already active" ) + if widget.handler_id : + widget.disconnect( widget.handler_id ) + widget.handler_id = widget.connect("clicked", scano, data) + widget.set_label("Stop scanning now !!") + +def scano(widget, data): + if data._timer : + if hildon : + hildon.hildon_banner_show_information( widget , "icon_path" , "Timer was running, stopping it" ) + gobject.source_remove( data._timer ) + data._timer = None + data.stop() + else : + if hildon : + hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning is not active" ) + if widget.handler_id : + widget.disconnect( widget.handler_id ) + widget.handler_id = widget.connect("clicked", scana, data) + widget.set_label("Start scanning now !!") + +class AbstractWifiscanner : + + def __init__ ( self ) : + + self.gpsdev = wifimap.Scanner( self ) + + self.connect("delete_event", gtk.main_quit, None) + + vbox = gtk.VBox(homogeneous=False, spacing=0) + self.add(vbox) + + # Top frame creation + top_frame = gtk.Frame() + vbox.pack_start(top_frame) + + hbox = gtk.HBox(homogeneous=False, spacing=0) + top_frame.add(hbox) + + # Bottom frame creation + bottom_frame = gtk.Frame() + vbox.pack_end(bottom_frame, expand=False) + + bottom_box = gtk.HBox(homogeneous=False, spacing=0) + bottom_frame.add( bottom_box ) + + # Top frame population + scrollview = gtk.ScrolledWindow() + hbox.pack_start( scrollview ) + + buttons = gtk.VBox(homogeneous=False, spacing=0) + hbox.pack_end(buttons, expand=False) + + textview = self.TextView( "Scan results ..." ) + scrollview.add( textview ) + scrollview.set_policy( gtk.POLICY_NEVER , gtk.POLICY_AUTOMATIC ) + + # Buttons creation + button = self.Button( "Switch On!") + button.handler_id = button.connect("clicked", hello, self.gpsdev) + buttons.pack_start(button, expand=False) + + button_scan = self.Button( "Start scanning now !!") + button_scan.handler_id = button_scan.connect("clicked", scana, self.gpsdev) + buttons.pack_start(button_scan, expand=False) + + toggle_button = self.CheckButton( "Use Assisted GPS" ) + toggle_button.connect("toggled", enable_agps) + buttons.pack_start(toggle_button, expand=False) + + # Bottom frame population + status = gtk.Label( "status bar ..." ) + self.gpsdev.set_infowin( status , textview.get_buffer() ) + bottom_box.pack_start( status , expand=False , padding=20 ) + + def run ( self ) : + self.show_all() + self.gpsdev.start() + gtk.main() + +if hildon : + + class Wifiscanner ( AbstractWifiscanner , hildon.Window ) : + + def __init__ ( self ) : + hildon.Window.__init__( self ) + program = hildon.Program.get_instance() + program.add_window(self) + + AbstractWifiscanner.__init__( self ) + + def TextView ( self , placeholder=None ) : + textview = hildon.TextView() + if placeholder : + textview.set_placeholder( placeholder ) + textview.set_editable( False ) + textview.set_cursor_visible( False ) + textview.modify_font( pango.FontDescription("Courier 12") ) + return textview + + def Button ( self , label="" ) : + button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL, label) + return button + + def CheckButton ( self , label=None ) : + toggle_button = hildon.CheckButton( gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT ) + if label : + toggle_button.set_label( label ) + return toggle_button + +else : + + class Wifiscanner ( AbstractWifiscanner , gtk.Window ) : + + def __init__ ( self ) : + gtk.Window.__init__( self ) + self.resize(640,400) + + AbstractWifiscanner.__init__( self ) + + def TextView ( self , placeholder=None ) : + textview = gtk.TextView() + if placeholder : + textview.get_buffer().set_text( placeholder ) + textview.set_editable( False ) + textview.set_cursor_visible( False ) + textview.modify_font( pango.FontDescription("Courier 12") ) + return textview + + def Button ( self , label="" ) : + button = gtk.Button( label ) + return button + + def CheckButton ( self , label=None ) : + toggle_button = gtk.CheckButton() + if label : + toggle_button.set_label( label ) + return toggle_button + -- 1.7.9.5