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

def roster_window::RosterWindow::compareIters (   self,
  model,
  iter1,
  iter2,
  data = None 
)

Compare two iters to sort them

Definition at line 2930 of file roster_window.py.

02930                                                               :
            '''Compare two iters to sort them'''
            name1 = model[iter1][C_NAME]
            name2 = model[iter2][C_NAME]
            if not name1 or not name2:
                  return 0
            name1 = name1.decode('utf-8')
            name2 = name2.decode('utf-8')
            type1 = model[iter1][C_TYPE]
            type2 = model[iter2][C_TYPE]
            if type1 == 'group':
                  if name1 == _('Transports'):
                        return 1
                  if name2 == _('Transports'):
                        return -1
                  if name1 == _('Not in Roster'):
                        return 1
                  if name2 == _('Not in Roster'):
                        return -1
            account1 = model[iter1][C_ACCOUNT]
            account2 = model[iter2][C_ACCOUNT]
            if not account1 or not account2:
                  return 0
            account1 = account1.decode('utf-8')
            account2 = account2.decode('utf-8')
            jid1 = model[iter1][C_JID].decode('utf-8')
            jid2 = model[iter2][C_JID].decode('utf-8')
            if type1 == 'contact':
                  lcontact1 = gajim.contacts.get_contact(account1, jid1)
                  contact1 = gajim.contacts.get_first_contact_from_jid(account1, jid1)
                  if not contact1:
                        return 0
                  name1 = contact1.get_shown_name()
            if type2 == 'contact':
                  lcontact2 = gajim.contacts.get_contact(account2, jid2)
                  contact2 = gajim.contacts.get_first_contact_from_jid(account2, jid2)
                  if not contact2:
                        return 0
                  name2 = contact2.get_shown_name()
            # We first compare by show if sort_by_show is True or if it's a child
            # contact
            if type1 == 'contact' and type2 == 'contact' and \
            gajim.config.get('sort_by_show'):
                  cshow = {'online':0, 'chat': 1, 'away': 2, 'xa': 3, 'dnd': 4,
                        'invisible': 5, 'offline': 6, 'not in roster': 7, 'error': 8}
                  s = self.get_show(lcontact1)
                  if s in cshow:
                        show1 = cshow[s]
                  else:
                        show1 = 9
                  s = self.get_show(lcontact2)
                  if s in cshow:
                        show2 = cshow[s]
                  else:
                        show2 = 9
                  if show1 < show2:
                        return -1
                  elif show1 > show2:
                        return 1
            # We compare names
            if name1.lower() < name2.lower():
                  return -1
            if name2.lower() < name1.lower():
                  return 1
            if type1 == 'contact' and type2 == 'contact':
                  # We compare account names
                  if account1.lower() < account2.lower():
                        return -1
                  if account2.lower() < account1.lower():
                        return 1
                  # We compare jids
                  if jid1.lower() < jid2.lower():
                        return -1
                  if jid2.lower() < jid1.lower():
                        return 1
            return 0

      def drag_data_get_data(self, treeview, context, selection, target_id, etime):


Generated by  Doxygen 1.6.0   Back to index