Logo Search packages:      
Sourcecode: gajim version File versions  Download package

def roster_window::RosterWindow::remove_contact (   self,
  contact,
  account 
)

Remove a contact from the roster

Definition at line 363 of file roster_window.py.

00363                                                 :
            '''Remove a contact from the roster'''
            if contact.jid in gajim.to_be_removed[account]:
                  return
            model = self.tree.get_model()
            iters = self.get_contact_iter(contact.jid, account)
            if not iters:
                  return
            parent_iter = model.iter_parent(iters[0])
            parent_type = model[parent_iter][C_TYPE]
            # remember children to re-add them
            children = []
            child_iter = model.iter_children(iters[0])
            while child_iter:
                  c_jid = model[child_iter][C_JID].decode('utf-8')
                  c_account = model[child_iter][C_ACCOUNT].decode('utf-8')
                  children.append((c_jid, c_account))
                  child_iter = model.iter_next(child_iter)
            
            # Remove iters and group iter if they are empty
            for i in iters:
                  parent_i = model.iter_parent(i)
                  model.remove(i)
                  if parent_type == 'group':
                        group = model[parent_i][C_JID].decode('utf-8')
                        if model.iter_n_children(parent_i) == 0:
                              model.remove(parent_i)
                              # We need to check all contacts, even offline contacts
                              for jid in gajim.contacts.get_jid_list(account):
                                    if group in gajim.contacts.get_contact_with_highest_priority(
                                          account, jid).groups:
                                          break
                              else:
                                    if gajim.groups[account].has_key(group):
                                          del gajim.groups[account][group]

            # re-add children
            for child in children:
                  self.add_contact_to_roster(child[0], child[1])
            # redraw parent
            if parent_type == 'contact':
                  parent_jid = model[parent_iter][C_JID].decode('utf-8')
                  parent_account = model[parent_iter][C_ACCOUNT].decode('utf-8')
                  self.draw_contact(parent_jid, parent_account)

      def get_appropriate_state_images(self, jid, size = '16',


Generated by  Doxygen 1.6.0   Back to index