Improve select_contact method.
* use correct API in session.py * only filter when really needed
This commit is contained in:
parent
5f7f717e29
commit
ea00e4d933
|
@ -2419,8 +2419,8 @@ class Interface:
|
|||
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_)
|
||||
|
|
|
@ -949,6 +949,12 @@ class RosterWindow:
|
|||
|
||||
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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
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 @@ class RosterWindow:
|
|||
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
|
||||
|
|
|
@ -330,13 +330,6 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
|||
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 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
|
|||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue