[d-feet: 3/7] DFeetWindow: factor out connect_to(address)
- From: Thomas Bechtold <toabctl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [d-feet: 3/7] DFeetWindow: factor out connect_to(address)
- Date: Wed, 15 Apr 2020 09:53:48 +0000 (UTC)
commit e93654fab836d63ef055e7ffd392481880256ac5
Author: Marc-André Lureau <marcandre lureau redhat com>
Date: Thu Mar 26 23:08:00 2020 +0100
DFeetWindow: factor out connect_to(address)
Reused in the following patch. Also returns whether attempt was
successfull.
Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>
src/dfeet/window.py | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/src/dfeet/window.py b/src/dfeet/window.py
index bfc08cc..2a91a23 100644
--- a/src/dfeet/window.py
+++ b/src/dfeet/window.py
@@ -147,6 +147,23 @@ class DFeetWindow(Gtk.ApplicationWindow):
except Exception as e:
print(e)
+ def connect_to(self, address):
+ """connect to given bus address"""
+ try:
+ bw = BusWatch(self.data_dir, address)
+ self.stack.add_titled(bw.box_bus, address, address)
+ # Fill history
+ if address in self.bus_history:
+ self.bus_history.remove(address)
+ self.bus_history.insert(0, address)
+ # Truncating history
+ if (len(self.bus_history) > self.HISTORY_MAX_SIZE):
+ self.bus_history = self.bus_history[0:self.HISTORY_MAX_SIZE]
+ except Exception as e:
+ print("can not connect to '%s': %s" % (address, str(e)))
+ return False
+ return True
+
def __action_connect_other_bus_cb(self, action, parameter):
"""connect to other bus"""
dialog = AddConnectionDialog(self.data_dir, self, self.bus_history)
@@ -160,18 +177,7 @@ class DFeetWindow(Gtk.ApplicationWindow):
self.activate_action('connect-system-bus', None)
return
else:
- try:
- bw = BusWatch(self.data_dir, address)
- self.stack.add_titled(bw.box_bus, address, address)
- # Fill history
- if address in self.bus_history:
- self.bus_history.remove(address)
- self.bus_history.insert(0, address)
- # Truncating history
- if (len(self.bus_history) > self.HISTORY_MAX_SIZE):
- self.bus_history = self.bus_history[0:self.HISTORY_MAX_SIZE]
- except Exception as e:
- print("can not connect to '%s': %s" % (address, str(e)))
+ self.connect_to(address)
dialog.destroy()
def __action_close_bus_cb(self, action, parameter):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]