From 1bca848cca15a99593e72e45a9787606c85387f7 Mon Sep 17 00:00:00 2001 From: roket1428 Date: Thu, 2 May 2024 14:45:08 +0300 Subject: [PATCH] Move the toggle logic to the StandardItems plugin --- blueman/main/DBusProxies.py | 12 +++--------- blueman/plugins/applet/StandardItems.py | 5 ++++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/blueman/main/DBusProxies.py b/blueman/main/DBusProxies.py index d12269759..27524620b 100644 --- a/blueman/main/DBusProxies.py +++ b/blueman/main/DBusProxies.py @@ -51,7 +51,7 @@ def __init__(self) -> None: object_path="/org/blueman/Manager", flags=Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION) - def _activate(self) -> None: + def activate(self) -> None: try: param = GLib.Variant('(a{sv})', ({},)) self.call_sync("Activate", param, Gio.DBusCallFlags.NONE, -1, None) @@ -79,11 +79,5 @@ def call_finish(proxy: "ManagerService", resp: Gio.AsyncResult) -> None: param = GLib.Variant('(sava{sv})', (name, [], {})) self.call('ActivateAction', param, Gio.DBusCallFlags.NONE, -1, None, call_finish) - def startstop(self) -> None: - if Gio.Settings(schema_id='org.blueman.plugins.standarditems')['toggle-manager-onclick']: - if self.get_name_owner() is None: - self._activate() - else: - self._call_action("Quit") - else: - self._activate() + def quit(self) -> None: + self._call_action("Quit") diff --git a/blueman/plugins/applet/StandardItems.py b/blueman/plugins/applet/StandardItems.py index a871b1a31..eeea12eb5 100644 --- a/blueman/plugins/applet/StandardItems.py +++ b/blueman/plugins/applet/StandardItems.py @@ -90,7 +90,10 @@ def on_send(self) -> None: def on_devices(self) -> None: m = ManagerService() - m.startstop() + if m.get_name_owner() and self.get_option("toggle-manager-onclick"): + m.quit() + else: + m.activate() def on_adapters(self) -> None: launch("blueman-adapters", name=_("Adapter Preferences"))