| ... |
... |
@@ -49,6 +49,9 @@ |
|
49
|
49
|
from gajim.common.preview_helpers import guess_simple_file_type
|
|
50
|
50
|
from gajim.common.types import ChatContactT
|
|
51
|
51
|
from gajim.common.types import OneOnOneContactT
|
|
|
52
|
+from gajim.common.modules.contacts import BareContact
|
|
|
53
|
+from gajim.common.modules.contacts import GroupchatContact
|
|
|
54
|
+from gajim.common.modules.contacts import GroupchatParticipant
|
|
52
|
55
|
|
|
53
|
56
|
from .menus import get_chat_list_row_menu
|
|
54
|
57
|
from .builder import get_builder
|
| ... |
... |
@@ -548,11 +551,24 @@ def __init__(self, workspace_id: str, account: str, jid: JID, type_: str, |
|
548
|
551
|
|
|
549
|
552
|
self._client = app.get_client(account)
|
|
550
|
553
|
self.contact = self._client.get_module('Contacts').get_contact(jid)
|
|
551
|
|
- self.contact.connect('presence-update', self._on_presence_update)
|
|
552
|
|
- self.contact.connect('chatstate-update', self._on_chatstate_update)
|
|
553
|
|
- self.contact.connect('nickname-update', self._on_nickname_update)
|
|
554
|
|
- self.contact.connect('caps-update', self._on_avatar_update)
|
|
555
|
|
- self.contact.connect('avatar-update', self._on_avatar_update)
|
|
|
554
|
+
|
|
|
555
|
+ if isinstance(self.contact, BareContact):
|
|
|
556
|
+ self.contact.connect('presence-update', self._on_presence_update)
|
|
|
557
|
+ self.contact.connect('chatstate-update', self._on_chatstate_update)
|
|
|
558
|
+ self.contact.connect('nickname-update', self._on_nickname_update)
|
|
|
559
|
+ self.contact.connect('caps-update', self._on_avatar_update)
|
|
|
560
|
+ self.contact.connect('avatar-update', self._on_avatar_update)
|
|
|
561
|
+
|
|
|
562
|
+ elif isinstance(self.contact, GroupchatContact):
|
|
|
563
|
+ self.contact.connect('avatar-update', self._on_avatar_update)
|
|
|
564
|
+
|
|
|
565
|
+ elif isinstance(self.contact, GroupchatParticipant):
|
|
|
566
|
+ self.contact.connect('chatstate-update', self._on_chatstate_update)
|
|
|
567
|
+ self.contact.connect('user-joined', self._on_muc_user_update)
|
|
|
568
|
+ self.contact.connect('user-left', self._on_muc_user_update)
|
|
|
569
|
+ self.contact.connect('user-avatar-update', self._on_muc_user_update)
|
|
|
570
|
+ self.contact.connect('user-status-show-changed',
|
|
|
571
|
+ self._on_muc_user_update)
|
|
556
|
572
|
|
|
557
|
573
|
self.contact_name: str = self.contact.name
|
|
558
|
574
|
self.timestamp: float = 0
|
| ... |
... |
@@ -568,6 +584,7 @@ def __init__(self, workspace_id: str, account: str, jid: JID, type_: str, |
|
568
|
584
|
self.add(self._ui.eventbox)
|
|
569
|
585
|
|
|
570
|
586
|
self.connect('state-flags-changed', self._on_state_flags_changed)
|
|
|
587
|
+ self.connect('destroy', self._on_destroy)
|
|
571
|
588
|
self._ui.eventbox.connect('button-press-event', self._on_button_press)
|
|
572
|
589
|
self._ui.close_button.connect('clicked', self._on_close_button_clicked)
|
|
573
|
590
|
|
| ... |
... |
@@ -752,6 +769,13 @@ def _on_avatar_update(self, |
|
752
|
769
|
) -> None:
|
|
753
|
770
|
self.update_avatar()
|
|
754
|
771
|
|
|
|
772
|
+ def _on_muc_user_update(self,
|
|
|
773
|
+ _contact: GroupchatParticipant,
|
|
|
774
|
+ _signal_name: str,
|
|
|
775
|
+ *args: Any
|
|
|
776
|
+ ) -> None:
|
|
|
777
|
+ self.update_avatar()
|
|
|
778
|
+
|
|
755
|
779
|
def update_avatar(self) -> None:
|
|
756
|
780
|
scale = self.get_scale_factor()
|
|
757
|
781
|
surface = self.contact.get_avatar(AvatarSize.ROSTER, scale)
|
| ... |
... |
@@ -881,6 +905,10 @@ def _on_state_flags_changed(self, |
|
881
|
905
|
else:
|
|
882
|
906
|
self._ui.revealer.set_reveal_child(False)
|
|
883
|
907
|
|
|
|
908
|
+ def _on_destroy(self, _row: ChatRow) -> None:
|
|
|
909
|
+ self.contact.disconnect_all_from_obj(self)
|
|
|
910
|
+ app.check_finalize(self)
|
|
|
911
|
+
|
|
884
|
912
|
def _on_close_button_clicked(self, _button: Gtk.Button) -> None:
|
|
885
|
913
|
app.window.activate_action(
|
|
886
|
914
|
'remove-chat',
|