Philipp Hörist pushed to branch mainwindow at gajim / gajim

Commits:

2 changed files:

Changes:

  • gajim/gtk/chat_list.py
    ... ... @@ -66,7 +66,8 @@ def _update_timer(self):
    66 66
         def _filter_func(self, row):
    
    67 67
             if not self._current_filter_text:
    
    68 68
                 return True
    
    69
    -        return self._current_filter_text in row.jid
    
    69
    +        text = self._current_filter_text.lower()
    
    70
    +        return text in row.contact.name.lower()
    
    70 71
     
    
    71 72
         @staticmethod
    
    72 73
         def _header_func(row, before):
    
    ... ... @@ -256,11 +257,11 @@ def __init__(self, workspace_id, account, jid, type_, pinned):
    256 257
             self.conversations_label = ConversationsHeader()
    
    257 258
             self.pinned_label = PinnedHeader()
    
    258 259
     
    
    259
    -        self._contact = app.get_client(account).get_module('Contacts').get_contact(jid)
    
    260
    -        self._contact.connect('presence-update', self._on_presence_update)
    
    261
    -        self._contact.connect('chatstate-update', self._on_chatstate_update)
    
    262
    -        self._contact.connect('nickname-update', self._on_nickname_update)
    
    263
    -        self._contact.connect('avatar-update', self._on_avatar_update)
    
    260
    +        self.contact = app.get_client(account).get_module('Contacts').get_contact(jid)
    
    261
    +        self.contact.connect('presence-update', self._on_presence_update)
    
    262
    +        self.contact.connect('chatstate-update', self._on_chatstate_update)
    
    263
    +        self.contact.connect('nickname-update', self._on_nickname_update)
    
    264
    +        self.contact.connect('avatar-update', self._on_avatar_update)
    
    264 265
     
    
    265 266
             self._timestamp = None
    
    266 267
             self._unread_count = 0
    
    ... ... @@ -367,17 +368,17 @@ def _on_avatar_update(self, _contact, _signal_name):
    367 368
     
    
    368 369
         def update_avatar(self):
    
    369 370
             scale = self.get_scale_factor()
    
    370
    -        surface = self._contact.get_avatar(AvatarSize.ROSTER, scale)
    
    371
    +        surface = self.contact.get_avatar(AvatarSize.ROSTER, scale)
    
    371 372
             self._ui.avatar_image.set_from_surface(surface)
    
    372 373
     
    
    373 374
         def update_name(self):
    
    374 375
             if self.type == 'pm':
    
    375 376
                 client = app.get_client(self.account)
    
    376 377
                 muc_name = get_groupchat_name(client, self.jid)
    
    377
    -            self._ui.name_label.set_text(f'{self._contact.name} ({muc_name})')
    
    378
    +            self._ui.name_label.set_text(f'{self.contact.name} ({muc_name})')
    
    378 379
                 return
    
    379 380
     
    
    380
    -        self._ui.name_label.set_text(self._contact.name)
    
    381
    +        self._ui.name_label.set_text(self.contact.name)
    
    381 382
     
    
    382 383
         def _on_chatstate_update(self, contact, _signal_name):
    
    383 384
             if contact.chatstate is None:
    

  • gajim/gtk/chat_list_stack.py
    ... ... @@ -38,9 +38,12 @@ def __init__(self, main_window, ui, chat_stack):
    38 38
             self._chat_stack = chat_stack
    
    39 39
             self._chat_lists = {}
    
    40 40
     
    
    41
    +        self._last_visible_child_name = 'default'
    
    42
    +
    
    41 43
             self.add_named(Gtk.Box(), 'default')
    
    42 44
     
    
    43 45
             self.show_all()
    
    46
    +        self.connect('notify::visible-child-name', self._on_visible_child_name)
    
    44 47
             self._ui.search_entry.connect(
    
    45 48
                 'search-changed', self._on_search_changed)
    
    46 49
     
    
    ... ... @@ -53,6 +56,16 @@ def _on_window_active(self, window, _param):
    53 56
                 if chat is not None:
    
    54 57
                     chat.reset_unread()
    
    55 58
     
    
    59
    +    def _on_visible_child_name(self, _stack, _param):
    
    60
    +        if self._last_visible_child_name == self.get_visible_child_name():
    
    61
    +            return
    
    62
    +
    
    63
    +        self._ui.search_entry.set_text('')
    
    64
    +        if self._last_visible_child_name != 'default':
    
    65
    +            child = self.get_child_by_name(self._last_visible_child_name)
    
    66
    +            child.set_filter_text('')
    
    67
    +        self._last_visible_child_name = self.get_visible_child_name()
    
    68
    +
    
    56 69
         def get_chatlist(self, workspace_id):
    
    57 70
             return self._chat_lists[workspace_id]
    
    58 71