| ... |
... |
@@ -12,10 +12,11 @@ |
|
12
|
12
|
# You should have received a copy of the GNU General Public License
|
|
13
|
13
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
14
|
14
|
|
|
15
|
|
-from typing import Dict
|
|
16
|
|
-from typing import Tuple
|
|
|
15
|
+from __future__ import annotations
|
|
17
|
16
|
from typing import Optional
|
|
18
|
17
|
from typing import Any
|
|
|
18
|
+from typing import cast
|
|
|
19
|
+from typing import Union
|
|
19
|
20
|
|
|
20
|
21
|
import logging
|
|
21
|
22
|
import time
|
| ... |
... |
@@ -34,6 +35,16 @@ |
|
34
|
35
|
from gajim.common.const import Direction
|
|
35
|
36
|
from gajim.common.const import KindConstant
|
|
36
|
37
|
from gajim.common.const import RowHeaderType
|
|
|
38
|
+from gajim.common.events import ApplicationEvent
|
|
|
39
|
+from gajim.common.events import BookmarksReceived
|
|
|
40
|
+from gajim.common.events import FileRequestReceivedEvent
|
|
|
41
|
+from gajim.common.events import JingleRequestReceived
|
|
|
42
|
+from gajim.common.events import MessageUpdated
|
|
|
43
|
+from gajim.common.events import MessageSent
|
|
|
44
|
+from gajim.common.events import MessageReceived
|
|
|
45
|
+from gajim.common.events import MamMessageReceived
|
|
|
46
|
+from gajim.common.events import GcMessageReceived
|
|
|
47
|
+from gajim.common.events import PresenceReceived
|
|
37
|
48
|
from gajim.common.i18n import _
|
|
38
|
49
|
from gajim.common.helpers import get_groupchat_name
|
|
39
|
50
|
from gajim.common.helpers import get_group_chat_nick
|
| ... |
... |
@@ -41,6 +52,9 @@ |
|
41
|
52
|
from gajim.common.helpers import get_uf_relative_time
|
|
42
|
53
|
from gajim.common.helpers import message_needs_highlight
|
|
43
|
54
|
from gajim.common.helpers import AdditionalDataDict
|
|
|
55
|
+from gajim.common.modules.contacts import BareContact
|
|
|
56
|
+from gajim.common.modules.contacts import GroupchatContact
|
|
|
57
|
+from gajim.common.modules.contacts import GroupchatParticipant
|
|
44
|
58
|
from gajim.common.preview_helpers import filename_from_uri
|
|
45
|
59
|
from gajim.common.preview_helpers import guess_simple_file_type
|
|
46
|
60
|
|
| ... |
... |
@@ -50,6 +64,9 @@ |
|
50
|
64
|
|
|
51
|
65
|
log = logging.getLogger('gajim.gui.chatlist')
|
|
52
|
66
|
|
|
|
67
|
+MessageEventT = Union[MessageReceived, GcMessageReceived, MamMessageReceived]
|
|
|
68
|
+ContactT = Union[BareContact, GroupchatContact, GroupchatParticipant]
|
|
|
69
|
+
|
|
53
|
70
|
|
|
54
|
71
|
class ChatList(Gtk.ListBox, EventHelper):
|
|
55
|
72
|
def __init__(self, workspace_id: str) -> None:
|
| ... |
... |
@@ -57,7 +74,7 @@ def __init__(self, workspace_id: str) -> None: |
|
57
|
74
|
EventHelper.__init__(self)
|
|
58
|
75
|
self._workspace_id = workspace_id
|
|
59
|
76
|
|
|
60
|
|
- self._chats: Dict[Tuple[str, JID], Any] = {}
|
|
|
77
|
+ self._chats: dict[tuple[str, JID], Any] = {}
|
|
61
|
78
|
self._current_filter: str = 'all'
|
|
62
|
79
|
self._current_filter_text: str = ''
|
|
63
|
80
|
|
| ... |
... |
@@ -128,21 +145,23 @@ def mark_as_read(self, account: str, jid: JID) -> None: |
|
128
|
145
|
|
|
129
|
146
|
def emit_unread_changed(self) -> None:
|
|
130
|
147
|
count = self.get_unread_count()
|
|
131
|
|
- self.get_parent().emit('unread-count-changed',
|
|
132
|
|
- self._workspace_id,
|
|
133
|
|
- count)
|
|
|
148
|
+ chat_list = cast(ChatList, self.get_parent())
|
|
|
149
|
+ chat_list.emit('unread-count-changed',
|
|
|
150
|
+ self._workspace_id,
|
|
|
151
|
+ count)
|
|
134
|
152
|
|
|
135
|
153
|
def is_visible(self) -> bool:
|
|
136
|
|
- return self.get_parent().get_property('child-widget') == self
|
|
|
154
|
+ chat_list = cast(ChatList, self.get_parent())
|
|
|
155
|
+ return chat_list.get_property('child-widget') == self
|
|
137
|
156
|
|
|
138
|
|
- def _on_destroy(self, *args):
|
|
|
157
|
+ def _on_destroy(self, _widget: Gtk.Widget) -> None:
|
|
139
|
158
|
GLib.source_remove(self._timer_id)
|
|
140
|
159
|
|
|
141
|
160
|
def _update_timer(self) -> bool:
|
|
142
|
161
|
self.update_time()
|
|
143
|
162
|
return True
|
|
144
|
163
|
|
|
145
|
|
- def _filter_func(self, row):
|
|
|
164
|
+ def _filter_func(self, row: ChatRow) -> bool:
|
|
146
|
165
|
is_groupchat = row.type == 'groupchat'
|
|
147
|
166
|
if self._current_filter == 'chats' and is_groupchat:
|
|
148
|
167
|
return False
|
| ... |
... |
@@ -156,7 +175,7 @@ def _filter_func(self, row): |
|
156
|
175
|
return text in row.contact_name.lower()
|
|
157
|
176
|
|
|
158
|
177
|
@staticmethod
|
|
159
|
|
- def _header_func(row, before):
|
|
|
178
|
+ def _header_func(row: ChatRow, before: ChatRow) -> None:
|
|
160
|
179
|
if before is None:
|
|
161
|
180
|
if row.is_pinned:
|
|
162
|
181
|
row.header = RowHeaderType.PINNED
|
| ... |
... |
@@ -182,7 +201,7 @@ def _header_func(row, before): |
|
182
|
201
|
else:
|
|
183
|
202
|
row.header = None
|
|
184
|
203
|
|
|
185
|
|
- def _sort_func(self, row1, row2):
|
|
|
204
|
+ def _sort_func(self, row1: ChatRow, row2: ChatRow) -> int:
|
|
186
|
205
|
if self._mouseover:
|
|
187
|
206
|
log.debug('Mouseover active, don’t sort rows')
|
|
188
|
207
|
return 0
|
| ... |
... |
@@ -200,7 +219,10 @@ def _sort_func(self, row1, row2): |
|
200
|
219
|
# Sort by timestamp
|
|
201
|
220
|
return -1 if row1.timestamp > row2.timestamp else 1
|
|
202
|
221
|
|
|
203
|
|
- def _on_mouse_focus_changed(self, _widget, event):
|
|
|
222
|
+ def _on_mouse_focus_changed(self,
|
|
|
223
|
+ _widget: Gtk.ListBox,
|
|
|
224
|
+ event: Gdk.EventCrossing
|
|
|
225
|
+ ) -> None:
|
|
204
|
226
|
if event.type == Gdk.EventType.ENTER_NOTIFY:
|
|
205
|
227
|
self._mouseover = True
|
|
206
|
228
|
|
| ... |
... |
@@ -219,7 +241,7 @@ def _set_placeholder(self) -> None: |
|
219
|
241
|
self.set_placeholder(button)
|
|
220
|
242
|
|
|
221
|
243
|
@staticmethod
|
|
222
|
|
- def _on_start_chat_clicked(_widget):
|
|
|
244
|
+ def _on_start_chat_clicked(_button: Gtk.Button) -> None:
|
|
223
|
245
|
app.app.activate_action('start-chat', GLib.Variant('s', ''))
|
|
224
|
246
|
|
|
225
|
247
|
def set_filter(self, name: str) -> None:
|
| ... |
... |
@@ -258,6 +280,7 @@ def select_next_chat(self, direction: Direction, |
|
258
|
280
|
row = self.get_row_at_index(0)
|
|
259
|
281
|
if row is None:
|
|
260
|
282
|
return
|
|
|
283
|
+ assert isinstance(row, ChatRow)
|
|
261
|
284
|
self.select_chat(row.account, row.jid)
|
|
262
|
285
|
return
|
|
263
|
286
|
|
| ... |
... |
@@ -280,6 +303,7 @@ def select_next_chat(self, direction: Direction, |
|
280
|
303
|
row = self.get_row_at_index(index)
|
|
281
|
304
|
if row is None:
|
|
282
|
305
|
return
|
|
|
306
|
+ assert isinstance(row, ChatRow)
|
|
283
|
307
|
if row.unread_count > 0:
|
|
284
|
308
|
unread_found = True
|
|
285
|
309
|
break
|
| ... |
... |
@@ -301,14 +325,17 @@ def select_next_chat(self, direction: Direction, |
|
301
|
325
|
else:
|
|
302
|
326
|
last = len(self.get_children()) - 1
|
|
303
|
327
|
next_row = self.get_row_at_index(last)
|
|
|
328
|
+ assert isinstance(next_row, ChatRow)
|
|
304
|
329
|
self.select_chat(next_row.account, next_row.jid)
|
|
305
|
330
|
return
|
|
306
|
331
|
|
|
|
332
|
+ assert isinstance(next_row, ChatRow)
|
|
307
|
333
|
self.select_chat(next_row.account, next_row.jid)
|
|
308
|
334
|
|
|
309
|
335
|
def select_chat_number(self, number: int) -> None:
|
|
310
|
336
|
row = self.get_row_at_index(number)
|
|
311
|
337
|
if row is not None:
|
|
|
338
|
+ assert isinstance(row, ChatRow)
|
|
312
|
339
|
self.select_chat(row.account, row.jid)
|
|
313
|
340
|
|
|
314
|
341
|
def toggle_chat_pinned(self, account: str, jid: JID) -> None:
|
| ... |
... |
@@ -331,8 +358,8 @@ def remove_chats_for_account(self, account: str) -> None: |
|
331
|
358
|
self.remove_chat(account, jid)
|
|
332
|
359
|
self.emit_unread_changed()
|
|
333
|
360
|
|
|
334
|
|
- def get_selected_chat(self) -> Optional[Any]:
|
|
335
|
|
- row = self.get_selected_row()
|
|
|
361
|
+ def get_selected_chat(self) -> Optional[ChatRow]:
|
|
|
362
|
+ row = cast(ChatRow, self.get_selected_row())
|
|
336
|
363
|
if row is None:
|
|
337
|
364
|
return None
|
|
338
|
365
|
return row
|
| ... |
... |
@@ -340,8 +367,8 @@ def get_selected_chat(self) -> Optional[Any]: |
|
340
|
367
|
def contains_chat(self, account: str, jid: JID) -> bool:
|
|
341
|
368
|
return self._chats.get((account, jid)) is not None
|
|
342
|
369
|
|
|
343
|
|
- def get_open_chats(self):
|
|
344
|
|
- open_chats = []
|
|
|
370
|
+ def get_open_chats(self) -> list[tuple[str, JID, str, bool]]:
|
|
|
371
|
+ open_chats: list[tuple[str, JID, str, bool]] = []
|
|
345
|
372
|
for key, value in self._chats.items():
|
|
346
|
373
|
open_chats.append(key + (value.type, value.is_pinned))
|
|
347
|
374
|
return open_chats
|
| ... |
... |
@@ -350,7 +377,7 @@ def update_time(self) -> None: |
|
350
|
377
|
for _key, row in self._chats.items():
|
|
351
|
378
|
row.update_time()
|
|
352
|
379
|
|
|
353
|
|
- def process_event(self, event):
|
|
|
380
|
+ def process_event(self, event: ApplicationEvent) -> None:
|
|
354
|
381
|
if event.name in ('message-received',
|
|
355
|
382
|
'mam-message-received',
|
|
356
|
383
|
'gc-message-received'):
|
| ... |
... |
@@ -368,10 +395,12 @@ def process_event(self, event): |
|
368
|
395
|
else:
|
|
369
|
396
|
log.warning('Unhandled Event: %s', event.name)
|
|
370
|
397
|
|
|
371
|
|
- def _on_message_received(self, event):
|
|
|
398
|
+ def _on_message_received(self, event: MessageEventT) -> None:
|
|
372
|
399
|
if not event.msgtxt:
|
|
373
|
400
|
return
|
|
374
|
|
- row = self._chats.get((event.account, event.jid))
|
|
|
401
|
+ row = self._chats.get((event.account, JID.from_string(event.jid)))
|
|
|
402
|
+ if row is None:
|
|
|
403
|
+ return
|
|
375
|
404
|
nick = self._get_nick_for_received_message(event)
|
|
376
|
405
|
row.set_nick(nick)
|
|
377
|
406
|
if event.name == 'mam-message-received':
|
| ... |
... |
@@ -392,8 +421,23 @@ def _on_message_received(self, event): |
|
392
|
421
|
self._add_unread(row, event)
|
|
393
|
422
|
self.invalidate_sort()
|
|
394
|
423
|
|
|
395
|
|
- def _on_message_updated(self, event):
|
|
396
|
|
- row = self._chats.get((event.account, event.jid))
|
|
|
424
|
+ @staticmethod
|
|
|
425
|
+ def _get_nick_for_received_message(event: MessageEventT) -> str:
|
|
|
426
|
+ nick = _('Me')
|
|
|
427
|
+ if event.properties.type.is_groupchat:
|
|
|
428
|
+ event_nick = event.properties.muc_nickname
|
|
|
429
|
+ our_nick = get_group_chat_nick(event.account, event.jid)
|
|
|
430
|
+ if event_nick != our_nick:
|
|
|
431
|
+ nick = event_nick
|
|
|
432
|
+ else:
|
|
|
433
|
+ con = app.get_client(event.account)
|
|
|
434
|
+ own_jid = con.get_own_jid()
|
|
|
435
|
+ if not own_jid.bare_match(event.properties.from_):
|
|
|
436
|
+ nick = ''
|
|
|
437
|
+ return nick
|
|
|
438
|
+
|
|
|
439
|
+ def _on_message_updated(self, event: MessageUpdated) -> None:
|
|
|
440
|
+ row = self._chats.get((event.account, JID.from_string(event.jid)))
|
|
397
|
441
|
if row is None:
|
|
398
|
442
|
return
|
|
399
|
443
|
|
| ... |
... |
@@ -409,14 +453,17 @@ def _on_message_updated(self, event): |
|
409
|
453
|
event.properties.moderation.reason)
|
|
410
|
454
|
row.set_message_text(text)
|
|
411
|
455
|
|
|
412
|
|
- def _on_message_sent(self, event):
|
|
|
456
|
+ def _on_message_sent(self, event: MessageSent) -> None:
|
|
413
|
457
|
msgtext = event.message
|
|
414
|
458
|
if not msgtext:
|
|
415
|
459
|
return
|
|
416
|
460
|
|
|
417
|
|
- row = self._chats.get((event.account, event.jid))
|
|
418
|
|
- con = app.get_client(event.account)
|
|
419
|
|
- own_jid = con.get_own_jid()
|
|
|
461
|
+ row = self._chats.get((event.account, JID.from_string(event.jid)))
|
|
|
462
|
+ if row is None:
|
|
|
463
|
+ return
|
|
|
464
|
+
|
|
|
465
|
+ client = app.get_client(event.account)
|
|
|
466
|
+ own_jid = client.get_own_jid()
|
|
420
|
467
|
|
|
421
|
468
|
if own_jid.bare_match(event.jid):
|
|
422
|
469
|
nick = ''
|
| ... |
... |
@@ -432,47 +479,41 @@ def _on_message_sent(self, event): |
|
432
|
479
|
additional_data=event.additional_data)
|
|
433
|
480
|
self.invalidate_sort()
|
|
434
|
481
|
|
|
435
|
|
- @staticmethod
|
|
436
|
|
- def _get_nick_for_received_message(event):
|
|
437
|
|
- nick = _('Me')
|
|
438
|
|
- if event.properties.type.is_groupchat:
|
|
439
|
|
- event_nick = event.properties.muc_nickname
|
|
440
|
|
- our_nick = get_group_chat_nick(event.account, event.jid)
|
|
441
|
|
- if event_nick != our_nick:
|
|
442
|
|
- nick = event_nick
|
|
443
|
|
- else:
|
|
444
|
|
- con = app.get_client(event.account)
|
|
445
|
|
- own_jid = con.get_own_jid()
|
|
446
|
|
- if not own_jid.bare_match(event.properties.from_):
|
|
447
|
|
- nick = ''
|
|
448
|
|
-
|
|
449
|
|
- return nick
|
|
450
|
|
-
|
|
451
|
|
- def _on_presence_received(self, event):
|
|
452
|
|
- row = self._chats.get((event.account, event.jid))
|
|
|
482
|
+ def _on_presence_received(self, event: PresenceReceived) -> None:
|
|
|
483
|
+ row = self._chats.get((event.account, JID.from_string(event.jid)))
|
|
|
484
|
+ if row is None:
|
|
|
485
|
+ return
|
|
453
|
486
|
row.update_avatar()
|
|
454
|
487
|
|
|
455
|
|
- def _on_jingle_request_received(self, event):
|
|
456
|
|
- content_types = []
|
|
|
488
|
+ def _on_jingle_request_received(self,
|
|
|
489
|
+ event: JingleRequestReceived
|
|
|
490
|
+ ) -> None:
|
|
|
491
|
+ content_types: list[str] = []
|
|
457
|
492
|
for item in event.contents:
|
|
458
|
493
|
content_types.append(item.media)
|
|
459
|
494
|
if 'audio' in content_types or 'video' in content_types:
|
|
460
|
495
|
# AV Call received
|
|
461
|
|
- row = self._chats.get((event.account, event.jid))
|
|
|
496
|
+ row = self._chats.get((event.account, JID.from_string(event.jid)))
|
|
|
497
|
+ if row is None:
|
|
|
498
|
+ return
|
|
462
|
499
|
row.set_timestamp(time.time())
|
|
463
|
500
|
row.set_nick('')
|
|
464
|
501
|
row.set_message_text(
|
|
465
|
502
|
_('Call'), icon_name='call-start-symbolic')
|
|
466
|
503
|
|
|
467
|
|
- def _on_file_request_received(self, event):
|
|
468
|
|
- row = self._chats.get((event.account, event.jid))
|
|
|
504
|
+ def _on_file_request_received(self,
|
|
|
505
|
+ event: FileRequestReceivedEvent
|
|
|
506
|
+ ) -> None:
|
|
|
507
|
+ row = self._chats.get((event.account, JID.from_string(event.jid)))
|
|
|
508
|
+ if row is None:
|
|
|
509
|
+ return
|
|
469
|
510
|
row.set_timestamp(time.time())
|
|
470
|
511
|
row.set_nick('')
|
|
471
|
512
|
row.set_message_text(
|
|
472
|
513
|
_('File'), icon_name='text-x-generic-symbolic')
|
|
473
|
514
|
|
|
474
|
515
|
@staticmethod
|
|
475
|
|
- def _add_unread(row, event):
|
|
|
516
|
+ def _add_unread(row: ChatRow, event: MessageEventT) -> None:
|
|
476
|
517
|
if event.properties.is_carbon_message:
|
|
477
|
518
|
if event.properties.carbon.is_sent:
|
|
478
|
519
|
return
|
| ... |
... |
@@ -490,12 +531,14 @@ def _add_unread(row, event): |
|
490
|
531
|
|
|
491
|
532
|
row.add_unread(event.msgtxt)
|
|
492
|
533
|
|
|
493
|
|
- def _on_account_changed(self, *args):
|
|
494
|
|
- for row in self.get_children():
|
|
|
534
|
+ def _on_account_changed(self, *args: Any) -> None:
|
|
|
535
|
+ rows = cast(list[ChatRow], self.get_children())
|
|
|
536
|
+ for row in rows:
|
|
495
|
537
|
row.update_account_identifier()
|
|
496
|
538
|
|
|
497
|
|
- def _on_bookmarks_received(self, _event):
|
|
498
|
|
- for row in self.get_children():
|
|
|
539
|
+ def _on_bookmarks_received(self, _event: BookmarksReceived) -> None:
|
|
|
540
|
+ rows = cast(list[ChatRow], self.get_children())
|
|
|
541
|
+ for row in rows:
|
|
499
|
542
|
row.update_name()
|
|
500
|
543
|
|
|
501
|
544
|
|
| ... |
... |
@@ -522,7 +565,7 @@ def __init__(self, workspace_id: str, account: str, jid: JID, type_: str, |
|
522
|
565
|
self.contact.connect('avatar-update', self._on_avatar_update)
|
|
523
|
566
|
|
|
524
|
567
|
self.contact_name: str = self.contact.name
|
|
525
|
|
- self.timestamp: int = 0
|
|
|
568
|
+ self.timestamp: float = 0
|
|
526
|
569
|
self.stanza_id: Optional[str] = None
|
|
527
|
570
|
self.message_id: Optional[str] = None
|
|
528
|
571
|
self._unread_count: int = 0
|
| ... |
... |
@@ -629,6 +672,7 @@ def header(self) -> Optional[RowHeaderType]: |
|
629
|
672
|
header = self.get_header()
|
|
630
|
673
|
if header is None:
|
|
631
|
674
|
return None
|
|
|
675
|
+ assert isinstance(header, BaseHeader)
|
|
632
|
676
|
return header.type
|
|
633
|
677
|
|
|
634
|
678
|
@header.setter
|
| ... |
... |
@@ -648,17 +692,20 @@ def header(self, type_: RowHeaderType) -> None: |
|
648
|
692
|
def is_pinned(self) -> bool:
|
|
649
|
693
|
return self._pinned
|
|
650
|
694
|
|
|
651
|
|
- def _on_button_press(self, _widget, event):
|
|
|
695
|
+ def _on_button_press(self,
|
|
|
696
|
+ _widget: Gtk.Widget,
|
|
|
697
|
+ event: Gdk.EventButton
|
|
|
698
|
+ ) -> None:
|
|
652
|
699
|
if event.button == 3: # right click
|
|
653
|
700
|
self._popup_menu(event)
|
|
654
|
701
|
|
|
655
|
|
- def _popup_menu(self, event):
|
|
|
702
|
+ def _popup_menu(self, event: Gdk.EventButton):
|
|
656
|
703
|
menu = get_chat_list_row_menu(
|
|
657
|
704
|
self.workspace_id, self.account, self.jid, self._pinned)
|
|
658
|
705
|
|
|
659
|
706
|
rectangle = Gdk.Rectangle()
|
|
660
|
|
- rectangle.x = event.x
|
|
661
|
|
- rectangle.y = event.y
|
|
|
707
|
+ rectangle.x = int(event.x)
|
|
|
708
|
+ rectangle.y = int(event.y)
|
|
662
|
709
|
rectangle.width = rectangle.height = 1
|
|
663
|
710
|
|
|
664
|
711
|
popover = Gtk.Popover.new_from_model(self, menu)
|
| ... |
... |
@@ -677,7 +724,10 @@ def _on_drag_begin(self, |
|
677
|
724
|
cairo.Format.ARGB32, alloc.width, alloc.height)
|
|
678
|
725
|
context = cairo.Context(surface)
|
|
679
|
726
|
self.draw(context)
|
|
680
|
|
- dest_x, dest_y = widget.translate_coordinates(self, 0, 0)
|
|
|
727
|
+ coords = widget.translate_coordinates(self, 0, 0)
|
|
|
728
|
+ if coords is None:
|
|
|
729
|
+ return
|
|
|
730
|
+ dest_x, dest_y = coords
|
|
681
|
731
|
surface.set_device_offset(-dest_x, -dest_y)
|
|
682
|
732
|
Gtk.drag_set_icon_surface(drag_context, surface)
|
|
683
|
733
|
|
| ... |
... |
@@ -695,10 +745,16 @@ def _on_drag_data_get(self, |
|
695
|
745
|
def toggle_pinned(self) -> None:
|
|
696
|
746
|
self._pinned = not self._pinned
|
|
697
|
747
|
|
|
698
|
|
- def _on_presence_update(self, _contact, _signal_name):
|
|
|
748
|
+ def _on_presence_update(self,
|
|
|
749
|
+ _contact: ContactT,
|
|
|
750
|
+ _signal_name: str
|
|
|
751
|
+ ) -> None:
|
|
699
|
752
|
self.update_avatar()
|
|
700
|
753
|
|
|
701
|
|
- def _on_avatar_update(self, _contact, _signal_name):
|
|
|
754
|
+ def _on_avatar_update(self,
|
|
|
755
|
+ _contact: ContactT,
|
|
|
756
|
+ _signal_name: str
|
|
|
757
|
+ ) -> None:
|
|
702
|
758
|
self.update_avatar()
|
|
703
|
759
|
|
|
704
|
760
|
def update_avatar(self) -> None:
|
| ... |
... |
@@ -724,13 +780,19 @@ def update_account_identifier(self) -> None: |
|
724
|
780
|
show = len(app.settings.get_active_accounts()) > 1
|
|
725
|
781
|
self._ui.account_identifier.set_visible(show)
|
|
726
|
782
|
|
|
727
|
|
- def _on_chatstate_update(self, contact, _signal_name):
|
|
|
783
|
+ def _on_chatstate_update(self,
|
|
|
784
|
+ contact: ContactT,
|
|
|
785
|
+ _signal_name: str
|
|
|
786
|
+ ) -> None:
|
|
728
|
787
|
if contact.chatstate is None:
|
|
729
|
788
|
self._ui.chatstate_image.hide()
|
|
730
|
789
|
else:
|
|
731
|
790
|
self._ui.chatstate_image.set_visible(contact.chatstate.is_composing)
|
|
732
|
791
|
|
|
733
|
|
- def _on_nickname_update(self, _contact, _signal_name):
|
|
|
792
|
+ def _on_nickname_update(self,
|
|
|
793
|
+ _contact: ContactT,
|
|
|
794
|
+ _signal_name: str
|
|
|
795
|
+ ) -> None:
|
|
734
|
796
|
self.update_name()
|
|
735
|
797
|
|
|
736
|
798
|
def get_real_unread_count(self) -> int:
|
| ... |
... |
@@ -746,7 +808,8 @@ def unread_count(self) -> int: |
|
746
|
808
|
def unread_count(self, value: int) -> None:
|
|
747
|
809
|
self._unread_count = value
|
|
748
|
810
|
self._update_unread()
|
|
749
|
|
- self.get_parent().emit_unread_changed()
|
|
|
811
|
+ chat_list = cast(ChatList, self.get_parent())
|
|
|
812
|
+ chat_list.emit_unread_changed()
|
|
750
|
813
|
|
|
751
|
814
|
def _update_unread(self) -> None:
|
|
752
|
815
|
unread_count = self._get_unread_string(self._unread_count)
|
| ... |
... |
@@ -766,7 +829,8 @@ def add_unread(self, text: str) -> None: |
|
766
|
829
|
|
|
767
|
830
|
self._unread_count += 1
|
|
768
|
831
|
self._update_unread()
|
|
769
|
|
- self.get_parent().emit_unread_changed()
|
|
|
832
|
+ chat_list = cast(ChatList, self.get_parent())
|
|
|
833
|
+ chat_list.emit_unread_changed()
|
|
770
|
834
|
app.storage.cache.set_unread_count(
|
|
771
|
835
|
self.account,
|
|
772
|
836
|
self.jid,
|
| ... |
... |
@@ -786,7 +850,8 @@ def add_unread(self, text: str) -> None: |
|
786
|
850
|
def reset_unread(self) -> None:
|
|
787
|
851
|
self._unread_count = 0
|
|
788
|
852
|
self._update_unread()
|
|
789
|
|
- self.get_parent().emit_unread_changed()
|
|
|
853
|
+ chat_list = cast(ChatList, self.get_parent())
|
|
|
854
|
+ chat_list.emit_unread_changed()
|
|
790
|
855
|
app.storage.cache.reset_unread_count(self.account, self.jid)
|
|
791
|
856
|
|
|
792
|
857
|
# Add class again in case we were mentioned previously
|
| ... |
... |
@@ -805,14 +870,17 @@ def is_recent(self) -> bool: |
|
805
|
870
|
return True
|
|
806
|
871
|
return False
|
|
807
|
872
|
|
|
808
|
|
- def _on_state_flags_changed(self, _listboxrow, *args):
|
|
|
873
|
+ def _on_state_flags_changed(self,
|
|
|
874
|
+ _row: ChatRow,
|
|
|
875
|
+ _flags: Gtk.StateFlags
|
|
|
876
|
+ ) -> None:
|
|
809
|
877
|
state = self.get_state_flags()
|
|
810
|
878
|
if (state & Gtk.StateFlags.PRELIGHT) != 0:
|
|
811
|
879
|
self._ui.revealer.set_reveal_child(True)
|
|
812
|
880
|
else:
|
|
813
|
881
|
self._ui.revealer.set_reveal_child(False)
|
|
814
|
882
|
|
|
815
|
|
- def _on_close_button_clicked(self, _button):
|
|
|
883
|
+ def _on_close_button_clicked(self, _button: Gtk.Button) -> None:
|
|
816
|
884
|
app.window.activate_action(
|
|
817
|
885
|
'remove-chat',
|
|
818
|
886
|
GLib.Variant('as', [self.account, str(self.jid)]))
|