Implement status bar and fix layout issues
authorjaviplx <javiplx@gmail.com>
Fri, 8 Oct 2010 19:39:40 +0000 (19:39 +0000)
committerjaviplx <javiplx@gmail.com>
Fri, 8 Oct 2010 19:39:40 +0000 (19:39 +0000)
git-svn-id: file:///svnroot/wifihood/trunk/wifiscanner@27 c51dfc6a-5949-4919-9c8e-f207a149c383

wifimap/gps.py
wifimap/wifiscan.py
wifiscanner

index 8802976..3c583fb 100644 (file)
@@ -20,6 +20,8 @@ class GPSObject ( gobject.GObject ) :
         self.update_handler = None
         self.satellites = None
         self.cell_info = None
+        self.ngps = 0
+        self.status = None
 
     def set_method ( self , method="gps" ) :
         if method == "agps" :
@@ -77,6 +79,8 @@ class GPSObject ( gobject.GObject ) :
             #        banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "Got GPS fix" )
             #        banner.set_timeout( 1500 )
                 self.gps_state = "FIX"
+                self.ngps += 1
+                self.refresh_infowin()
             elif self.device.status == location.GPS_DEVICE_STATUS_DGPS_FIX :
             #    if self.gps_state == "NO_FIX" :
             #        banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "Got differential GPS fix" )
@@ -91,6 +95,12 @@ class GPSObject ( gobject.GObject ) :
         #        banner = hildon.hildon_banner_show_information( self._parent , "icon_path" , "GPS info : %s" % self.gps_info )
         #        banner.set_timeout( 300 )
 
+    def set_infowin ( self , statuswin ) :
+        self.status = statuswin
+
+    def refresh_infowin ( self ) :
+        self.status.set_label( "%d gps" % self.ngps )
+
 
 #    mode = device.fix[0]
 #    if mode == location.GPS_DEVICE_MODE_NOT_SEEN : # This means ??
index 574582e..b278d4c 100644 (file)
@@ -15,6 +15,9 @@ class Scanner ( gps.GPSObject ) :
         osso_rpc = osso.Rpc(self.osso_context)
         scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "wakeup", wait_reply = True)
         self._timer = None
+        self.nscan = 0
+        self.nfp = 0
+        self.aplist = {}
 
     def start ( self ) :
         osso_rpc = osso.Rpc(self.osso_context)
@@ -28,13 +31,17 @@ class Scanner ( gps.GPSObject ) :
         osso_rpc = osso.Rpc(self.osso_context)
         try :
             scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "scan", wait_reply = True)
+            self.nscan +=1
         except Exception , ex :
             osso.SystemNote(self.osso_context).system_note_infoprint("Exception scanning %s" % ex )
             return True
         out_str = ""
         for net in scan_out.split() :
+            self.nfp += 1
             items = net.rsplit(":", 1)
             out_str += " %s %s" % ( items[0] , items[1] )
+            self.aplist[ items[0] ] = 1
+        self.refresh_infowin()
         if self._debug :
         # Use osso or hildon for notes ???
             osso.SystemNote(self.osso_context).system_note_infoprint("Found %d APs" % len(scan_out) )
@@ -54,6 +61,9 @@ class Scanner ( gps.GPSObject ) :
 
         return True
 
+    def refresh_infowin ( self ) :
+        self.status.set_label( "%d gps\t%d scan\t%d fp\t%d ap" % ( self.ngps , self.nscan , self.nfp , len(self.aplist.keys()) ) )
+
 
 gobject.type_register(Scanner)
 
index aaf97a2..af54198 100755 (executable)
@@ -59,8 +59,8 @@ def main():
     window.connect("delete_event", gtk.main_quit, None)
 
     vbox = gtk.VBox(homogeneous=False, spacing=0)
-    top_frame = gtk.Frame(label="top")
-    bottom_frame = gtk.Frame(label="bottom")
+    top_frame = gtk.Frame()
+    bottom_frame = gtk.Frame()
     bottom_box = gtk.HBox(homogeneous=False, spacing=0)
 
     hbox = gtk.HBox(homogeneous=False, spacing=0)
@@ -74,7 +74,7 @@ def main():
     hbox.pack_start( scrollview )
 
     buttons = gtk.VBox(homogeneous=False, spacing=0)
-    hbox.pack_end( buttons )
+    hbox.pack_end(buttons, expand=False)
 
     button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Switch On!")
     button.handler_id = button.connect("clicked", hello, gpsdev)
@@ -89,12 +89,13 @@ def main():
     buttons.pack_start(toggle_button, expand=False)
 
     status = gtk.Label( "status bar ..." )
+    gpsdev.set_infowin( status )
     bottom_box.pack_start( status , expand=False , padding=20 )
 
     bottom_frame.add( bottom_box )
 
     vbox.pack_start(top_frame)
-    vbox.pack_end(bottom_frame)
+    vbox.pack_end(bottom_frame, expand=False)
     window.add(vbox)
 
     window.show_all()