Author: steve-e Date: 2008-05-19 22:00:41 +0200 (Mon, 19 May 2008) New Revision: 9679
Modified: trunk/src/gajim.py trunk/src/roster_window.py trunk/src/session.py Log: Improve select_contact method. * use correct API in session.py * only filter when really needed
Modified: trunk/src/gajim.py =================================================================== --- trunk/src/gajim.py 2008-05-19 19:06:11 UTC (rev 9678) +++ trunk/src/gajim.py 2008-05-19 20:00:41 UTC (rev 9679) @@ -2419,8 +2419,8 @@ self.roster.add_to_not_in_the_roster(account, jid) self.roster.draw_contact(jid, account)
- # Show contact in roster (if he is invisible for example) and select line - self.roster.show_and_select_contact_if_having_events(jid, account) + # Select the contact in roster, it's visible because it has events. + self.roster.select_contact(jid, account)
def remove_first_event(self, account, jid, type_ = None): event = gajim.events.get_first_event(account, jid, type_)
Modified: trunk/src/roster_window.py =================================================================== --- trunk/src/roster_window.py 2008-05-19 19:06:11 UTC (rev 9678) +++ trunk/src/roster_window.py 2008-05-19 20:00:41 UTC (rev 9679) @@ -949,6 +949,12 @@
name = gobject.markup_escape_text(contact.get_shown_name())
+ groups = contact.groups + if contact.is_observer(): + groups = [_('Observers')] + elif not groups: + groups = [_('General')] + # gets number of unread gc marked messages if jid in gajim.interface.minimized_controls[account]: nb_unread = len(gajim.events.get_events(account, jid, @@ -966,11 +972,6 @@ if jid in gajim.connections[account].blocked_contacts: strike = True else: - groups = contact.groups - if contact.is_observer(): - groups = [_('Observers')] - elif not groups: - groups = [_('General')] for group in groups: if group in gajim.connections[account].blocked_groups: strike = True @@ -1117,6 +1118,13 @@ for c, acc in brothers: self.draw_contact(c.jid, acc) self.draw_avatar(c.jid, acc) + + for group in groups: + # We need to make sure that _visible_func is called for + # our groups otherwise we might not be shown + iterG = self._get_group_iter(group, account, model = self.model) + self.model[iterG][C_JID] = self.model[iterG][C_JID] + return False
@@ -1232,10 +1240,13 @@ self.tree.columns_autosize() - def show_and_select_contact_if_having_events(self, jid, account): + def select_contact(self, jid, account): '''Select contact in roster. If contact is hidden but has eventsi, show him.''' - self.refilter_shown_roster_items() + # Refiltering SHOULD NOT be needed: + # When a contact gets a new event he will be redrawn and his + # icon changes, so _visible_func WILL be called on him anyway + iters = self._get_contact_iter(jid, account) if not iters: # Not visible in roster
Modified: trunk/src/session.py =================================================================== --- trunk/src/session.py 2008-05-19 19:06:11 UTC (rev 9678) +++ trunk/src/session.py 2008-05-19 20:00:41 UTC (rev 9679) @@ -330,13 +330,6 @@ contact = gajim.interface.roster.add_to_not_in_the_roster( self.conn.name, jid, user_nick)
- # If visible, try to get first line of contact in roster - path = None - iters = gajim.interface.roster._get_contact_iter(jid, self.conn.name, - contact=contact) - if iters: - path = gajim.interface.roster.modelfilter.get_path(iters[0]) - if not self.control: # if no control exists and message comes from highest prio, the new # control shouldn't have a resource @@ -395,23 +388,10 @@
if len(gajim.events.get_events(self.conn.name, fjid)): self.control.read_queue() - - if path and not gajim.interface.roster.dragging and \ - gajim.config.get('scroll_roster_to_last_message'): - # we curently see contact in our roster - # show and select his line in roster - # do not change selection while DND'ing - tree = gajim.interface.roster.tree - tree.expand_row(path[0:1], False) - tree.expand_row(path[0:2], False) - tree.scroll_to_cell(path) - tree.set_cursor(path) else: if no_queue: # We didn't have a queue: we change icons gajim.interface.roster.draw_contact(jid, self.conn.name)
gajim.interface.roster.show_title() # we show the * or [n] - # Show contact in roster (if he is invisible for example) and select - # line - gajim.interface.roster.show_and_select_contact_if_having_events(jid, - self.conn.name) + # Select contact row in roster. + gajim.interface.roster.select_contact(jid, self.conn.name)