def __action_connect_other_bus_cb(self, action, parameter): """connect to other bus""" dialog = AddConnectionDialog(self.data_dir, self, self.bus_history) result = dialog.run() if result == Gtk.ResponseType.OK: address = dialog.address if address == 'Session Bus': self.activate_action('connect-session-bus', None) return elif address == 'System Bus': 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))) dialog.destroy()
def __action_connect_system_bus_cb(self, action, parameter): """connect to system bus""" try: if self.system_bus is not None: return bw = BusWatch(self.data_dir, Gio.BusType.SYSTEM) self.system_bus = bw.box_bus self.stack.add_titled(self.system_bus, 'System Bus', 'System Bus') self.remove_action('connect-system-bus') except Exception as e: print(e)
def __action_connect_session_bus_cb(self, action, parameter): """connect to session bus""" try: if self.session_bus is not None: return bw = BusWatch(self.data_dir, Gio.BusType.SESSION) self.session_bus = bw.box_bus self.stack.add_titled(self.session_bus, 'Session Bus', 'Session Bus') self.remove_action('connect-session-bus') 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) self.stack.set_visible_child_name(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