#!/usr/bin/python
-import wifimap
-
-import gtk
-import hildon
-
-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 :
- 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 :
- hildon.hildon_banner_show_information( widget , "icon_path" , "Timer was running, stopping it" )
- gobject.source_remove( data._timer )
- data._timer = None
- data.stop()
- else :
- 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 !!")
-
-def main():
-
- window = hildon.Window()
- program = hildon.Program.get_instance()
- program.add_window(window)
-
- gpsdev = wifimap.Scanner( window )
-
- 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")
-
- # FIXME : Temporary holder !!!
- table = gtk.Table (2, 1, False)
-
- # set the spacing to 10 on x and 10 on y
- table.set_row_spacings(10)
- table.set_col_spacings(10)
-
- button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Switch On!")
- button.handler_id = button.connect("clicked", hello, gpsdev)
- table.attach(button, 0, 1, 0, 1)
-
- button_scan = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH, hildon.BUTTON_ARRANGEMENT_VERTICAL, "Start scanning now !!")
- button_scan.handler_id = button_scan.connect("clicked", scana, gpsdev)
- table.attach(button_scan, 0, 1, 1, 2)
-
- bottom_frame.add(table)
-
- toggle_button = gtk.CheckButton(label="Use Assisted GPS")
- toggle_button.connect("toggled", enable_agps)
- top_frame.add(toggle_button)
-
- vbox.pack_start(top_frame)
- vbox.pack_end(bottom_frame)
- window.add(vbox)
-
- window.show_all()
-
- gpsdev.start()
-
- gtk.main()
+import wifimap.ui
if __name__ == "__main__":
- main()
+ window = wifimap.ui.Wifiscanner()
+ window.run()