Philipp Hörist pushed to branch master at gajim / gajim


Commits:
79140e1f by Merci Jacob at 2026-03-16T20:40:01+00:00
fix: MacOS: Fix clicking folder open button does nothing

- - - - -


3 changed files:

- gajim/gtk/util/misc.py
- typings/AppKit/__init__.pyi
- + typings/Foundation/__init__.pyi


Changes:

=====================================
gajim/gtk/util/misc.py
=====================================
@@ -8,6 +8,7 @@
 from typing import Any
 from typing import cast
 from typing import Literal
+from typing import TYPE_CHECKING
 
 import datetime
 import gc
@@ -55,6 +56,10 @@
 
 from gajim.gtk.const import GDK_MEMORY_DEFAULT
 
+if sys.platform == "darwin" or TYPE_CHECKING:
+    from AppKit import NSWorkspace
+    from Foundation import NSURL
+
 log = logging.getLogger("gajim.gtk.util")
 
 
@@ -437,7 +442,14 @@ def open_file(path: Path, *, show_in_folder: bool = False) 
-> None:
     launcher = Gtk.FileLauncher(file=Gio.File.new_for_path(str(path_absolute)))
     try:
         if show_in_folder:
-            launcher.open_containing_folder(app.window)
+            if (
+                sys.platform == "darwin"
+            ):  # Implemented as workaround for 
https://gitlab.gnome.org/GNOME/gtk/-/issues/8070
+                assert NSWorkspace is not None and NSURL is not None
+                url = NSURL.fileURLWithPath_(str(path_absolute))
+                
NSWorkspace.sharedWorkspace().activateFileViewerSelectingURLs_([url])
+            else:
+                launcher.open_containing_folder(app.window)
         else:
             launcher.launch(app.window)
     except Exception as error:


=====================================
typings/AppKit/__init__.pyi
=====================================
@@ -11,3 +11,8 @@ class NSSound:
     def alloc(cls) -> NSSound: ...
     def initWithContentsOfFile_byReference_(self, url: str, byref: bool) -> 
None: ...
     def play(self) -> None: ...
+
+class NSWorkspace:
+    @classmethod
+    def sharedWorkspace(cls) -> Any: ...
+    def activateFileViewerSelectingURLs_(self, urls: list[Any]) -> None: ...


=====================================
typings/Foundation/__init__.pyi
=====================================
@@ -0,0 +1,7 @@
+from __future__ import annotations
+
+from typing import Any
+
+class NSURL:
+    @classmethod
+    def fileURLWithPath_(cls, path: str) -> Any: ...



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/79140e1f319a55d0e613d9934d42a99f29f9620e

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/79140e1f319a55d0e613d9934d42a99f29f9620e
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to