blueman
blueman copied to clipboard
Add an option to toggle manager visibility on clicking the tray icon
Fixes #2346
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.
@roket1428 let me know if you can and want to make this change. If not I can do it later this week.
@infirit something like this?
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"))
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
No data about Duplication
@infirit I applied your changes, but I couldn't find a better alternative to the settings name (I'm open to ideas, though).