diff --git a/blueman/gui/DeviceSelectorDialog.py b/blueman/gui/DeviceSelectorDialog.py index dfd22cd11..4c5ea2766 100644 --- a/blueman/gui/DeviceSelectorDialog.py +++ b/blueman/gui/DeviceSelectorDialog.py @@ -25,7 +25,7 @@ def __init__(self, title: str = _("Select Device"), parent: Optional[Gtk.Contain self.selector = DeviceSelectorWidget(adapter_name=adapter_name, visible=True) self.vbox.pack_start(self.selector, True, True, 0) - self.selection: Optional[Tuple[str, Device]] = None + self.selection: Optional[Tuple[str, Optional[Device]]] = None self.selector.List.connect("device-selected", self.on_device_selected) self.selector.List.connect("adapter-changed", self.on_adapter_changed) @@ -45,6 +45,6 @@ def on_row_activated(self, _treeview: Gtk.TreeView, _path: Gtk.TreePath, _view_c def on_adapter_changed(self, _devlist: DeviceList, _adapter: str) -> None: self.selection = None - def on_device_selected(self, devlist: DeviceList, device: Device, _tree_iter: Gtk.TreeIter) -> None: + def on_device_selected(self, devlist: DeviceList, device: Optional[Device], _tree_iter: Gtk.TreeIter) -> None: assert devlist.Adapter is not None self.selection = (devlist.Adapter.get_object_path(), device) diff --git a/blueman/gui/manager/ManagerMenu.py b/blueman/gui/manager/ManagerMenu.py index 2c399dc9e..d94ffad25 100644 --- a/blueman/gui/manager/ManagerMenu.py +++ b/blueman/gui/manager/ManagerMenu.py @@ -154,7 +154,7 @@ def _on_settings_changed(self, settings: Gio.Settings, key: str) -> None: logging.debug("refilter") self.blueman.List.filter.refilter() - def on_device_selected(self, _lst: ManagerDeviceList, device: Device, tree_iter: Gtk.TreeIter) -> None: + def on_device_selected(self, _lst: ManagerDeviceList, device: Optional[Device], tree_iter: Gtk.TreeIter) -> None: if tree_iter and device: self.item_device.props.sensitive = True diff --git a/blueman/gui/manager/ManagerToolbar.py b/blueman/gui/manager/ManagerToolbar.py index c042b8d61..bf0e17f35 100644 --- a/blueman/gui/manager/ManagerToolbar.py +++ b/blueman/gui/manager/ManagerToolbar.py @@ -66,8 +66,13 @@ def on_adapter_changed(self, _lst: ManagerDeviceList, adapter_path: Optional[str logging.debug(f"toolbar adapter {adapter_path}") self._update_buttons(None if adapter_path is None else Adapter(obj_path=adapter_path)) - def on_device_selected(self, dev_list: ManagerDeviceList, device: Device, _tree_iter: Gtk.TreeIter) -> None: - self._update_buttons(Adapter(obj_path=device["Adapter"])) + def on_device_selected( + self, + dev_list: ManagerDeviceList, + device: Optional[Device], + _tree_iter: Gtk.TreeIter, + ) -> None: + self._update_buttons(None if device is None else Adapter(obj_path=device["Adapter"])) def _update_buttons(self, adapter: Optional[Adapter]) -> None: powered = adapter is not None and adapter["Powered"]