Daniel Brötzmann pushed to branch master at gajim / gajim
Commits:
43d4a27f by wurstsalat at 2025-04-18T12:28:44+02:00
fix: Clipboard: Guard for errors and show error dialog
- - - - -
3 changed files:
- gajim/gtk/chat_stack.py
- gajim/gtk/message_actions_box.py
- gajim/gtk/message_input.py
Changes:
=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -249,12 +249,11 @@ def _on_primary_clipboard_read_text_finished(
clipboard: Gdk.Clipboard,
result: Gio.AsyncResult,
) -> None:
- text = None
-
try:
text = clipboard.read_text_finish(result)
except Exception as e:
- log.exception("Error while trying to paste text: %s", e)
+ SimpleDialog(_("Pasting Content Failed"), _("Error: %s") % e)
+ return
if text is None:
log.info("No text pasted")
=====================================
gajim/gtk/message_actions_box.py
=====================================
@@ -881,7 +881,17 @@ def _on_clipboard_read_value_finished(
clipboard: Gdk.Clipboard,
result: Gio.AsyncResult,
) -> None:
- file_list = clipboard.read_value_finish(result)
+ try:
+ file_list = clipboard.read_value_finish(result)
+ except Exception as e:
+ formats = clipboard.get_formats()
+ mime_types = formats.get_mime_types()
+ SimpleDialog(
+ _("Pasting Content Failed"),
+ _("Error: %s (mime types: %s)") % (e, mime_types),
+ )
+ return
+
if file_list is None or not isinstance(file_list, Gdk.FileList):
log.info("No URIs pasted")
return
@@ -897,7 +907,8 @@ def _on_clipboard_read_texture_finished(
try:
texture = clipboard.read_texture_finish(result)
except GLib.Error as e:
- log.error("Could not read clipboard content: %s", e)
+ self._ui.input_overlay.set_visible(False)
+ SimpleDialog(_("Pasting Content Failed"), _("Error: %s") % e)
return
if texture is None:
=====================================
gajim/gtk/message_input.py
=====================================
@@ -35,6 +35,7 @@
from gajim.gtk.completion.nickname import NicknameCompletionProvider
from gajim.gtk.completion.popover import CompletionPopover
from gajim.gtk.const import MAX_MESSAGE_LENGTH
+from gajim.gtk.dialogs import SimpleDialog
from gajim.gtk.menus import get_message_input_extra_context_menu
from gajim.gtk.util.misc import scroll_to_end
from gajim.gtk.widgets import GdkRectangle
@@ -396,12 +397,11 @@ def paste_as_code_block(self) -> None:
def _on_clipboard_read_text_finished(
self, clipboard: Gdk.Clipboard, result: Gio.AsyncResult, action_name:
str
) -> None:
- text = None
-
try:
text = clipboard.read_text_finish(result)
except Exception as e:
- log.exception("Error while trying to paste text: %s", e)
+ SimpleDialog(_("Pasting Content Failed"), _("Error: %s") % e)
+ return
if text is None:
log.info("No text pasted")
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/43d4a27f4f772d0a582fdfdc1971622ae10ffba7
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/43d4a27f4f772d0a582fdfdc1971622ae10ffba7
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]