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

def roster_window::RosterWindow::on_cell_edited (   self,
  cell,
  row,
  new_text 
)

When an iter is edited:
if text has changed, rename the contact

Definition at line 2610 of file roster_window.py.

02610                                                    :
            '''When an iter is edited:
            if text has changed, rename the contact'''
            model = self.tree.get_model()
            # if this is a last item in the group, row is invalid
            try:
                  iter = model.get_iter_from_string(row)
            except:
                  self.editing_path = None
                  return
            path = model.get_path(iter)
            # do not set new name if row order has changed
            if path != self.editing_path:
                  self.editing_path = None
                  return
            self.editing_path = None
            new_text = new_text.decode('utf-8')
            account = model[iter][C_ACCOUNT].decode('utf-8')
            jid = model[iter][C_JID].decode('utf-8')
            type = model[iter][C_TYPE]
            model[iter][C_EDITABLE] = False
            if type in ('contact', 'agent'):
                  old_text = gajim.contacts.get_contact_with_highest_priority(account,
                        jid).name
                  if old_text != new_text:
                        for u in gajim.contacts.get_contact(account, jid):
                              u.name = new_text
                        gajim.connections[account].update_contact(jid, new_text, u.groups)
                  self.draw_contact(jid, account)
                  # Update opened chat
                  ctrl = gajim.interface.msg_win_mgr.get_control(jid, account)
                  if ctrl:
                        ctrl.update_ui()
                        win = gajim.interface.msg_win_mgr.get_window(jid, account)
                        win.redraw_tab(ctrl)
                        win.show_title()
            elif type == 'group':
                  # in C_JID column, we hold the group name (which is not escaped)
                  old_name = model[iter][C_JID].decode('utf-8')
                  # Groups may not change name from or to a special groups
                  for g in helpers.special_groups:
                        if g in (new_text, old_name):
                              return
                  # get all contacts in that group
                  for jid in gajim.contacts.get_jid_list(account):
                        contact = gajim.contacts.get_contact_with_highest_priority(account,
                              jid)
                        if old_name in contact.groups:
                              # set them in the new one and remove it from the old
                              contact.groups.remove(old_name)
                              self.remove_contact(contact, account)
                              if not new_text in contact.groups:
                                    contact.groups.append(new_text)
                              self.add_contact_to_roster(contact.jid, account)
                              gajim.connections[account].update_contact(contact.jid,
                                    contact.name, contact.groups)
                  # If last removed iter was not visible, gajim.groups is not cleaned
                  if gajim.groups[account].has_key(old_name):
                        del gajim.groups[account][old_name]

      def on_service_disco_menuitem_activate(self, widget, account):


Generated by  Doxygen 1.6.0   Back to index