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

def roster_window::RosterWindow::draw_contact (   self,
  jid,
  account,
  selected = False,
  focus = False 
)

draw the correct state image, name BUT not avatar

Definition at line 420 of file roster_window.py.

00420                                                                            :
            '''draw the correct state image, name BUT not avatar'''
            # focus is about if the roster window has toplevel-focus or not
            model = self.tree.get_model()
            iters = self.get_contact_iter(jid, account)
            if len(iters) == 0:
                  return
            contact_instances = gajim.contacts.get_contact(account, jid)
            contact = gajim.contacts.get_highest_prio_contact_from_contacts(
                  contact_instances)
            if not contact:
                  return
            name = gtkgui_helpers.escape_for_pango_markup(contact.get_shown_name())

            if len(contact_instances) > 1:
                  name += ' (' + unicode(len(contact_instances)) + ')'

            # show (account_name) if there are 2 contact with same jid in merged mode
            if self.regroup:
                  add_acct = False
                  # look through all contacts of all accounts
                  for a in gajim.connections:
                        for j in gajim.contacts.get_jid_list(a):
                              # [0] cause it'fster than highest_prio
                              c = gajim.contacts.get_first_contact_from_jid(a, j)
                              if c.name == contact.name and (j, a) != (jid, account):
                                    add_acct = True
                                    break
                        if add_acct:
                              # No need to continue in other account if we already found one
                              break
                  if add_acct:
                        name += ' (' + account + ')'

            # add status msg, if not empty, under contact name in the treeview
            if contact.status and gajim.config.get('show_status_msgs_in_roster'):
                  status = contact.status.strip()
                  if status != '':
                        status = gtkgui_helpers.reduce_chars_newlines(status, max_lines = 1)
                        # escape markup entities and make them small italic and fg color
                        color = gtkgui_helpers._get_fade_color(self.tree, selected, focus)
                        colorstring = "#%04x%04x%04x" % (color.red, color.green, color.blue)
                        name += '\n<span size="small" style="italic" foreground="%s">%s</span>'\
                              % (colorstring, gtkgui_helpers.escape_for_pango_markup(status))

            iter = iters[0] # choose the icon with the first iter
            icon_name = helpers.get_icon_name_to_show(contact, account)
            # look if anotherresource has awaiting events
            for c in contact_instances:
                  c_icon_name = helpers.get_icon_name_to_show(c, account)
                  if c_icon_name == 'message':
                        icon_name = c_icon_name
                        break
            path = model.get_path(iter)
            if model.iter_has_child(iter):
                  if not self.tree.row_expanded(path) and icon_name != 'message':
                        child_iter = model.iter_children(iter)
                        if icon_name in ('error', 'offline'):
                              # get the icon from the first child as they are sorted by show
                              child_jid = model[child_iter][C_JID].decode('utf-8')
                              child_contact = gajim.contacts.get_contact_with_highest_priority(
                                    account, child_jid)
                              child_icon_name = helpers.get_icon_name_to_show(child_contact, account)
                              if child_icon_name not in ('error', 'not in roster'):
                                    icon_name = child_icon_name
                        while child_iter:
                              # a child has awaiting messages ?
                              child_jid = model[child_iter][C_JID].decode('utf-8')
                              if gajim.awaiting_events[account].has_key(child_jid):
                                    icon_name = 'message'
                                    break
                              child_iter = model.iter_next(child_iter)
                  if self.tree.row_expanded(path):
                        state_images = self.get_appropriate_state_images(jid,
                              size = 'opened', icon_name = icon_name)
                  else:
                        state_images = self.get_appropriate_state_images(jid,
                              size = 'closed', icon_name = icon_name)
            else:
                  # redraw parent
                  self.draw_parent_contact(jid, account)
                  state_images = self.get_appropriate_state_images(jid,
                        icon_name = icon_name)
      
            img = state_images[icon_name]

            for iter in iters:
                  model[iter][C_IMG] = img
                  model[iter][C_NAME] = name

      def draw_parent_contact(self, jid, account):


Generated by  Doxygen 1.6.0   Back to index