when a child has awaiting events, draw parent with message icon and open chat with this child contact when we dubble click on parent

This commit is contained in:
Yann Leboulanger 2006-02-20 17:09:14 +00:00
parent 76a3bbaf25
commit f4e95cdc8d
2 changed files with 52 additions and 20 deletions

View File

@ -1390,6 +1390,13 @@ class ChatControl(ChatControlBase):
typ = 'pm' typ = 'pm'
gajim.interface.roster.draw_contact(jid, self.account) gajim.interface.roster.draw_contact(jid, self.account)
# Redraw parent too
contact = gajim.contacts.get_contact_with_highest_priority(self.account,
jid)
if gajim.contacts.is_subcontact(self.account, contact):
parent_contact = gajim.contacts.get_parent_contact(
self.account, contact)
gajim.interface.roster.draw_contact(parent_contact.jid, self.account)
if gajim.interface.systray_enabled: if gajim.interface.systray_enabled:
gajim.interface.systray.remove_jid(jid, self.account, typ) gajim.interface.systray.remove_jid(jid, self.account, typ)
if (self.contact.show == 'offline' or self.contact.show == 'error'): if (self.contact.show == 'offline' or self.contact.show == 'error'):

View File

@ -342,7 +342,7 @@ class RosterWindow:
name += ' (' + unicode(len(contact_instances)) + ')' name += ' (' + unicode(len(contact_instances)) + ')'
# FIXME: remove when we use metacontacts # FIXME: remove when we use metacontacts
# shoz (account_name) if there are 2 contact with same jid in merged mode # show (account_name) if there are 2 contact with same jid in merged mode
if self.regroup: if self.regroup:
add_acct = False add_acct = False
# look through all contacts of all accounts # look through all contacts of all accounts
@ -370,27 +370,37 @@ class RosterWindow:
name += '\n<span size="small" style="italic" foreground="%s">%s</span>'\ name += '\n<span size="small" style="italic" foreground="%s">%s</span>'\
% (colorstring, gtkgui_helpers.escape_for_pango_markup(status)) % (colorstring, gtkgui_helpers.escape_for_pango_markup(status))
for iter in iters: iter = iters[0] # choose the icon with the first iter
icon_name = helpers.get_icon_name_to_show(contact, account) icon_name = helpers.get_icon_name_to_show(contact, account)
path = model.get_path(iter) path = model.get_path(iter)
if model.iter_has_child(iter): if model.iter_has_child(iter):
if icon_name in ('error', 'offline') and not \ if not self.tree.row_expanded(path) and icon_name != 'message':
self.tree.row_expanded(path): child_iter = model.iter_children(iter)
# get children icon if icon_name in ('error', 'offline'):
#FIXME: improve that # get the icon from the first child as they are sorted by show
cc = gajim.contacts.get_children_contacts(account, contact)[0] child_jid = model[child_iter][C_JID].decode('utf-8')
icon_name = helpers.get_icon_name_to_show(cc) child_contact = gajim.contacts.get_contact_with_highest_priority(
if self.tree.row_expanded(path): account, child_jid)
state_images = self.get_appropriate_state_images(jid, icon_name = helpers.get_icon_name_to_show(child_contact, account)
size = 'opened') while child_iter:
else: # a child has awaiting messages ?
state_images = self.get_appropriate_state_images(jid, child_jid = model[child_iter][C_JID].decode('utf-8')
size = 'closed') 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')
else: else:
state_images = self.get_appropriate_state_images(jid, size = '16') state_images = self.get_appropriate_state_images(jid,
size = 'closed')
img = state_images[icon_name] else:
state_images = self.get_appropriate_state_images(jid, size = '16')
img = state_images[icon_name]
for iter in iters:
model[iter][C_IMG] = img model[iter][C_IMG] = img
model[iter][C_NAME] = name model[iter][C_NAME] = name
@ -1910,6 +1920,11 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
else: else:
if no_queue: # We didn't have a queue: we change icons if no_queue: # We didn't have a queue: we change icons
self.draw_contact(jid, account) self.draw_contact(jid, account)
# Redraw parent too
if gajim.contacts.is_subcontact(account, contact):
parent_contact = gajim.contacts.get_parent_contact(account,
contact)
self.draw_contact(parent_contact.jid, account)
if gajim.interface.systray_enabled: if gajim.interface.systray_enabled:
gajim.interface.systray.add_jid(jid, account, kind) gajim.interface.systray.add_jid(jid, account, kind)
self.show_title() # we show the * or [n] self.show_title() # we show the * or [n]
@ -2150,6 +2165,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
account = model[path][C_ACCOUNT].decode('utf-8') account = model[path][C_ACCOUNT].decode('utf-8')
type = model[path][C_TYPE] type = model[path][C_TYPE]
jid = model[path][C_JID].decode('utf-8') jid = model[path][C_JID].decode('utf-8')
iter = model.get_iter(path)
if type in ('group', 'account'): if type in ('group', 'account'):
if self.tree.row_expanded(path): if self.tree.row_expanded(path):
self.tree.collapse_row(path) self.tree.collapse_row(path)
@ -2157,6 +2173,15 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
self.tree.expand_row(path, False) self.tree.expand_row(path, False)
else: else:
first_ev = gajim.get_first_event(account, jid) first_ev = gajim.get_first_event(account, jid)
if not first_ev and model.iter_has_child(iter):
child_iter = model.iter_children(iter)
while not first_ev and child_iter:
child_jid = model[child_iter][C_JID].decode('utf-8')
first_ev = gajim.get_first_event(account, child_jid)
if first_ev:
jid = child_jid
else:
child_iter = model.iter_next(child_iter)
if first_ev: if first_ev:
if self.open_event(account, jid, first_ev): if self.open_event(account, jid, first_ev):
return return