blueman icon indicating copy to clipboard operation
blueman copied to clipboard

Add an option to toggle manager visibility on clicking the tray icon

Open roket1428 opened this issue 1 year ago • 6 comments

Fixes #2346

roket1428 avatar Apr 21 '24 17:04 roket1428

If this is to be an option the gsettings should be handled in the StandardItems applet plugin https://github.com/blueman-project/blueman/blob/1fd1680d3567fd9daf61f7f74fa15f5fdb51ac4d/blueman/plugins/applet/StandardItems.py#L19

With a corresponding option for the PluginManager so users can discover and toggle it.

infirit avatar Apr 22 '24 11:04 infirit

@roket1428 let me know if you can and want to make this change. If not I can do it later this week.

infirit avatar Apr 22 '24 12:04 infirit

@infirit something like this?

roket1428 avatar Apr 22 '24 19:04 roket1428

Apologies I wasn't clear, I forget not everyone is familiar with blueman internals. The logic should now be part of the StandardItems plugin. Also plugins have a convenience function to retrieve options. I suggest something like below on top of your changes.

I'm not sold on the name of the setting toggle-manager-onclick but I'm blanking on a better alternative...

diff --git a/blueman/main/DBusProxies.py b/blueman/main/DBusProxies.py
index d1226975..27524620 100644
--- a/blueman/main/DBusProxies.py
+++ b/blueman/main/DBusProxies.py
@@ -51,7 +51,7 @@ class ManagerService(ProxyBase):
                          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 @@ class ManagerService(ProxyBase):
         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 a871b1a3..eeea12eb 100644
--- a/blueman/plugins/applet/StandardItems.py
+++ b/blueman/plugins/applet/StandardItems.py
@@ -90,7 +90,10 @@ class StandardItems(AppletPlugin, PowerStateListener):
 
     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"))

infirit avatar May 01 '24 11:05 infirit

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar May 02 '24 12:05 sonarqubecloud[bot]

@infirit I applied your changes, but I couldn't find a better alternative to the settings name (I'm open to ideas, though).

roket1428 avatar May 02 '24 12:05 roket1428