| ... |
... |
@@ -14,6 +14,7 @@ |
|
14
|
14
|
|
|
15
|
15
|
import logging
|
|
16
|
16
|
import time
|
|
|
17
|
+from typing import Optional
|
|
17
|
18
|
|
|
18
|
19
|
from gi.repository import Gio
|
|
19
|
20
|
from gi.repository import Gdk
|
| ... |
... |
@@ -29,6 +30,7 @@ |
|
29
|
30
|
from gajim.common.helpers import get_groupchat_name
|
|
30
|
31
|
from gajim.common.helpers import get_group_chat_nick
|
|
31
|
32
|
from gajim.common.helpers import get_uf_relative_time
|
|
|
33
|
+from gajim.common.helpers import AdditionalDataDict
|
|
32
|
34
|
from gajim.common.preview_helpers import filename_from_uri
|
|
33
|
35
|
from gajim.common.preview_helpers import guess_simple_file_type
|
|
34
|
36
|
|
| ... |
... |
@@ -667,7 +669,9 @@ def set_nick(self, nickname): |
|
667
|
669
|
self._ui.nick_label.set_visible(bool(nickname))
|
|
668
|
670
|
self._ui.nick_label.set_text(nickname)
|
|
669
|
671
|
|
|
670
|
|
- def set_message_text(self, text, icon_name=None, additional_data=None):
|
|
|
672
|
+ def set_message_text(self, text: str, icon_name: Optional[str] = None,
|
|
|
673
|
+ additional_data: Optional[AdditionalDataDict] = None
|
|
|
674
|
+ ) -> None:
|
|
671
|
675
|
icon = None
|
|
672
|
676
|
if icon_name is not None:
|
|
673
|
677
|
icon = Gio.Icon.new_for_string(icon_name)
|
| ... |
... |
@@ -676,12 +680,13 @@ def set_message_text(self, text, icon_name=None, additional_data=None): |
|
676
|
680
|
text, additional_data):
|
|
677
|
681
|
file_name = filename_from_uri(text)
|
|
678
|
682
|
icon, file_type = guess_simple_file_type(text)
|
|
679
|
|
- text = '%(file_type)s (%(file_name)s)' % {
|
|
680
|
|
- 'file_type': file_type,
|
|
681
|
|
- 'file_name': file_name}
|
|
682
|
|
- else:
|
|
683
|
|
- text = text.replace('\n', ' ')
|
|
|
683
|
+ text = f'{file_type} ({file_name})'
|
|
|
684
|
+
|
|
|
685
|
+ # Split by newline and display last line
|
|
|
686
|
+ lines = text.split('\n')
|
|
|
687
|
+ text = lines[-1]
|
|
684
|
688
|
self._ui.message_label.set_text(text)
|
|
|
689
|
+
|
|
685
|
690
|
if icon is None:
|
|
686
|
691
|
self._ui.message_icon.hide()
|
|
687
|
692
|
else:
|