def notify(self, device, service_interface, conn_args): dprint(device, service_interface, conn_args) item = {} object_path = device.get_object_path() try: adapter = Adapter(device.Adapter) except: dprint("adapter not found") return props = adapter.get_properties() item["adapter"] = props["Address"] item["address"] = device.Address item["alias"] = device.Alias item["icon"] = device.Icon item["service"] = service_interface item["conn_args"] = conn_args item["time"] = time.time() item["device"] = device #device object item["mitem"] = None #menu item object for i in RecentConns.items: if i["adapter"] == item["adapter"] and \ i["address"] == item["address"] and \ i["service"] == item["service"] and \ i["conn_args"] == item["conn_args"]: i["time"] = item["time"] if i["gsignal"]: i["device"].disconnect(i["gsignal"]) i["device"] = item["device"] i["gsignal"] = item["device"].connect("invalidated", self.on_device_removed, i) self.initialize() return item["gsignal"] = item["device"].connect("invalidated", self.on_device_removed, item) RecentConns.items.append(item) self.initialize() self.store_state()
def notify(self, service): device = service.device dprint(device, service, service.uuid) item = {} try: adapter = Adapter(device['Adapter']) except: dprint("adapter not found") return props = adapter.get_properties() item["adapter"] = props["Address"] item["address"] = device['Address'] item["alias"] = device['Alias'] try: item["icon"] = device['Icon'] except KeyError: item["icon"] = 'blueman' item["name"] = service.name item["uuid"] = service.uuid item["time"] = time.time() item["device"] = device.get_object_path() item["mitem"] = None #menu item object for i in RecentConns.items: if i["adapter"] == item["adapter"] and \ i["address"] == item["address"] and \ i["uuid"] == item["uuid"]: i["time"] = item["time"] i["device"] = item["device"] self.initialize() return RecentConns.items.append(item) self.initialize() self.store_state()