Daniel Brötzmann pushed to branch mainwindow at gajim / gajim


Commits:
b3d0169d by wurstsalat at 2021-11-04T22:39:19+01:00
ChatList: Properly split newlines

- - - - -


1 changed file:

- gajim/gtk/chat_list.py


Changes:

=====================================
gajim/gtk/chat_list.py
=====================================
@@ -14,6 +14,7 @@
 
 import logging
 import time
+from typing import Optional
 
 from gi.repository import Gio
 from gi.repository import Gdk
@@ -29,6 +30,7 @@
 from gajim.common.helpers import get_groupchat_name
 from gajim.common.helpers import get_group_chat_nick
 from gajim.common.helpers import get_uf_relative_time
+from gajim.common.helpers import AdditionalDataDict
 from gajim.common.preview_helpers import filename_from_uri
 from gajim.common.preview_helpers import guess_simple_file_type
 
@@ -667,7 +669,9 @@ def set_nick(self, nickname):
         self._ui.nick_label.set_visible(bool(nickname))
         self._ui.nick_label.set_text(nickname)
 
-    def set_message_text(self, text, icon_name=None, additional_data=None):
+    def set_message_text(self, text: str, icon_name: Optional[str] = None,
+                         additional_data: Optional[AdditionalDataDict] = None
+                         ) -> None:
         icon = None
         if icon_name is not None:
             icon = Gio.Icon.new_for_string(icon_name)
@@ -676,12 +680,13 @@ def set_message_text(self, text, icon_name=None, 
additional_data=None):
                     text, additional_data):
                 file_name = filename_from_uri(text)
                 icon, file_type = guess_simple_file_type(text)
-                text = '%(file_type)s (%(file_name)s)' % {
-                    'file_type': file_type,
-                    'file_name': file_name}
-        else:
-            text = text.replace('\n', ' ')
+                text = f'{file_type} ({file_name})'
+
+        # Split by newline and display last line
+        lines = text.split('\n')
+        text = lines[-1]
         self._ui.message_label.set_text(text)
+
         if icon is None:
             self._ui.message_icon.hide()
         else:



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

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


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to