2 import wifimap , wifiview
12 def hello(widget, data):
14 if widget.handler_id :
15 widget.disconnect( widget.handler_id )
16 widget.handler_id = widget.connect("clicked", bye, data)
17 widget.set_label("Switch Off!")
19 def bye(widget, data):
21 if widget.handler_id :
22 widget.disconnect( widget.handler_id )
23 widget.handler_id = widget.connect("clicked", hello, data)
24 widget.set_label("Switch On!")
26 def enable_agps(widget):
27 if widget.get_active() :
28 print "%s state is active" % widget
30 def scana(widget, data):
32 data._timer = gobject.timeout_add( 5000 , data.scan )
35 hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning was already active" )
36 if widget.handler_id :
37 widget.disconnect( widget.handler_id )
38 widget.handler_id = widget.connect("clicked", scano, data)
39 widget.set_label("Stop scanning now !!")
41 def scano(widget, data):
44 hildon.hildon_banner_show_information( widget , "icon_path" , "Timer was running, stopping it" )
45 gobject.source_remove( data._timer )
50 hildon.hildon_banner_show_information( widget , "icon_path" , "Scanning is not active" )
51 if widget.handler_id :
52 widget.disconnect( widget.handler_id )
53 widget.handler_id = widget.connect("clicked", scana, data)
54 widget.set_label("Start scanning now !!")
56 class AbstractWifiscanner :
58 def __init__ ( self ) :
60 self.gpsdev = wifimap.Scanner()
62 self.connect("delete_event", gtk.main_quit, None)
64 self.vbox = gtk.VBox(homogeneous=False, spacing=0)
67 top_frame = gtk.Frame()
68 self.vbox.pack_start(top_frame)
70 hbox = gtk.HBox(homogeneous=False, spacing=0)
73 # Bottom frame creation
74 bottom_frame = gtk.Frame()
75 self.vbox.pack_end(bottom_frame, expand=False)
77 bottom_box = gtk.HBox(homogeneous=False, spacing=0)
78 bottom_frame.add( bottom_box )
80 # Top frame population
81 notebook = gtk.Notebook()
82 hbox.pack_start( notebook )
84 scrollview = gtk.ScrolledWindow()
85 notebook.append_page( scrollview , gtk.Label("Scanning") )
86 notebook.append_page( MapWindow() , gtk.Label("Map") )
88 buttons = gtk.VBox(homogeneous=False, spacing=0)
89 hbox.pack_end(buttons, expand=False)
91 textview = self.TextView( "Scan results ..." )
92 scrollview.add( textview )
93 scrollview.set_policy( gtk.POLICY_NEVER , gtk.POLICY_AUTOMATIC )
96 button = self.Button( "Switch On!")
97 button.handler_id = button.connect("clicked", hello, self.gpsdev)
98 buttons.pack_start(button, expand=False)
100 button_scan = self.Button( "Start scanning now !!")
101 button_scan.handler_id = button_scan.connect("clicked", scana, self.gpsdev)
102 buttons.pack_start(button_scan, expand=False)
104 toggle_button = self.CheckButton( "Use Assisted GPS" )
105 toggle_button.connect("toggled", enable_agps)
106 buttons.pack_start(toggle_button, expand=False)
108 # Bottom frame population
109 status = gtk.Label( "status bar ..." )
110 bottom_box.pack_start( status , expand=False , padding=20 )
119 class MapWindow ( gtk.Frame ) :
122 gtk.Frame.__init__( self )
124 self.config = wifimap.config.Configuration()
125 self.config.zoom = 16
126 self.map = wifimap.simpleMapWidget( self.config )
130 class Wifiscanner ( AbstractWifiscanner , hildon.Window ) :
132 def __init__ ( self ) :
133 hildon.Window.__init__( self )
134 program = hildon.Program.get_instance()
135 program.add_window(self)
137 AbstractWifiscanner.__init__( self )
140 def TextView ( self , placeholder=None ) :
141 textview = hildon.TextView()
143 textview.set_placeholder( placeholder )
144 textview.set_editable( False )
145 textview.set_cursor_visible( False )
146 textview.modify_font( pango.FontDescription("Courier 12") )
149 def Button ( self , label="" ) :
150 button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL, label)
153 def CheckButton ( self , label=None ) :
154 toggle_button = hildon.CheckButton( gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT )
156 toggle_button.set_label( label )
161 class MapWindow ( gtk.Frame ) :
164 gtk.Frame.__init__( self )
166 self.config = wifimap.config.Configuration()
167 self.config.zoom = 16
168 self.add( wifimap.simpleMapWidget( self.config , (640,400) ) )
170 class Wifiscanner ( AbstractWifiscanner , gtk.Window ) :
172 def __init__ ( self ) :
173 gtk.Window.__init__( self )
176 AbstractWifiscanner.__init__( self )
179 def TextView ( self , placeholder=None ) :
180 textview = gtk.TextView()
182 textview.get_buffer().set_text( placeholder )
183 textview.set_editable( False )
184 textview.set_cursor_visible( False )
185 textview.modify_font( pango.FontDescription("Courier 12") )
188 def Button ( self , label="" ) :
189 button = gtk.Button( label )
192 def CheckButton ( self , label=None ) :
193 toggle_button = gtk.CheckButton()
195 toggle_button.set_label( label )