def append_contact(self, contact): identifer = contact.get_id() itr = self.get_model().append( \ self.get_group_itr_by_name(contact.group), \ [identifer, contact.name, contact.group, contact.version, contact.login, contact.host, None, \ contact.addr[0] in ipmsg.get_block_list() and icons.Menu.get_pixbuf('block') or None, ]) self.expand_to_path(self.get_model().get_path(itr))
def update_contact(self, contact, root_itr): id_addr = contact.get_id() itr = root_itr model = self.get_model() while itr: if model.get_value(itr, 0) == id_addr: get_markup = contact.has_left_for() > 0 and self.get_offline_markup or self.get_normal_markup model.set(itr, 1, get_markup(contact.name), 2, get_markup(contact.group), 3, get_markup(contact.version), 4, get_markup(contact.login), 5, get_markup(contact.host), 6, icons.Menu.get_status_pixbuf(contact.status), 7, contact.addr[0] in ipmsg.get_block_list() and icons.Menu.get_pixbuf('block') or None, ) return itr itr = model.iter_next(itr) return None
def make_context_menu(self, itr): menu = gtk.Menu() menu.show() model = self.get_model() contact_id = model.get_value(itr, 0).split(':')[0] if contact_id in ipmsg.get_block_list(): item = gtk.MenuItem('Unblock', False) def on_handle(w, *args): model.set(itr, 7, None) settings['block_list'] = [ip for ip in settings['block_list'] if ip != contact_id] settings.save() ipmsg.update_block_list() else: item = gtk.MenuItem('Block', False) def on_handle(w, *args): model.set(itr, 7, icons.Menu.get_pixbuf('block')) settings['block_list'].append(contact_id) settings.save() ipmsg.update_block_list() item.connect('activate', on_handle) item.show() menu.add(item) return menu