X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=wifiscanner%2Fwifiscanner;h=5aff5304fcb37d60f2ce42e50f5834fdf44b0026;hb=5a6481baa084244a7f777d440eff21eb129809ec;hp=f50cc6356bc5a36d9325101595f39f02a9e106dd;hpb=48f7a5099615bbd810eef24e99096ae3b9aaacde;p=wifihood diff --git a/wifiscanner/wifiscanner b/wifiscanner/wifiscanner index f50cc63..5aff530 100755 --- a/wifiscanner/wifiscanner +++ b/wifiscanner/wifiscanner @@ -6,20 +6,20 @@ import gtk , pango try : import hildon except : - hildon = False + from hildongtk import hildon -def global_start(button, scanner): - scanner.start() +def global_start(button, scanner, config): + scanner.start( int( 1000 * config.scan_period ) , config.store_log ) if button._id : button.disconnect( button._id ) - button._id = button.connect("clicked", global_stop, scanner) + button._id = button.connect("clicked", global_stop, scanner, config) button.set_label("Switch GPS Off") -def global_stop(button, scanner): +def global_stop(button, scanner, config): scanner.stop() if button._id : button.disconnect( button._id ) - button._id = button.connect("clicked", global_start, scanner) + button._id = button.connect("clicked", global_start, scanner, config) button.set_label("Switch GPS On") def enable_agps(button): @@ -59,16 +59,29 @@ class scanner ( wifimap.Scanner ) : self.map.hide() self.map.recenter( self.info[4:6] ) pixmap,mask = self.map.get_pixbuf().render_pixmap_and_mask() - self.map.plot( pixmap , ( float(self.info[4]) , float(self.info[5]) ) , "red" , 2 ) + pointsize = 2 + if self.newaps : + pointsize += 2 + self.map.plot( pixmap , ( float(self.info[4]) , float(self.info[5]) ) , "red" , pointsize ) + for mac,ap in self.aps.iteritems() : + if self.oldpos.get( mac ) : + self.map.line( pixmap , self.oldpos[mac] , ( ap[1]/ap[0] , ap[2]/ap[0] ) , "green" ) + self.map.plot( pixmap , ( ap[1]/ap[0] , ap[2]/ap[0] ) , "green" , 2 ) self.map.get_pixbuf().get_from_drawable( pixmap , pixmap.get_colormap() , 0, 0 , 0 , 0 , self.map.win_x, self.map.win_y ) self.map.show() -class AbstractWifiscanner : +class Wifiscanner ( hildon.StackableWindow ) : def __init__ ( self ) : - _scanner = scanner( "wlan0" ) + hildon.StackableWindow.__init__( self ) + self.set_title( "Wifihood Scanner" ) + program = hildon.Program.get_instance() + program.add_window(self) + + config = wifimap.config.Configuration( 'scanner' ) + _scanner = scanner( config , "wlan0" ) self.connect("delete_event", gtk.main_quit, None) @@ -76,7 +89,6 @@ class AbstractWifiscanner : # Top frame creation top_frame = gtk.Frame() - self.vbox.pack_start(top_frame) hbox = gtk.HBox(homogeneous=False, spacing=0) top_frame.add(hbox) @@ -85,6 +97,8 @@ class AbstractWifiscanner : bottom_frame = gtk.Frame() self.vbox.pack_end(bottom_frame, expand=False) + self.vbox.pack_end(top_frame) + bottom_box = gtk.HBox(homogeneous=False, spacing=0) bottom_frame.add( bottom_box ) @@ -94,26 +108,31 @@ class AbstractWifiscanner : scrollview = gtk.ScrolledWindow() notebook.append_page( scrollview , gtk.Label("Scanning") ) - self.map = MapWindow() + self.map = MapWindow( config ) notebook.append_page( self.map , gtk.Label("Map") ) buttons = gtk.VBox(homogeneous=False, spacing=0) hbox.pack_end(buttons, expand=False) - textview = self.TextView( "Scan results ..." ) + textview = hildon.TextView() + textview.set_placeholder( "Scan results ..." ) + textview.set_editable( False ) + textview.set_cursor_visible( False ) + textview.modify_font( pango.FontDescription("Courier 12") ) scrollview.add( textview ) scrollview.set_policy( gtk.POLICY_NEVER , gtk.POLICY_AUTOMATIC ) # Buttons creation - button = self.Button( "Switch GPS On") - button._id = button.connect("clicked", global_start, _scanner) + button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Switch GPS On" ) + button._id = button.connect("clicked", global_start, _scanner, config) buttons.pack_start(button, expand=False) - button_scan = self.Button( "Start scanning") + button_scan = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Start scanning" ) button_scan._id = button_scan.connect("clicked", start_scan, _scanner) buttons.pack_start(button_scan, expand=False) - toggle_button = self.CheckButton( "Use Assisted GPS" ) + toggle_button = hildon.CheckButton( gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT ) + toggle_button.set_label( "Use Assisted GPS" ) toggle_button.connect("toggled", enable_agps) buttons.pack_start(toggle_button, expand=False) @@ -121,58 +140,16 @@ class AbstractWifiscanner : status = gtk.Label( "status bar ..." ) _scanner.status = status _scanner.buffer = textview.get_buffer() - _scanner.map = self.map + _scanner.map = self.map.child bottom_box.pack_start( status , expand=False , padding=20 ) - def run ( self ) : - gtk.main() - -if hildon : - - class MapWindow ( gtk.Frame ) : - - def __init__(self): - gtk.Frame.__init__( self ) - - self.config = wifimap.config.Configuration() - self.config.zoom = 16 - self.add( wifimap.simpleMapWidget( self.config ) ) - - class Wifiscanner ( AbstractWifiscanner , hildon.StackableWindow ) : - - def __init__ ( self ) : - hildon.StackableWindow.__init__( self ) - self.set_title( "Wifihood Scanner" ) - program = hildon.Program.get_instance() - program.add_window(self) - - AbstractWifiscanner.__init__( self ) - self.add(self.vbox) - - self.create_menu( ) - - self.show_all() + self.add(self.vbox) - 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 + self.create_menu( ) - 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 + self.show_all() - def create_menu ( self ) : + def create_menu ( self ) : menubar = hildon.AppMenu() self.set_app_menu( menubar ) @@ -181,55 +158,27 @@ if hildon : hildon.BUTTON_ARRANGEMENT_VERTICAL, "Settings", None) - settings.connect( "clicked", settings_cb , self.map.config ) + settings.connect( "clicked", settings_cb , self.map ) menubar.append( settings ) menubar.show_all() - def settings_cb ( widget , config ) : - wifimap.config.SettingsWindow( config ) + def run ( self ) : + gtk.main() + +def settings_cb ( widget , map ) : + window = wifimap.config.SettingsWindow( map.config , map.child.SetZoom ) -else : - class MapWindow ( gtk.Frame ) : +class MapWindow ( gtk.Frame ) : - def __init__(self): + def __init__( self , config ): gtk.Frame.__init__( self ) - self.config = wifimap.config.Configuration() - self.config.zoom = 16 - self.add( wifimap.simpleMapWidget( self.config , (640,400) ) ) - - class Wifiscanner ( AbstractWifiscanner , gtk.Window ) : - - def __init__ ( self ) : - gtk.Window.__init__( self ) - self.resize(640,400) - - AbstractWifiscanner.__init__( self ) - self.add(self.vbox) - - self.show_all() - - 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 + self.config = config + self.add( wifimap.simpleMapWidget( self.config ) ) + window = Wifiscanner() window.run()