6 from launcher import Launcher
7 from settings import Settings
14 def __init__(self, launcher, settings, parent_window):
15 self._settings = settings
16 self._parent = parent_window
17 self._launcher = launcher
18 self._popup = self._settings.getUsePopup()
21 def launch_browser(self):
22 url = self._settings.getUrlToOpen()
23 self._launcher.openUrl(url)
26 def show_decision_dialog(self, ssid):
30 dialog = gtk.Dialog(ssid, parent)
31 dialog.vbox.set_homogeneous(False)
33 dialog.add_button(_('No'), gtk.RESPONSE_NO)
34 dialog.add_button(_('Yes'), gtk.RESPONSE_YES)
36 label = gtk.Label(_('New network connection established - do you wish to launch a browser?'))
37 label.set_line_wrap(True)
38 #label.set_justify(gtk.JUSTIFY_LEFT)
39 #label.set_alignment(0, 0.5)
40 dialog.vbox.add(label)
42 checkbox = hildon.CheckButton(gtk.HILDON_SIZE_FINGER_HEIGHT)
43 checkbox.set_label(_('Remember this decision'))
44 checkbox.set_active(True)
45 dialog.vbox.add(checkbox)
51 launchBrowser = (result == gtk.RESPONSE_YES)
52 if checkbox.get_active():
53 self._settings.setLaunchSettings(ssid, launchBrowser)
58 def connection_established(self, ssid):
59 value = self._settings.getLaunchSettings(ssid)
61 if self.show_decision_dialog(ssid):
69 def _connection_cb(self, connection, event):
70 status = event.get_status()
71 if status == conic.STATUS_CONNECTED:
72 # assemble id > name dict
74 iaps = connection.get_all_iaps()
77 iap_name = iap.get_name()
78 iap_id_to_name[iap_id] = iap_name
81 iap_id = event.get_iap_id()
83 if (iap_id_to_name.has_key(iap_id)):
84 iap_name = iap_id_to_name[iap_id]
85 self.connection_established(iap_name)
89 self._connection = conic.Connection()
90 self._connection.connect("connection-event", self._connection_cb)
91 self._connection.set_property("automatic-connection-events", True)
92 self._settings.addUsePopupListener(self._activateCallback)
97 self._settings.removeUsePopupListener(self._activateCallback)
98 self._connection.set_property("automatic-connection-events", False)
101 def _activateCallback(self, gconfClient, id, gconfEntry, x):
102 self._popup = gconfEntry.get_value().get_bool()
105 if __name__ == "__main__":
106 d = Daemon(Launcher(), Settings(), gtk.Window())