| ... |
... |
@@ -53,14 +53,14 @@ |
|
53
|
53
|
|
|
54
|
54
|
|
|
55
|
55
|
class ChatList(Gtk.ListBox, EventHelper):
|
|
56
|
|
- def __init__(self, workspace_id):
|
|
|
56
|
+ def __init__(self, workspace_id: str) -> None:
|
|
57
|
57
|
Gtk.ListBox.__init__(self)
|
|
58
|
58
|
EventHelper.__init__(self)
|
|
|
59
|
+ self._workspace_id = workspace_id
|
|
59
|
60
|
|
|
60
|
61
|
self._chats: Dict[Tuple[str, JID], Any] = {}
|
|
61
|
62
|
self._current_filter: str = 'all'
|
|
62
|
63
|
self._current_filter_text: str = ''
|
|
63
|
|
- self._workspace_id: str = workspace_id
|
|
64
|
64
|
|
|
65
|
65
|
self.get_style_context().add_class('chatlist')
|
|
66
|
66
|
self.set_filter_func(self._filter_func)
|
| ... |
... |
@@ -386,7 +386,9 @@ def _on_message_received(self, event): |
|
386
|
386
|
row.set_stanza_id(stanza_id)
|
|
387
|
387
|
row.set_message_id(event.unique_id)
|
|
388
|
388
|
row.set_message_text(
|
|
389
|
|
- event.msgtxt, additional_data=event.additional_data)
|
|
|
389
|
+ event.msgtxt,
|
|
|
390
|
+ nickname=nick,
|
|
|
391
|
+ additional_data=event.additional_data)
|
|
390
|
392
|
|
|
391
|
393
|
self._add_unread(row, event.properties, event.msgtxt)
|
|
392
|
394
|
self.invalidate_sort()
|
| ... |
... |
@@ -420,23 +422,25 @@ def _on_message_sent(self, event): |
|
420
|
422
|
if own_jid.bare_match(event.jid):
|
|
421
|
423
|
nick = ''
|
|
422
|
424
|
else:
|
|
423
|
|
- nick = _('Me: ')
|
|
|
425
|
+ nick = _('Me')
|
|
424
|
426
|
row.set_nick(nick)
|
|
425
|
427
|
|
|
426
|
428
|
# Set timestamp if it's None (outgoing MUC messages)
|
|
427
|
429
|
row.set_timestamp(event.timestamp or time.time())
|
|
428
|
430
|
row.set_message_text(
|
|
429
|
|
- event.message, additional_data=event.additional_data)
|
|
|
431
|
+ event.message,
|
|
|
432
|
+ nickname=app.nicks[event.account],
|
|
|
433
|
+ additional_data=event.additional_data)
|
|
430
|
434
|
self.invalidate_sort()
|
|
431
|
435
|
|
|
432
|
436
|
@staticmethod
|
|
433
|
437
|
def _get_nick_for_received_message(event):
|
|
434
|
|
- nick = _('Me: ')
|
|
|
438
|
+ nick = _('Me')
|
|
435
|
439
|
if event.properties.type.is_groupchat:
|
|
436
|
440
|
event_nick = event.properties.muc_nickname
|
|
437
|
441
|
our_nick = get_group_chat_nick(event.account, event.jid)
|
|
438
|
442
|
if event_nick != our_nick:
|
|
439
|
|
- nick = _('%(incoming_nick)s: ') % {'incoming_nick': event_nick}
|
|
|
443
|
+ nick = event_nick
|
|
440
|
444
|
else:
|
|
441
|
445
|
con = app.get_client(event.account)
|
|
442
|
446
|
own_jid = con.get_own_jid()
|
| ... |
... |
@@ -569,21 +573,24 @@ def __init__(self, workspace_id: str, account: str, jid: JID, type_: str, |
|
569
|
573
|
message_text = get_retraction_text(
|
|
570
|
574
|
self.account, retracted_by, reason)
|
|
571
|
575
|
|
|
572
|
|
- self.set_message_text(
|
|
573
|
|
- message_text, additional_data=line.additional_data)
|
|
574
|
576
|
if line.kind in (KindConstant.CHAT_MSG_SENT,
|
|
575
|
577
|
KindConstant.SINGLE_MSG_SENT):
|
|
576
|
|
- self._ui.nick_label.set_text(_('Me:'))
|
|
577
|
|
- self._ui.nick_label.show()
|
|
|
578
|
+ self.set_nick(_('Me'))
|
|
|
579
|
+ me_nickname = app.nicks[account]
|
|
578
|
580
|
|
|
579
|
581
|
if line.kind == KindConstant.GC_MSG:
|
|
580
|
582
|
our_nick = get_group_chat_nick(account, jid)
|
|
581
|
583
|
if line.contact_name == our_nick:
|
|
582
|
|
- self._ui.nick_label.set_text(_('Me:'))
|
|
|
584
|
+ self.set_nick(_('Me'))
|
|
|
585
|
+ me_nickname = our_nick
|
|
583
|
586
|
else:
|
|
584
|
|
- self._ui.nick_label.set_text(_('%(muc_nick)s:') % {
|
|
585
|
|
- 'muc_nick': line.contact_name})
|
|
586
|
|
- self._ui.nick_label.show()
|
|
|
587
|
+ self.set_nick(line.contact_name)
|
|
|
588
|
+ me_nickname = line.contact_name
|
|
|
589
|
+
|
|
|
590
|
+ self.set_message_text(
|
|
|
591
|
+ message_text,
|
|
|
592
|
+ nickname=me_nickname,
|
|
|
593
|
+ additional_data=line.additional_data)
|
|
587
|
594
|
|
|
588
|
595
|
self.timestamp = line.time
|
|
589
|
596
|
uf_timestamp = get_uf_relative_time(line.time)
|
| ... |
... |
@@ -821,9 +828,13 @@ def update_time(self) -> None: |
|
821
|
828
|
|
|
822
|
829
|
def set_nick(self, nickname: str) -> None:
|
|
823
|
830
|
self._ui.nick_label.set_visible(bool(nickname))
|
|
824
|
|
- self._ui.nick_label.set_text(nickname)
|
|
|
831
|
+ self._ui.nick_label.set_text(
|
|
|
832
|
+ _('%(nickname)s:') % {'nickname': nickname})
|
|
825
|
833
|
|
|
826
|
|
- def set_message_text(self, text: str, icon_name: Optional[str] = None,
|
|
|
834
|
+ def set_message_text(self,
|
|
|
835
|
+ text: str,
|
|
|
836
|
+ nickname: Optional[str] = None,
|
|
|
837
|
+ icon_name: Optional[str] = None,
|
|
827
|
838
|
additional_data: Optional[AdditionalDataDict] = None
|
|
828
|
839
|
) -> None:
|
|
829
|
840
|
icon = None
|
| ... |
... |
@@ -836,10 +847,16 @@ def set_message_text(self, text: str, icon_name: Optional[str] = None, |
|
836
|
847
|
icon, file_type = guess_simple_file_type(text)
|
|
837
|
848
|
text = f'{file_type} ({file_name})'
|
|
838
|
849
|
|
|
|
850
|
+ text = GLib.markup_escape_text(text)
|
|
|
851
|
+ if text.startswith('/me') and nickname is not None:
|
|
|
852
|
+ nickname = GLib.markup_escape_text(nickname)
|
|
|
853
|
+ text = text.replace('/me', f'* {nickname}', 1)
|
|
|
854
|
+ text = f'<i>{text}</i>'
|
|
|
855
|
+
|
|
839
|
856
|
# Split by newline and display last line
|
|
840
|
857
|
lines = text.split('\n')
|
|
841
|
858
|
text = lines[-1]
|
|
842
|
|
- self._ui.message_label.set_text(text)
|
|
|
859
|
+ self._ui.message_label.set_markup(text)
|
|
843
|
860
|
|
|
844
|
861
|
if icon is None:
|
|
845
|
862
|
self._ui.message_icon.hide()
|