Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 17, 2024

Conversation

roket1428
Copy link
Contributor

Fixes #2346

@infirit
Copy link
Contributor

infirit commented Apr 22, 2024

If this is to be an option the gsettings should be handled in the StandardItems applet plugin

class StandardItems(AppletPlugin, PowerStateListener):

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

@infirit
Copy link
Contributor

infirit commented Apr 22, 2024

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

@roket1428
Copy link
Contributor Author

@infirit something like this?

@infirit
Copy link
Contributor

infirit commented May 1, 2024

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"))

Copy link

sonarcloud bot commented May 2, 2024

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

@roket1428
Copy link
Contributor Author

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

@cschramm cschramm added this to the 2.4.2 milestone May 9, 2024
@cschramm cschramm requested a review from infirit May 16, 2024 05:25
@infirit infirit merged commit 1bca848 into blueman-project:main May 17, 2024
21 checks passed
@cschramm cschramm mentioned this pull request May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After 2.4, clicking the tray icon no longer minimizes the GUI.
3 participants