Ticket #1201: modelfilter.2.patch

File modelfilter.2.patch, 41.7 KB (added by asterix, 3 years ago)
  • src/roster_window.py

     
    3030import sys 
    3131import time 
    3232import urllib 
     33import threading 
    3334 
    3435import common.sleepy 
    3536import history_window 
     
    8081class RosterWindow: 
    8182        '''Class for main window of the GTK+ interface''' 
    8283 
    83         def get_account_iter(self, name): 
     84        def get_account_iter(self, name, model = None): 
    8485                ''' Returns a gtk.TreeIter of accounts in roster data model or None ''' 
    85                 model = self.tree.get_model() 
     86                if not model: 
     87                        model = self.tree.get_model() 
    8688                if model is None: 
    8789                        return 
    8890                account_iter = model.get_iter_root() 
    8991                if self.regroup: 
    9092                        return account_iter 
    9193                while account_iter: 
    92                         account_name = model[account_iter][C_ACCOUNT].decode('utf-8') 
    93                         if name == account_name: 
     94                        account_name = model[account_iter][C_ACCOUNT] 
     95                        if account_name and name == account_name.decode('utf-8'): 
    9496                                break 
    9597                        account_iter = model.iter_next(account_iter) 
    9698                return account_iter 
    9799 
    98         def get_group_iter(self, name, account): 
     100        def get_group_iter(self, name, account, model = None): 
    99101                ''' Returns a gtk.TreeIter of groups in roster data model or None ''' 
    100                 model = self.tree.get_model() 
    101                 root = self.get_account_iter(account) 
     102                if not model: 
     103                        model = self.tree.get_model() 
     104                root = self.get_account_iter(account, model) 
    102105                group_iter = model.iter_children(root) 
    103106                # C_NAME column contacts the pango escaped group name 
    104107                while group_iter: 
     
    108111                        group_iter = model.iter_next(group_iter) 
    109112                return group_iter 
    110113 
    111         def get_contact_iter(self, jid, account): 
     114        def get_contact_iter(self, jid, account, model = None): 
    112115                if jid == gajim.get_jid_from_account(account): 
    113116                        iter = self.get_self_contact_iter(account) 
    114117                        if iter: 
    115118                                return [iter] 
    116119                        else: 
    117120                                return [] 
    118                 model = self.tree.get_model() 
    119                 acct = self.get_account_iter(account) 
     121                if not model: 
     122                        model = self.tree.get_model() 
     123                acct = self.get_account_iter(account, model) 
    120124                found = [] 
    121125                if model is None: # when closing Gajim model can be none (async pbs?) 
    122126                        return found 
     
    124128                while group_iter: 
    125129                        contact_iter = model.iter_children(group_iter) 
    126130                        while contact_iter: 
    127                                 if jid == model[contact_iter][C_JID].decode('utf-8') and \ 
     131                                iter_jid = model[contact_iter][C_JID] 
     132                                if iter_jid and jid == iter_jid.decode('utf-8') and \ 
    128133                                        account == model[contact_iter][C_ACCOUNT].decode('utf-8'): 
    129134                                        found.append(contact_iter) 
    130135                                # find next contact iter 
     
    170175                        # show him 
    171176                        self.add_contact_to_roster(jid, account) 
    172177                        iters = self.get_contact_iter(jid, account) 
     178                        #FIXME: adding it doesn't mean it is visible 
     179                        if not iters: 
     180                                return 
    173181                        path = self.tree.get_model().get_path(iters[0]) 
    174182                if self.dragging or not gajim.config.get('scroll_roster_to_last_message'): 
    175183                        # do not change selection while DND'ing 
     
    184192        def add_account_to_roster(self, account): 
    185193                ''' Add an account to roster data model. ''' 
    186194                model = self.tree.get_model() 
     195                child_model = model.get_model() 
    187196                if self.get_account_iter(account): 
    188197                        return 
    189198 
    190199                # if we merge accounts... 
    191200                if self.regroup: 
    192201                        show = helpers.get_global_show() 
    193                         model.append(None, [self.jabber_state_images['16'][show], 
     202                        child_model.append(None, [self.jabber_state_images['16'][show], 
    194203                                _('Merged accounts'), 'account', '', 'all', None]) 
    195204                        self.draw_account(account) 
    196205                        return 
     
    204213 
    205214                our_jid = gajim.get_jid_from_account(account) 
    206215 
    207                 model.append(None, [self.jabber_state_images['16'][show], 
     216                child_model.append(None, [self.jabber_state_images['16'][show], 
    208217                        gobject.markup_escape_text(account), 
    209218                        'account', our_jid, account, tls_pixbuf]) 
    210219 
    211220        def draw_account(self, account): 
    212                 model = self.tree.get_model() 
    213                 iter = self.get_account_iter(account) 
     221                child_iter = self.get_account_iter(account, self.model) 
    214222                if self.regroup: 
    215223                        accounts = gajim.connections.keys() 
    216224                else: 
     
    239247                                                new_pixels += chr(128) 
    240248                                tls_pixbuf = gtk.gdk.pixbuf_new_from_data(new_pixels, colorspace, 
    241249                                        True, bps, width, height, rowstride) 
    242                         model[iter][C_SECPIXBUF] = tls_pixbuf 
     250                        self.model[child_iter][C_SECPIXBUF] = tls_pixbuf 
    243251                else: 
    244                         model[iter][C_SECPIXBUF] = None 
    245                 path = model.get_path(iter) 
     252                        self.model[child_iter][C_SECPIXBUF] = None 
     253                path = self.model.get_path(child_iter) 
    246254                account_name = account 
    247255                accounts = [account] 
    248256                if self.regroup: 
    249257                        account_name = _('Merged accounts') 
    250258                        accounts = [] 
    251                 if not self.tree.row_expanded(path) and model.iter_has_child(iter): 
     259                if not self.tree.row_expanded(path) and self.model.iter_has_child( 
     260                child_iter): 
    252261                        # account row not expanded 
    253262                        account_name = '[%s]' % account_name 
    254263                if (gajim.account_is_connected(account) or (self.regroup and \ 
     
    257266                        nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 
    258267                                accounts = accounts) 
    259268                        account_name += ' (%s/%s)' % (repr(nbr_on),repr(nbr_total)) 
    260                 model[iter][C_NAME] = account_name 
     269                self.model[child_iter][C_NAME] = account_name 
    261270 
    262271        def remove_newly_added(self, jid, account): 
    263272                if jid in gajim.newly_added[account]: 
     
    270279                is False, because it has online children, so we need to show it. 
    271280                If add_children is True, we also add all children, even if they were not 
    272281                already drawn''' 
    273                 showOffline = gajim.config.get('showoffline') 
    274                 model = self.tree.get_model() 
     282                model = self.modelfilter 
     283                child_model = model.get_model() 
    275284                contact = gajim.contacts.get_first_contact_from_jid(account, jid) 
    276285                nb_events = gajim.events.get_nb_roster_events(account, contact.jid) 
    277286                # count events from all resources 
     
    289298                                self.add_self_contact(account) 
    290299                        return 
    291300                if gajim.jid_is_transport(contact.jid): 
    292                         # if jid is transport, check if we wanna show it in roster 
    293                         if not gajim.config.get('show_transports_group') and not nb_events: 
    294                                 return 
    295301                        contact.groups = [_('Transports')] 
    296                 elif not showOffline and not gajim.account_is_connected(account) and \ 
    297                 nb_events == 0: 
    298                         return 
    299302 
    300                 # XEP-0162 
    301                 hide = contact.is_hidden_from_roster() 
    302                 if hide and contact.sub != 'from': 
    303                         return 
    304303                observer = contact.is_observer() 
    305304                groupchat = contact.is_groupchat() 
    306305 
     
    309308                        tag = gajim.contacts.get_metacontacts_tag(account, jid) 
    310309                        if tag: 
    311310                                gajim.contacts.remove_metacontact(account, jid) 
     311                        contact.groups = [_('Observers')] 
    312312 
    313313                # family is [{'account': acct, 'jid': jid, 'priority': prio}, ] 
    314314                # 'priority' is optional 
     
    324324                                        continue 
    325325                                _jid = data['jid'] 
    326326 
    327                                 if self.get_contact_iter(_jid, _account): 
     327                                if self.get_contact_iter(_jid, _account, self.model): 
    328328                                        shown_family.append(data) 
    329329                                if _jid == jid and _account == account: 
    330330                                        our_data = data 
     
    335335                        big_brother_account = big_brother_data['account'] 
    336336                        if big_brother_jid != jid or big_brother_account != account: 
    337337                                # We are adding a child contact 
    338                                 if contact.show in ('offline', 'error') and \ 
    339                                 not showOffline and len(gajim.events.get_events(account, jid)) == 0: 
     338                                parent_iters = self.get_contact_iter(big_brother_jid, 
     339                                        big_brother_account, self.model) 
     340                                if parent_iters: 
     341                                        name = contact.get_shown_name() 
     342                                        added_iters = [] 
     343                                        for child_i in parent_iters: 
     344                                                # we add some values here. see draw_contact for more 
     345                                                i_ = child_model.append(child_i, (None, name, 'contact', jid, 
     346                                                        account, None)) 
     347                                                added_iters.append(i_) 
     348                                        self.draw_contact(jid, account) 
     349                                        self.draw_avatar(added_iters) 
     350                                        self.draw_account(account) 
     351                                        # Redraw parent to change icon 
     352                                        self.draw_contact(big_brother_jid, big_brother_account) 
    340353                                        return 
    341                                 parent_iters = self.get_contact_iter(big_brother_jid, 
    342                                         big_brother_account) 
    343                                 name = contact.get_shown_name() 
    344                                 for i in parent_iters: 
    345                                         # we add some values here. see draw_contact for more 
    346                                         model.append(i, (None, name, 'contact', jid, account, None)) 
    347                                 self.draw_contact(jid, account) 
    348                                 self.draw_avatar(jid, account) 
    349                                 self.draw_account(account) 
    350                                 # Redraw parent to change icon 
    351                                 self.draw_contact(big_brother_jid, big_brother_account) 
    352                                 return 
    353354 
    354                 if (contact.show in ('offline', 'error') or hide) and \ 
    355                 not showOffline and (not _('Transports') in contact.groups or \ 
    356                 gajim.connections[account].connected < 2) and \ 
    357                 len(gajim.contacts.get_contacts(account, jid)) == 1 and nb_events == 0 and\ 
    358                 not _('Not in Roster') in contact.groups: 
    359                         return 
    360  
    361355                # Remove brother contacts that are already in roster to add them 
    362356                # under this iter 
    363357                for data in shown_family: 
     
    370364                        groups = [_('Observers')] 
    371365                elif not groups: 
    372366                        groups = [_('General')] 
     367                added_iters = [] 
    373368                for group in groups: 
    374369                        self.draw_group(group, account) 
    375                         iterG = self.get_group_iter(group, account) 
    376                         if not iterG: 
    377                                 IterAcct = self.get_account_iter(account) 
    378                                 iterG = model.append(IterAcct, [ 
     370                        child_iterG = self.get_group_iter(group, account, self.model) 
     371                        if not child_iterG: 
     372                                child_iterA = self.get_account_iter(account, self.model) 
     373                                child_iterG = self.model.append(child_iterA, [ 
    379374                                        self.jabber_state_images['16']['closed'], 
    380375                                        gobject.markup_escape_text(group), 'group', 
    381376                                        group, account, None]) 
    382377                                self.draw_group(group, account) 
    383                                 if model.iter_n_children(IterAcct) == 1: # We added the first one 
    384                                         self.draw_account(account) 
    385                         if group not in gajim.groups[account]: # It can probably never append 
     378                        try: 
     379                                iterG = model.convert_child_iter_to_iter(child_iterG) 
     380                        except RuntimeError: 
     381                                # group is not visible in filtered model 
     382                                iterG = None 
     383                        if group not in gajim.groups[account]: 
    386384                                if account + group in self.collapsed_rows: 
    387385                                        ishidden = False 
    388386                                else: 
    389387                                        ishidden = True 
    390388                                gajim.groups[account][group] = {'expand': ishidden} 
    391                         if not account in self.collapsed_rows: 
     389                        if iterG and not account in self.collapsed_rows: 
    392390                                self.tree.expand_row((model.get_path(iterG)[0]), False) 
    393391 
    394392                        typestr = 'contact' 
     
    399397 
    400398                        name = contact.get_shown_name() 
    401399                        # we add some values here. see draw_contact for more 
    402                         model.append(iterG, (None, name, typestr, contact.jid, account, None)) 
     400                        i_ = self.model.append(child_iterG, (None, name, typestr, contact.jid, 
     401                                account, None)) 
     402                        added_iters.append(i_) 
    403403 
    404404                        if gajim.groups[account][group]['expand']: 
    405                                 self.tree.expand_row(model.get_path(iterG), False) 
    406                 self.draw_contact(jid, account) 
    407                 self.draw_avatar(jid, account) 
     405                                #FIXME: why do we need to recall it? because we added a child? 
     406                                iterG = self.get_group_iter(group, account) 
     407                                if iterG: 
     408                                        self.tree.expand_row(model.get_path(iterG), False) 
     409                if not self.starting: 
     410                        self.draw_contact(jid, account) 
     411                        self.draw_avatar(added_iters) 
    408412                self.draw_account(account) 
    409413                # put the children under this iter 
    410414                for data in shown_family: 
     
    413417                        self.add_contact_to_roster(data['jid'], data['account']) 
    414418 
    415419        def draw_group(self, group, account): 
    416                 iter = self.get_group_iter(group, account) 
    417                 if not iter: 
     420                child_iter = self.get_group_iter(group, account, self.model) 
     421                if not child_iter: 
    418422                        return 
    419423                if self.regroup: 
    420424                        accounts = [] 
     
    427431                        nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 
    428432                                accounts = accounts, groups = [group]) 
    429433                        text += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) 
    430                 model = self.tree.get_model() 
    431                 model.set_value(iter, 1 , text) 
     434                self.model.set_value(child_iter, 1 , gobject.markup_escape_text(text)) 
    432435 
    433436        def add_to_not_in_the_roster(self, account, jid, nick = '', resource = ''): 
    434437                ''' add jid to group "not in the roster", he MUST not be in roster yet, 
     
    467470                return contact 
    468471 
    469472        def get_self_contact_iter(self, account): 
    470                 model = self.tree.get_model() 
    471473                iterAcct = self.get_account_iter(account) 
    472                 iter = model.iter_children(iterAcct) 
     474                iter = self.modelfilter.iter_children(iterAcct) 
    473475                if not iter: 
    474476                        return None 
    475                 if model[iter][C_TYPE] == 'self_contact': 
     477                if self.modelfilter[iter][C_TYPE] == 'self_contact': 
    476478                        return iter 
    477479                return None 
    478480 
    479481        def add_self_contact(self, account): 
     482                return 
    480483                jid = gajim.get_jid_from_account(account) 
    481                 if self.get_self_contact_iter(account): 
     484                self_contact_iter = self.get_self_contact_iter(account) 
     485                if self_contact_iter: 
    482486                        self.draw_contact(jid, account) 
    483                         self.draw_avatar(jid, account) 
     487                        child_iter = self.modelfilter.convert_iter_to_child_iter( 
     488                                self_contact_iter) 
     489                        self.draw_avatar(child_iter) 
    484490                        return 
    485491 
    486492                contact = gajim.contacts.get_first_contact_from_jid(account, jid) 
    487493                if not contact: 
    488494                        return 
    489                 showOffline = gajim.config.get('showoffline') 
    490                 if (contact.show in ('offline', 'error')) and not showOffline and \ 
    491                         len(gajim.events.get_events(account, jid)) == 0: 
    492                         return 
    493495 
    494496                model = self.tree.get_model() 
    495                 iterAcct = self.get_account_iter(account) 
    496                 model.append(iterAcct, (None, gajim.nicks[account], 'self_contact', jid, 
    497                         account, None)) 
     497                iterA = self.get_account_iter(account) 
     498                child_model = model.get_model() 
     499                child_iterA = model.convert_iter_to_child_iter(iterA) 
     500                i_ = child_model.append(child_iterA, (None, gajim.nicks[account], 
     501                        'self_contact', jid, account, None)) 
    498502                self.draw_contact(jid, account) 
    499                 self.draw_avatar(jid, account) 
     503                self.draw_avatar([i_]) 
    500504 
    501505        def add_transport_to_roster(self, account, transport): 
    502506                c = gajim.contacts.create_contact(jid = transport, name = transport, 
     
    511515                        return 
    512516                if contact.jid in gajim.newly_added[account]: 
    513517                        return 
    514                 if gajim.jid_is_transport(contact.jid) and gajim.account_is_connected( 
    515                 account) and gajim.config.get('show_transports_group'): 
    516                         # It's an agent and we show them 
    517                         return 
    518518                if contact.jid in gajim.to_be_removed[account]: 
    519519                        gajim.to_be_removed[account].remove(contact.jid) 
     520                        # FIXME: refilter only this contact 
     521#                       for iter in self.get_contact_iter(contact.jid, account, self.model): 
     522#                               path = self.model.get_path(iter) 
     523                                # doesn't work 
     524#                               self.model.row_has_child_toggled(path, iter) 
     525                        self.modelfilter.refilter() 
    520526 
     527#               hide = contact.is_hidden_from_roster() 
     528# 
     529#               show_offline = gajim.config.get('showoffline') 
     530#               show_transports = gajim.config.get('show_transports_group') 
     531# 
     532#               nb_events = 0 
     533#               jid_list = [contact.jid] 
     534#               if contact.get_full_jid() != contact.jid: 
     535#                       jid_list.append(contact.get_full_jid()) 
     536#               for jid in jid_list: 
     537#                       # dont't count printed_chat messages 
     538#                       nb_events += gajim.events.get_nb_roster_events(account, jid, ['chat']) 
     539# 
     540#               if (_('Transports') in contact.groups and not show_transports) or \ 
     541#               ((contact.show in ('offline', 'error') or hide) and not show_offline and \ 
     542#               (not _('Transports') in contact.groups or \ 
     543#               gajim.account_is_disconnected(account))) and nb_events == 0: 
     544#               else: 
     545#                       self.draw_contact(contact.jid, account) 
    521546 
    522                 hide = contact.is_hidden_from_roster() 
    523  
    524                 show_offline = gajim.config.get('showoffline') 
    525                 show_transports = gajim.config.get('show_transports_group') 
    526  
    527                 nb_events = 0 
    528                 jid_list = [contact.jid] 
    529                 if contact.get_full_jid() != contact.jid: 
    530                         jid_list.append(contact.get_full_jid()) 
    531                 for jid in jid_list: 
    532                         # dont't count printed_chat messages 
    533                         nb_events += gajim.events.get_nb_roster_events(account, jid, ['chat']) 
    534  
    535                 if (_('Transports') in contact.groups and not show_transports) or \ 
    536                 ((contact.show in ('offline', 'error') or hide) and not show_offline and \ 
    537                 (not _('Transports') in contact.groups or \ 
    538                 gajim.account_is_disconnected(account))) and nb_events == 0: 
    539                         self.remove_contact(contact, account) 
    540                 else: 
    541                         self.draw_contact(contact.jid, account) 
    542  
    543547        def remove_contact(self, contact, account): 
    544548                '''Remove a contact from the roster''' 
    545549                if contact.jid in gajim.to_be_removed[account]: 
    546550                        return 
    547                 model = self.tree.get_model() 
    548                 iters = self.get_contact_iter(contact.jid, account) 
     551                # look for iters in all (even not shown) iters 
     552                iters = self.get_contact_iter(contact.jid, account, self.model) 
    549553                if not iters: 
    550554                        return 
    551                 parent_iter = model.iter_parent(iters[0]) 
    552                 parent_type = model[parent_iter][C_TYPE] 
     555                parent_iter = self.model.iter_parent(iters[0]) 
     556                parent_type = self.model[parent_iter][C_TYPE] 
    553557                # remember children to re-add them 
    554558                children = [] 
    555                 child_iter = model.iter_children(iters[0]) 
    556                 while child_iter: 
    557                         c_jid = model[child_iter][C_JID].decode('utf-8') 
    558                         c_account = model[child_iter][C_ACCOUNT].decode('utf-8') 
     559                iterC = self.model.iter_children(iters[0]) 
     560                while iterC: 
     561                        c_jid = self.model[iterC][C_JID].decode('utf-8') 
     562                        c_account = self.model[iterC][C_ACCOUNT].decode('utf-8') 
    559563                        children.append((c_jid, c_account)) 
    560                         child_iter = model.iter_next(child_iter) 
     564                        iterC = self.model.iter_next(iterC) 
    561565 
    562566                # Remove iters and group iter if they are empty 
    563567                for i in iters: 
    564                         parent_i = model.iter_parent(i) 
    565                         model.remove(i) 
     568                        parent_i = self.model.iter_parent(i) 
     569                        self.model.remove(i) 
    566570                        if parent_type == 'group': 
    567                                 group = model[parent_i][C_JID].decode('utf-8') 
    568                                 if model.iter_n_children(parent_i) == 0: 
    569                                         model.remove(parent_i) 
    570                                         # We need to check all contacts, even offline contacts 
    571                                         for jid in gajim.contacts.get_jid_list(account): 
    572                                                 if group in gajim.contacts.get_contact_with_highest_priority( 
    573                                                         account, jid).groups: 
    574                                                         break 
    575                                         else: 
    576                                                 if gajim.groups[account].has_key(group): 
    577                                                         del gajim.groups[account][group] 
     571                                group = self.model[parent_i][C_JID].decode('utf-8') 
     572                                if self.model.iter_n_children(parent_i) == 0: 
     573                                        self.model.remove(parent_i) 
     574                                        if gajim.groups[account].has_key(group): 
     575                                                del gajim.groups[account][group] 
    578576                                else: 
    579577                                        self.draw_group(group, account) 
    580578 
     
    583581                        self.add_contact_to_roster(child[0], child[1]) 
    584582                # redraw parent 
    585583                if parent_type == 'contact': 
    586                         parent_jid = model[parent_iter][C_JID].decode('utf-8') 
    587                         parent_account = model[parent_iter][C_ACCOUNT].decode('utf-8') 
     584                        parent_jid = self.model[parent_iter][C_JID].decode('utf-8') 
     585                        parent_account = self.model[parent_iter][C_ACCOUNT].decode('utf-8') 
    588586                        self.draw_contact(parent_jid, parent_account) 
    589587 
    590588        def get_appropriate_state_images(self, jid, size = '16', 
    591                 icon_name = 'online'): 
     589        icon_name = 'online'): 
    592590                '''check jid and return the appropriate state images dict for 
    593591                the demanded size. icon_name is taken into account when jid is from 
    594592                transport: transport iconset doesn't contain all icons, so we fall back 
     
    603601        def draw_contact(self, jid, account, selected = False, focus = False): 
    604602                '''draw the correct state image, name BUT not avatar''' 
    605603                # focus is about if the roster window has toplevel-focus or not 
    606                 model = self.tree.get_model() 
    607                 iters = self.get_contact_iter(jid, account) 
    608                 if len(iters) == 0: 
     604                child_iters = self.get_contact_iter(jid, account, self.model) 
     605                if len(child_iters) == 0: 
    609606                        return 
    610607                contact_instances = gajim.contacts.get_contacts(account, jid) 
    611608                contact = gajim.contacts.get_highest_prio_contact_from_contacts( 
     
    653650                if self.regroup: 
    654651                        add_acct = False 
    655652                        # look through all contacts of all accounts 
    656                         for account_iter in gajim.connections: 
    657                                 if account_iter == account: # useless to add accout name 
     653                        for account_ in gajim.connections: 
     654                                if account_ == account: # useless to add accout name 
    658655                                        continue 
    659                                 for jid_iter in gajim.contacts.get_jid_list(account_iter): 
     656                                for jid_ in gajim.contacts.get_jid_list(account_): 
    660657                                        # [0] cause it'fster than highest_prio 
    661                                         contact_iter = gajim.contacts.\ 
    662                                                 get_first_contact_from_jid(account_iter, jid_iter) 
    663                                         if contact_iter.get_shown_name() == \ 
    664                                         contact.get_shown_name() and\ 
    665                                         (jid_iter, account_iter) != (jid, account): 
     658                                        contact_ = gajim.contacts.get_first_contact_from_jid(account_, 
     659                                                jid_) 
     660                                        if contact_.get_shown_name() == contact.get_shown_name() and \ 
     661                                        (jid_, account_) != (jid, account): 
    666662                                                add_acct = True 
    667663                                                break 
    668664                                if add_acct: 
     
    683679                                        '\n<span size="small" style="italic" foreground="%s">%s</span>' \ 
    684680                                        % (colorstring, gobject.markup_escape_text(status)) 
    685681 
    686                 iter = iters[0] # choose the icon with the first iter 
    687  
    688682                if gajim.gc_connected[account].has_key(jid): 
    689683                        contact.show = 'online' 
    690                         model[iter][C_TYPE] = 'groupchat' 
     684                        # There is no reason for it to be in several groups but who knows... 
     685                        for child_iter in child_iters: 
     686                                self.model[child_iter][C_TYPE] = 'groupchat' 
    691687 
    692688                icon_name = helpers.get_icon_name_to_show(contact, account) 
    693689                # look if another resource has awaiting events 
     
    696692                        if c_icon_name in ('event', 'muc_active', 'muc_inactive'): 
    697693                                icon_name = c_icon_name 
    698694                                break 
    699                 path = model.get_path(iter) 
    700                 if model.iter_has_child(iter): 
     695                child_iters = self.get_contact_iter(jid, account, self.model) 
     696                child_iter = child_iters[0] # choose the icon with the first iter 
     697                try: 
     698                        iter = self.modelfilter.convert_child_iter_to_iter(child_iter) 
     699                except RuntimeError: 
     700                        # iter is not visible in filtered model 
     701                        iter = None 
     702                if iter and self.modelfilter.iter_has_child(iter): 
     703                        path = self.modelfilter.get_path(iter) 
    701704                        if not self.tree.row_expanded(path) and \ 
    702705                        icon_name not in ('event', 'muc_active', 'muc_inactive'): 
    703                                 child_iter = model.iter_children(iter) 
     706                                iterC = self.modelfilter.iter_children(iter) 
    704707                                if icon_name in ('error', 'offline'): 
    705708                                        # get the icon from the first child as they are sorted by show 
    706                                         child_jid = model[child_iter][C_JID].decode('utf-8') 
    707                                         child_account = model[child_iter][C_ACCOUNT].decode('utf-8') 
    708                                         child_contact = gajim.contacts.get_contact_with_highest_priority( 
    709                                                 child_account, child_jid) 
    710                                         child_icon_name = helpers.get_icon_name_to_show(child_contact, 
    711                                                 child_account) 
    712                                         if child_icon_name not in ('error', 'not in roster'): 
    713                                                 icon_name = child_icon_name 
    714                                 while child_iter: 
     709                                        jidC = self.modelfilter[iterC][C_JID].decode('utf-8') 
     710                                        accountC = self.modelfilter[iterC][C_ACCOUNT].decode( 
     711                                                'utf-8') 
     712                                        contactC = gajim.contacts.get_contact_with_highest_priority( 
     713                                                accountC, jidC) 
     714                                        icon_nameC = helpers.get_icon_name_to_show(contactC, accountC) 
     715                                        if icon_nameC not in ('error', 'not in roster'): 
     716                                                icon_name = icon_nameC 
     717                                while iterC: 
    715718                                        # a child has awaiting messages ? 
    716                                         child_jid = model[child_iter][C_JID].decode('utf-8') 
    717                                         child_account = model[child_iter][C_ACCOUNT].decode('utf-8') 
    718                                         if len(gajim.events.get_events(child_account, child_jid)): 
     719                                        jidC = self.modelfilter[iterC][C_JID].decode('utf-8') 
     720                                        accountC = self.modelfilter[iterC][C_ACCOUNT].decode('utf-8') 
     721                                        if len(gajim.events.get_events(accountC, jidC)): 
    719722                                                icon_name = 'event' 
    720723                                                break 
    721                                         child_iter = model.iter_next(child_iter) 
     724                                        iterC = self.modelfilter.iter_next(iterC) 
    722725                        if self.tree.row_expanded(path): 
    723726                                state_images = self.get_appropriate_state_images(jid, 
    724727                                        size = 'opened', icon_name = icon_name) 
     
    733736 
    734737                img = state_images[icon_name] 
    735738 
    736                 for iter in iters: 
    737                         model[iter][C_IMG] = img 
    738                         model[iter][C_NAME] = name 
     739                for child_iter in child_iters: 
     740                        gtk.gdk.threads_enter() 
     741                        self.model[child_iter][C_IMG] = img 
     742                        self.model[child_iter][C_NAME] = name 
     743                        gtk.gdk.threads_leave() 
    739744 
    740745        def draw_parent_contact(self, jid, account): 
    741                 model = self.tree.get_model() 
    742                 iters = self.get_contact_iter(jid, account) 
    743                 if not len(iters): 
     746                child_iters = self.get_contact_iter(jid, account, self.model) 
     747                if not len(child_iters): 
    744748                        return 
    745                 parent_iter = model.iter_parent(iters[0]) 
    746                 if model[parent_iter][C_TYPE] != 'contact': 
     749                parent_iter = self.model.iter_parent(child_iters[0]) 
     750                if self.model[parent_iter][C_TYPE] != 'contact': 
    747751                        # parent is not a contact 
    748752                        return 
    749                 parent_jid = model[parent_iter][C_JID].decode('utf-8') 
    750                 parent_account = model[parent_iter][C_ACCOUNT].decode('utf-8') 
     753                parent_jid = self.model[parent_iter][C_JID].decode('utf-8') 
     754                parent_account = self.model[parent_iter][C_ACCOUNT].decode('utf-8') 
    751755                self.draw_contact(parent_jid, parent_account) 
    752756 
    753         def draw_avatar(self, jid, account): 
    754                 '''draw the avatar''' 
    755                 model = self.tree.get_model() 
    756                 iters = self.get_contact_iter(jid, account) 
     757        def draw_avatar_from_jid(self, jid, account): 
     758                iters = self.get_contact_iter(jid, account, self.model) 
     759                self.draw_avatar(iters) 
     760 
     761        def draw_avatar(self, iters): 
     762                '''draw the avatar 
     763                iters are iters in treemodel, not treemodelfilter''' 
     764                if not iters: 
     765                        return 
     766                jid = self.model[iters[0]][C_JID] 
     767                if not jid: 
     768                        return 
     769                jid = jid.decode('utf-8') 
    757770                if gajim.config.get('show_avatars_in_roster'): 
    758771                        pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid) 
    759772                        if pixbuf in ('ask', None): 
     
    762775                                scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'roster') 
    763776                else: 
    764777                        scaled_pixbuf = None 
    765                 for iter in iters: 
    766                         model[iter][C_SECPIXBUF] = scaled_pixbuf 
     778                for child_iter in iters: 
     779                        self.model[child_iter][C_SECPIXBUF] = scaled_pixbuf 
    767780 
    768781        def join_gc_room(self, account, room_jid, nick, password, minimize=False, 
    769782                is_continued=False): 
     
    12291242 
    12301243        def change_roster_style(self, option): 
    12311244                model = self.tree.get_model() 
    1232                 model.foreach(self._change_style, option) 
     1245                child_model = model.get_model() 
     1246                child_model.foreach(self._change_style, option) 
    12331247                for win in gajim.interface.msg_win_mgr.windows(): 
    12341248                        win.repaint_themed_widgets() 
    12351249 
    12361250        def draw_roster(self): 
    12371251                '''clear and draw roster''' 
    12381252                # clear the model, only if it is not empty 
    1239                 model = self.tree.get_model() 
    1240                 if model: 
    1241                         model.clear() 
     1253                if self.model: 
     1254                        self.model.clear() 
    12421255                for acct in gajim.connections: 
    12431256                        self.add_account_to_roster(acct) 
    12441257                        self.add_account_contacts(acct) 
     
    12471260 
    12481261        def add_account_contacts(self, account): 
    12491262                '''adds contacts of group to roster treeview''' 
    1250                 for jid in gajim.contacts.get_jid_list(account): 
     1263                c1 = time.clock() 
     1264                self.tree.freeze_child_notify() 
     1265                jids = gajim.contacts.get_jid_list(account) 
     1266                self.starting = True 
     1267                for jid in jids: 
    12511268                        self.add_contact_to_roster(jid, account) 
     1269                self.starting = False 
     1270                self.tree.thaw_child_notify() 
    12521271                self.draw_account(account) 
     1272                def draw_contacts(jids, account): 
     1273                        for jid in jids: 
     1274                                self.draw_contact(jid, account) 
     1275                                self.draw_avatar_from_jid(jid, account) 
     1276                                time.sleep(0.01) 
    12531277 
     1278                t = threading.Thread(target=draw_contacts, args=(jids, account)) 
     1279                t.start() 
     1280                c4 = time.clock() 
     1281                print c4-c1 
     1282 
    12541283        def fire_up_unread_messages_events(self, account): 
    12551284                '''reads from db the unread messages, and fire them up''' 
    12561285                for jid in gajim.contacts.get_jid_list(account): 
     
    12751304                gajim.contacts.clear_contacts(account) 
    12761305                for jid in array.keys(): 
    12771306                        jids = jid.split('/') 
    1278                         #get jid 
     1307                        # get jid 
    12791308                        ji = jids[0] 
    1280                         #get resource 
     1309                        # get resource 
    12811310                        resource = '' 
    12821311                        if len(jids) > 1: 
    12831312                                resource = '/'.join(jids[1:]) 
    1284                         #get name 
     1313                        # get name 
    12851314                        name = array[jid]['name'] 
    12861315                        if not name: 
    12871316                                name = '' 
    12881317                        show = 'offline' # show is offline by default 
    1289                         status = '' #no status message by default 
     1318                        status = '' # no status message by default 
    12901319 
    12911320                        keyID = '' 
    12921321                        attached_keys = gajim.config.get_per('accounts', account, 
     
    13561385                                gajim.contacts.remove_contact(account, contact) 
    13571386                elif len(contact_instances) > 1 and contact.resource != '': 
    13581387                        name += '/' + contact.resource 
    1359                 self.remove_contact(contact, account) 
    1360                 self.add_contact_to_roster(contact.jid, account) 
     1388                if gajim.contacts.has_brother(account, contact.jid): 
     1389                        # Big brother maybe changed 
     1390                        self.remove_contact(contact, account) 
     1391                        self.add_contact_to_roster(contact.jid, account) 
     1392                else: 
     1393                        self.draw_contact(contact.jid, account) 
    13611394                # print status in chat window and update status/GPG image 
    13621395                if gajim.interface.msg_win_mgr.has_window(contact.jid, account): 
    13631396                        win = gajim.interface.msg_win_mgr.get_window(contact.jid, account) 
     
    13801413                        contact.jid in gajim.interface.status_sent_to_users[account]: 
    13811414                        del gajim.interface.status_sent_to_users[account][contact.jid] 
    13821415 
     1416                self.modelfilter.refilter() 
    13831417                if not contact.groups: 
    13841418                        self.draw_group(_('General'), account) 
    13851419                else: 
     
    34293463 
    34303464        def set_connecting_state(self, account): 
    34313465                model = self.tree.get_model() 
    3432                 accountIter = self.get_account_iter(account) 
    3433                 if accountIter: 
    3434                         model[accountIter][0] = self.jabber_state_images['16']['connecting'] 
     3466                child_model = model.get_model() 
     3467                IterA = self.get_account_iter(account) 
     3468                if IterA: 
     3469                        child_iterA = model.convert_iter_to_child_iter(IterA) 
     3470                        child_model[child_iterA][0] = \ 
     3471                                self.jabber_state_images['16']['connecting'] 
    34353472                if gajim.interface.systray_enabled: 
    34363473                        gajim.interface.systray.change_status('connecting') 
    34373474 
    34383475        def send_status(self, account, status, txt, auto = False, to = None): 
    34393476                model = self.tree.get_model() 
    3440                 accountIter = self.get_account_iter(account) 
     3477                child_model = model.get_model() 
     3478                iterA = self.get_account_iter(account) 
    34413479                if status != 'offline': 
    34423480                        if gajim.connections[account].connected < 2: 
    34433481                                self.set_connecting_state(account) 
     
    34523490                                                _('Save password')) 
    34533491                                        passphrase, save = w.run() 
    34543492                                        if passphrase == -1: 
    3455                                                 if accountIter: 
    3456                                                         model[accountIter][0] = self.jabber_state_images['16']\ 
    3457                                                                 ['offline'] 
     3493                                                if iterA: 
     3494                                                        child_iterA = model.convert_iter_to_child_iter(iterA) 
     3495                                                        child_model[child_iterA][0] = self.jabber_state_images[ 
     3496                                                                '16']['offline'] 
    34583497                                                if gajim.interface.systray_enabled: 
    34593498                                                        gajim.interface.systray.change_status('offline') 
    34603499                                                self.update_status_combobox() 
     
    37753814        def set_account_status_icon(self, account): 
    37763815                status = gajim.connections[account].connected 
    37773816                model = self.tree.get_model() 
    3778                 accountIter = self.get_account_iter(account) 
    3779                 if not accountIter: 
     3817                child_model = model.get_model() 
     3818                iterA = self.get_account_iter(account) 
     3819                if not iterA: 
    37803820                        return 
     3821                child_iterA = model.convert_iter_to_child_iter(iterA) 
    37813822                if not self.regroup: 
    37823823                        show = gajim.SHOW_LIST[status] 
    37833824                else:   # accounts merged 
    37843825                        show = helpers.get_global_show() 
    3785                 model[accountIter][C_IMG] = self.jabber_state_images['16'][show] 
     3826                child_model[child_iterA][C_IMG] = self.jabber_state_images['16'][show] 
    37863827 
    37873828        def on_status_changed(self, account, status): 
    37883829                '''the core tells us that our status has changed''' 
    37893830                if account not in gajim.contacts.get_accounts(): 
    37903831                        return 
    37913832                model = self.tree.get_model() 
    3792                 accountIter = self.get_account_iter(account) 
     3833                child_model = model.get_model() 
     3834                iterA = self.get_account_iter(account) 
     3835                child_iterA = model.convert_iter_to_child_iter(iterA) 
    37933836                self.set_account_status_icon(account) 
    37943837                if status == 'offline': 
    37953838                        if self.quit_on_next_offline > -1: 
    37963839                                self.quit_on_next_offline -= 1 
    37973840                                if self.quit_on_next_offline < 1: 
    37983841                                        self.quit_gtkgui_interface() 
    3799                         else: 
    3800                                 # No need to redraw contacts if we're quitting 
    3801                                 if accountIter: 
    3802                                         model[accountIter][C_SECPIXBUF] = None 
    3803                                 if gajim.con_types.has_key(account): 
    3804                                         gajim.con_types[account] = None 
    3805                                 for jid in gajim.contacts.get_jid_list(account): 
    3806                                         lcontact = gajim.contacts.get_contacts(account, jid) 
    3807                                         lcontact_copy = [] 
    3808                                         for contact in lcontact: 
    3809                                                 lcontact_copy.append(contact) 
    3810                                         for contact in lcontact_copy: 
    3811                                                 self.chg_contact_status(contact, 'offline', '', account) 
     3842                                return # No need to update GUI, we're quitting 
     3843                        if iterA: 
     3844                                child_model[child_iterA][C_SECPIXBUF] = None 
     3845                        if gajim.con_types.has_key(account): 
     3846                                gajim.con_types[account] = None 
     3847                        for jid in gajim.contacts.get_jid_list(account): 
     3848                                lcontact = gajim.contacts.get_contacts(account, jid) 
     3849                                lcontact_copy = [] 
     3850                                for contact in lcontact: 
     3851                                        lcontact_copy.append(contact) 
     3852                                for contact in lcontact_copy: 
     3853                                        self.chg_contact_status(contact, 'offline', '', account) 
    38123854                        self.actions_menu_needs_rebuild = True 
    38133855                self.update_status_combobox() 
    38143856                # Force the rebuild now since the on_activates on the menu itself does 
     
    38523894 
    38533895        def new_chat_from_jid(self, account, fjid): 
    38543896                jid, resource = gajim.get_room_and_nick_from_fjid(fjid) 
    3855                 if resource: 
    3856                         contact = gajim.contacts.get_contact(account, jid, resource) 
    3857                 else: 
    3858                         contact = gajim.contacts.get_contact_with_highest_priority(account, 
    3859                                 jid) 
     3897                contact = gajim.contacts.get_contact(account, jid, resource) 
    38603898                added_to_roster = False 
    38613899                if not contact: 
    38623900                        added_to_roster = True 
     
    40564094 
    40574095        def on_show_transports_menuitem_activate(self, widget): 
    40584096                gajim.config.set('show_transports_group', widget.get_active()) 
    4059                 self.draw_roster() 
     4097                self.tree.get_model().refilter() 
    40604098 
    40614099        def on_manage_bookmarks_menuitem_activate(self, widget): 
    40624100                config.ManageBookmarksWindow() 
     
    43544392        def on_roster_treeview_row_expanded(self, widget, iter, path): 
    43554393                '''When a row is expanded change the icon of the arrow''' 
    43564394                model = self.tree.get_model() 
     4395                child_model = model.get_model() 
     4396                child_iter =  model.convert_iter_to_child_iter(iter) 
    43574397                if self.regroup: # merged accounts 
    43584398                        accounts = gajim.connections.keys() 
    43594399                else: 
    43604400                        accounts = [model[iter][C_ACCOUNT].decode('utf-8')] 
    43614401                type_ = model[iter][C_TYPE] 
    43624402                if type_ == 'group': 
    4363                         model.set_value(iter, 0, self.jabber_state_images['16']['opened']) 
     4403                        child_model[child_iter][C_IMG] = self.jabber_state_images['16'][ 
     4404                                'opened'] 
    43644405                        jid = model[iter][C_JID].decode('utf-8') 
    43654406                        for account in accounts: 
    43664407                                if gajim.groups[account].has_key(jid): # This account has this group 
     
    43864427                '''When a row is collapsed : 
    43874428                change the icon of the arrow''' 
    43884429                model = self.tree.get_model() 
     4430                child_model = model.get_model() 
     4431                child_iter =  model.convert_iter_to_child_iter(iter) 
    43894432                if self.regroup: # merged accounts 
    43904433                        accounts = gajim.connections.keys() 
    43914434                else: 
    43924435                        accounts = [model[iter][C_ACCOUNT].decode('utf-8')] 
    43934436                type_ = model[iter][C_TYPE] 
    43944437                if type_ == 'group': 
    4395                         model.set_value(iter, 0, self.jabber_state_images['16']['closed']) 
     4438                        child_model[child_iter][C_IMG] = self.jabber_state_images['16'][ 
     4439                                'closed'] 
    43964440                        jid = model[iter][C_JID].decode('utf-8') 
    43974441                        for account in accounts: 
    43984442                                if gajim.groups[account].has_key(jid): # This account has this group 
     
    44094453                        account = model[iter][C_ACCOUNT].decode('utf-8') 
    44104454                        self.draw_contact(jid, account) 
    44114455 
     4456        def on_model_row_has_child_toggled(self, model, path, iter): 
     4457                '''When we add child, look if we have to expand parent''' 
     4458                iter_parent = model.iter_parent(iter) 
     4459                if not iter_parent: 
     4460                        # it's an account row, nothing to do 
     4461                        return 
     4462                type_ = model[iter][C_TYPE] 
     4463                account = model[iter][C_ACCOUNT] 
     4464                if not account: 
     4465                        return 
     4466                account = account.decode('utf-8') 
     4467                if type_ == 'group' and not account in self.collapsed_rows: 
     4468                        # expand account row 
     4469                        self.tree.expand_row(path[:-1], False) 
     4470                else: 
     4471                        group = model[iter_parent][C_JID].decode('utf-8') 
     4472                        if  not account + group in self.collapsed_rows: 
     4473                                self.tree.expand_row(path[:-1], False) 
     4474#               print ' has_child', model.iter_has_child(iter) 
     4475#               child_iter = model.convert_iter_to_child_iter(iter) 
     4476#               print ' expanded', self.model. 
     4477 
    44124478        def on_service_disco_menuitem_activate(self, widget, account): 
    44134479                server_jid = gajim.config.get_per('accounts', account, 'hostname') 
    44144480                if gajim.interface.instances[account]['disco'].has_key(server_jid): 
     
    45614627                '''when show offline option is changed: 
    45624628                redraw the treeview''' 
    45634629                gajim.config.set('showoffline', not gajim.config.get('showoffline')) 
    4564                 self.draw_roster() 
     4630                self.modelfilter.refilter() 
    45654631 
    45664632        def set_renderer_color(self, renderer, style, set_background = True): 
    45674633                '''set style for treeview cell, using PRELIGHT system color''' 
     
    47314797                                show = u.show 
    47324798                return show 
    47334799 
     4800        def contact_is_visible(self, contact, account): 
     4801                # show it if pending events 
     4802                if gajim.events.get_nb_roster_events(account, contact.jid) > 0: 
     4803                        return True 
     4804                # count events from all resources 
     4805                for contact_ in gajim.contacts.get_contacts(account, contact.jid): 
     4806                        if contact_.resource and gajim.events.get_nb_roster_events(account, 
     4807                        contact_.get_full_jid()) > 0: 
     4808                                return True 
     4809                # XEP-0162 
     4810                hide = contact.is_hidden_from_roster() 
     4811                if hide and contact.sub != 'from': 
     4812                        return False 
     4813 
     4814                showOffline = gajim.config.get('showoffline') 
     4815                if (contact.show in ('offline', 'error') or hide) and not showOffline: 
     4816                        if contact.jid in gajim.to_be_removed[account]: 
     4817                                return True 
     4818                        return False 
     4819                return True 
     4820 
     4821        def visible_func(self, model, iter): 
     4822                type_ = model[iter][C_TYPE] 
     4823                if not type_: 
     4824                        return False 
     4825                if type_ == 'account': 
     4826                        return True 
     4827                account = model[iter][C_ACCOUNT] 
     4828                if not account: 
     4829                        return False 
     4830                account = account.decode('utf-8') 
     4831                jid = model[iter][C_JID] 
     4832                if not jid: 
     4833                        return False 
     4834                jid = jid.decode('utf-8') 
     4835                if type_ == 'group': 
     4836                        group = jid 
     4837                        if group == _('Transports'): 
     4838                                return gajim.config.get('show_transports_group') 
     4839                        for contact in gajim.contacts.iter_contacts(account): 
     4840                                # Is this contact in this group ? 
     4841                                if group in contact.groups or (group == _('General') and not \ 
     4842                                contact.groups): 
     4843                                        if self.contact_is_visible(contact, account): 
     4844                                                return True 
     4845                        return False 
     4846                if type_ == 'contact': 
     4847                        contact = gajim.contacts.get_first_contact_from_jid(account, jid) 
     4848                        return self.contact_is_visible(contact, account) 
     4849                if type_ == 'agent': 
     4850                        return gajim.config.get('show_transports_group') 
     4851                return True 
     4852 
    47344853        def compareIters(self, model, iter1, iter2, data = None): 
    47354854                '''Compare two iters to sort them''' 
    47364855                name1 = model[iter1][C_NAME] 
     
    48394958                self.dragging = False 
    48404959 
    48414960        def on_drop_in_contact(self, widget, account_source, c_source, account_dest, 
    4842                 c_dest, was_big_brother, context, etime): 
     4961        c_dest, was_big_brother, context, etime): 
    48434962                if not gajim.connections[account_source].private_storage_supported or not\ 
    48444963                gajim.connections[account_dest].private_storage_supported: 
    48454964                        dialogs.WarningDialog(_('Metacontacts storage not supported by your ' 
     
    49215040                        context.finish(True, True, etime) 
    49225041 
    49235042        def add_contact_to_group(self, account, contact, group): 
    4924                 model = self.tree.get_model() 
    49255043                if not group in contact.groups: 
    49265044                        contact.groups.append(group) 
    49275045                # Remove all rows because add_contact_to_roster doesn't add it if one 
    49285046                # is already in roster 
    4929                 for i in self.get_contact_iter(contact.jid, account): 
    4930                         model.remove(i) 
     5047                for i in self.get_contact_iter(contact.jid, account, self.model): 
     5048                        self.model.remove(i) 
    49315049                self.add_contact_to_roster(contact.jid, account) 
    49325050                gajim.connections[account].update_contact(contact.jid, contact.name, 
    49335051                        contact.groups) 
     
    49385056                        contact.groups.remove(group) 
    49395057                self.remove_contact(contact, account) 
    49405058 
     5059        def drag_drop(self, treeview, context, x, y, timestamp): 
     5060                target_list = treeview.drag_dest_get_target_list() 
     5061                target = treeview.drag_dest_find_target(context, target_list) 
     5062                selection = treeview.drag_get_data(context, target) 
     5063                context.finish(False, True) 
     5064                return True 
     5065 
    49415066        def drag_data_received_data(self, treeview, context, x, y, selection, info, 
    4942                 etime): 
     5067        etime): 
     5068                treeview.stop_emission('drag_data_received') 
    49435069                drop_info = treeview.get_dest_row_at_pos(x, y) 
    49445070                if not drop_info: 
    49455071                        return 
     
    52655391                self.popup_notification_windows = [] 
    52665392 
    52675393                #(icon, name, type, jid, account, editable, secondary_pixbuf) 
    5268                 model = gtk.TreeStore(gtk.Image, str, str, str, str, gtk.gdk.Pixbuf) 
     5394                self.model = gtk.TreeStore(gtk.Image, str, str, str, str, gtk.gdk.Pixbuf) 
    52695395 
    5270                 model.set_sort_func(1, self.compareIters) 
    5271                 model.set_sort_column_id(1, gtk.SORT_ASCENDING) 
    5272                 self.tree.set_model(model) 
     5396                self.model.set_sort_func(1, self.compareIters) 
     5397                self.model.set_sort_column_id(1, gtk.SORT_ASCENDING) 
     5398                self.modelfilter = self.model.filter_new() 
     5399                self.modelfilter.set_visible_func(self.visible_func) 
     5400                self.modelfilter.connect('row_changed', self.on_model_row_has_child_toggled) 
     5401                self.tree.set_model(self.modelfilter) 
     5402 
    52735403                # when this value become 0 we quit main application 
    52745404                self.quit_on_next_offline = -1 
    52755405                self.make_jabber_state_images() 
     
    54005530                self.tree.enable_model_drag_dest(TARGETS2, gtk.gdk.ACTION_DEFAULT) 
    54015531                self.tree.connect('drag_begin', self.drag_begin) 
    54025532                self.tree.connect('drag_end', self.drag_end) 
     5533                self.tree.connect('drag_drop', self.drag_drop) 
    54035534                self.tree.connect('drag_data_get', self.drag_data_get_data) 
    54045535                self.tree.connect('drag_data_received', self.drag_data_received_data) 
    54055536                self.dragging = False 
  • src/gajim.py

     
    656656                        # It must be an agent 
    657657                        if ji in jid_list: 
    658658                                # Update existing iter 
     659                                self.roster.modelfilter.refilter() 
    659660                                self.roster.draw_contact(ji, account) 
    660661                                self.roster.draw_group(_('Transports'), account) 
    661662                                if new_show > 1 and ji in gajim.transport_avatar[account]: 
     
    10791080                if gc_ctrl and gc_ctrl.type_id == message_control.TYPE_GC: 
    10801081                        gc_ctrl.draw_avatar(resource) 
    10811082                else: 
    1082                         self.roster.draw_avatar(jid, account) 
     1083                        self.roster.draw_avatar_from_jid(jid, account) 
    10831084                if self.remote_ctrl: 
    10841085                        self.remote_ctrl.raise_signal('VcardInfo', (account, vcard)) 
    10851086 
  • src/common/contacts.py

     
    238238                                        return c 
    239239                return None 
    240240 
     241        def iter_contacts(self, account): 
     242                for jid in self._contacts[account]: 
     243                        for contact in self._contacts[account][jid]: 
     244                                yield contact 
     245 
    241246        def get_contact_from_full_jid(self, account, fjid): 
    242247                ''' Get Contact object for specific resource of given jid''' 
    243248                barejid, resource = common.gajim.get_room_and_nick_from_fjid(fjid) 
     
    285290                for account in accounts: 
    286291                        our_jid = common.gajim.get_jid_from_account(account) 
    287292                        for jid in self.get_jid_list(account): 
    288                                 if self.has_brother(account, jid) and not \ 
    289                                         self.is_big_brother(account, jid): 
    290                                         # count metacontacts only once 
    291                                         continue 
     293#                               if self.has_brother(account, jid) and not \ 
     294#                                       self.is_big_brother(account, jid): 
     295#                                       # count metacontacts only once 
     296#                                       continue 
    292297                                if jid == our_jid: 
    293298                                        continue 
    294299                                if common.gajim.jid_is_transport(jid) and not \