telepathy-gabble: console UI: throw up a message when the connection dies

Simon McVittie smcv at kemper.freedesktop.org
Mon Oct 14 08:21:20 PDT 2013


Module: telepathy-gabble
Branch: master
Commit: 0c8fadad44e3b4acc9a2086f59df9d653128dbd8
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=0c8fadad44e3b4acc9a2086f59df9d653128dbd8

Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Mon Feb 13 13:04:09 2012 +0000

console UI: throw up a message when the connection dies

---

 plugins/telepathy-gabble-xmpp-console |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/plugins/telepathy-gabble-xmpp-console b/plugins/telepathy-gabble-xmpp-console
index 7e473d4..d54d52a 100755
--- a/plugins/telepathy-gabble-xmpp-console
+++ b/plugins/telepathy-gabble-xmpp-console
@@ -324,10 +324,14 @@ plugin installed.""" % locals()
 
         self.console_proxy = Gio.DBusProxy.new_sync(bus, 0, None,
             connection_bus_name, sidecar_path, CONSOLE_IFACE, None)
+        self.console_proxy.connect('notify::g-name-owner', self.__console_noc_cb)
 
         # Build up the UI
+        self.grid = Gtk.Grid()
+        self.add(self.grid)
+
         self.nb = Gtk.Notebook()
-        self.add(self.nb)
+        self.grid.attach(self.nb, 0, 0, 1, 1)
 
         self.iq = IQPage(self.console_proxy)
         self.nb.insert_page(self.iq,
@@ -344,8 +348,28 @@ plugin installed.""" % locals()
             Gtk.Label.new_with_mnemonic("_Monitor network traffic"),
             self.SNOOPY_PAGE)
 
+        self.infobar = Gtk.InfoBar()
+        self.infobar.set_message_type(Gtk.MessageType.WARNING)
+        self.infobar.set_no_show_all(True)
+        label = Gtk.Label("The connection went away! Time to leave.")
+        label.show()
+        self.infobar.get_content_area().add(label)
+        self.infobar_close_button = self.infobar.add_button("Close", Gtk.ResponseType.CLOSE)
+        self.infobar.connect('response', lambda infobar, response: Gtk.main_quit())
+        self.infobar.connect('close', lambda infobar: Gtk.main_quit())
+
+        self.grid.attach_next_to(self.infobar, self.nb,
+            Gtk.PositionType.BOTTOM, 1, 1)
+
         self.connect('destroy', Window.__destroy_cb)
 
+    def __console_noc_cb(self, *args):
+        if self.console_proxy.get_name_owner() is None:
+            self.infobar.show()
+            self.infobar_close_button.grab_focus()
+            self.nb.set_sensitive(False)
+        # TODO: reconnect if the connection comes back.
+
     def __destroy_cb(self):
         try:
             self.snoopy.teardown()



More information about the telepathy-commits mailing list