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


Commits:
c894c7ff by drcross2 at 2026-03-22T07:49:49+00:00
fix: MacOS: Fix copy/paste when clipboard contains text/uri-list

- - - - -


1 changed file:

- gajim/gtk/message_actions_box.py


Changes:

=====================================
gajim/gtk/message_actions_box.py
=====================================
@@ -874,21 +874,32 @@ def _on_clipboard_read_value_finished(
         try:
             file_list = clipboard.read_value_finish(result)
         except Exception as e:
-            formats = clipboard.get_formats()
-            mime_types = formats.get_mime_types()
-            InformationAlertDialog(
-                _("Pasting Content Failed"),
-                _("Error: %s (mime types: %s)") % (e, mime_types),
-            )
+            log.info("FileList read failed, trying text fallback: %s", e)
+            clipboard.read_text_async(None, 
self._on_clipboard_text_fallback_finished)
             return
 
         if file_list is None or not isinstance(file_list, Gdk.FileList):
-            log.info("No URIs pasted")
+            log.info("Unexpected type received %r, trying text fallback", 
file_list)
+            clipboard.read_text_async(None, 
self._on_clipboard_text_fallback_finished)
             return
 
         uris = [file.get_uri() for file in file_list.get_files()]
         app.window.activate_action("win.send-file", GLib.Variant("as", uris))
 
+    def _on_clipboard_text_fallback_finished(
+        self,
+        clipboard: Gdk.Clipboard,
+        result: Gio.AsyncResult,
+    ) -> None:
+        try:
+            text = clipboard.read_text_finish(result)
+        except Exception as e:
+            log.warning("Text fallback paste also failed: %s", e)
+            return
+
+        if text:
+            self._message_input.get_buffer().insert_at_cursor(text)
+
     def _on_clipboard_read_texture_finished(
         self,
         clipboard: Gdk.Clipboard,



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/c894c7ffaee55bfac00606193579478636a59a8b
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