Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2022-10-02 21:31:59 +0300
committerPhilipp Hörist <philipp@hoerist.com>2022-10-02 21:31:59 +0300
commit9019cf24b4ebcfa081acfb5d1277c4e07e29866c (patch)
tree4b5f142896695811ba71fa8dedaebeb22b4f5253
parent0f44c5d423f809ba0f3da8868bda9dd0c8f19133 (diff)
refactor: ChatListRow: Move connecting contact signals into own method
-rw-r--r--gajim/gtk/chat_list_row.py50
1 files changed, 28 insertions, 22 deletions
diff --git a/gajim/gtk/chat_list_row.py b/gajim/gtk/chat_list_row.py
index f8996873d..1bfe7f51e 100644
--- a/gajim/gtk/chat_list_row.py
+++ b/gajim/gtk/chat_list_row.py
@@ -82,29 +82,9 @@ class ChatListRow(Gtk.ListBoxRow):
self._pinned_label = PinnedHeader()
self._client = app.get_client(account)
- self.contact = self._client.get_module('Contacts').get_contact(jid)
-
- if isinstance(self.contact, BareContact):
- self.contact.connect('presence-update', self._on_presence_update)
- self.contact.connect('chatstate-update', self._on_chatstate_update)
- self.contact.connect('nickname-update', self._on_nickname_update)
- self.contact.connect('caps-update', self._on_avatar_update)
- self.contact.connect('avatar-update', self._on_avatar_update)
-
- elif isinstance(self.contact, GroupchatContact):
- self.contact.connect('avatar-update', self._on_avatar_update)
-
- elif isinstance(self.contact, GroupchatParticipant):
- self.contact.connect('chatstate-update', self._on_chatstate_update)
- self.contact.connect('user-joined', self._on_muc_user_update)
- self.contact.connect('user-left', self._on_muc_user_update)
- self.contact.connect('user-avatar-update', self._on_muc_user_update)
- self.contact.connect('user-status-show-changed',
- self._on_muc_user_update)
- self.contact.room.connect('room-left', self._on_muc_update)
- self.contact.room.connect('room-destroyed', self._on_muc_update)
- self.contact.room.connect('room-kicked', self._on_muc_update)
+ self.contact = self._client.get_module('Contacts').get_contact(jid)
+ self._connect_contact_signals()
self.contact_name: str = self.contact.name
self.timestamp: float = 0
@@ -471,6 +451,32 @@ class ChatListRow(Gtk.ListBoxRow):
byte_data = pickle.dumps((self.account, self.jid))
selection_data.set(drop_type, 8, byte_data)
+ def _connect_contact_signals(self) -> None:
+ if isinstance(self.contact, BareContact):
+ self.contact.connect('presence-update', self._on_presence_update)
+ self.contact.connect('chatstate-update', self._on_chatstate_update)
+ self.contact.connect('nickname-update', self._on_nickname_update)
+ self.contact.connect('caps-update', self._on_avatar_update)
+ self.contact.connect('avatar-update', self._on_avatar_update)
+
+ elif isinstance(self.contact, GroupchatContact):
+ self.contact.connect('avatar-update', self._on_avatar_update)
+
+ elif isinstance(self.contact, GroupchatParticipant):
+ self.contact.connect('chatstate-update', self._on_chatstate_update)
+ self.contact.connect('user-joined', self._on_muc_user_update)
+ self.contact.connect('user-left', self._on_muc_user_update)
+ self.contact.connect('user-avatar-update', self._on_muc_user_update)
+ self.contact.connect('user-status-show-changed',
+ self._on_muc_user_update)
+
+ self.contact.room.connect('room-left', self._on_muc_update)
+ self.contact.room.connect('room-destroyed', self._on_muc_update)
+ self.contact.room.connect('room-kicked', self._on_muc_update)
+
+ else:
+ raise TypeError('Unkown contact type: %s' % type(self.contact))
+
def _on_presence_update(self,
_contact: ChatContactT,
_signal_name: str