diff --git a/blueman/config/AutoConnectConfig.py b/blueman/config/AutoConnectConfig.py index ab5869cfc..b453c9d4b 100644 --- a/blueman/config/AutoConnectConfig.py +++ b/blueman/config/AutoConnectConfig.py @@ -1,4 +1,5 @@ from typing import Tuple +from blueman.bluemantyping import BtAddress import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk @@ -9,7 +10,7 @@ class AutoConnectConfig(Gio.Settings): def __init__(self) -> None: super().__init__(schema_id="org.blueman.plugins.autoconnect") - def bind_to_menuitem(self, item: Gtk.CheckMenuItem, data: Tuple[str, str]) -> None: + def bind_to_menuitem(self, item: Gtk.CheckMenuItem, data: Tuple[BtAddress, str]) -> None: def switch(active: bool) -> None: services = set(self["services"]) if active: diff --git a/blueman/gui/manager/ManagerDeviceMenu.py b/blueman/gui/manager/ManagerDeviceMenu.py index c3c746b84..fc8502106 100644 --- a/blueman/gui/manager/ManagerDeviceMenu.py +++ b/blueman/gui/manager/ManagerDeviceMenu.py @@ -3,6 +3,7 @@ from gettext import gettext as _ from operator import attrgetter from typing import Dict, List, Tuple, Optional, TYPE_CHECKING, Union, Iterable +from blueman.bluemantyping import BtAddress from blueman.bluemantyping import ObjectPath from blueman.Functions import create_menuitem, e_ @@ -328,6 +329,7 @@ def generate(self) -> None: config = AutoConnectConfig() generic_service = ServiceUUID("00000000-0000-0000-0000-000000000000") object_path = self.SelectedDevice.get_object_path() + btaddress: BtAddress = self.SelectedDevice["Address"] generic_autoconnect = (object_path, str(generic_service)) in set(config["services"]) if row["connected"] or generic_autoconnect or autoconnect_items: @@ -335,7 +337,7 @@ def generate(self) -> None: if row["connected"] or generic_autoconnect: item = Gtk.CheckMenuItem(label=generic_service.name) - config.bind_to_menuitem(item, (str(object_path), str(generic_service))) + config.bind_to_menuitem(item, (btaddress, str(generic_service))) item.show() self.append(item) diff --git a/blueman/plugins/applet/AutoConnect.py b/blueman/plugins/applet/AutoConnect.py index f187900a5..9e84ac7ce 100644 --- a/blueman/plugins/applet/AutoConnect.py +++ b/blueman/plugins/applet/AutoConnect.py @@ -41,8 +41,8 @@ def on_adapter_property_changed(self, path: ObjectPath, key: str, value: Any) -> self._run() def _run(self) -> bool: - for address, uuid in self.get_option('services'): - device = self.parent.Manager.find_device(address) + for btaddress, uuid in self.get_option('services'): + device = self.parent.Manager.find_device(btaddress) if device is None or device.get("Connected"): continue diff --git a/blueman/plugins/manager/Services.py b/blueman/plugins/manager/Services.py index 5aaf6c7ba..56c783363 100644 --- a/blueman/plugins/manager/Services.py +++ b/blueman/plugins/manager/Services.py @@ -1,4 +1,5 @@ from typing import List, Callable +from blueman.bluemantyping import BtAddress import cairo @@ -73,14 +74,14 @@ def on_request_menu_items( items.append(DeviceMenuItem(item, DeviceMenuItem.Group.DISCONNECT, service.priority + 100)) item.show() - object_path = device.get_object_path() + btaddress: BtAddress = device["Address"] if services: config = AutoConnectConfig() autoconnect_services = set(config["services"]) for service in services: - if service.connected_instances or (object_path, service.uuid) in autoconnect_services: + if service.connected_instances or (btaddress, service.uuid) in autoconnect_services: item = Gtk.CheckMenuItem(label=service.name) - config.bind_to_menuitem(item, (object_path, service.uuid)) + config.bind_to_menuitem(item, (btaddress, service.uuid)) item.show() items.append(DeviceMenuItem(item, DeviceMenuItem.Group.AUTOCONNECT, service.priority))