Count unread msgs correctly in systray tooltip, closes #1461

This commit is contained in:
Travis Shirk 2006-01-31 04:03:34 +00:00
parent 3b0079685f
commit aeddca16b2
2 changed files with 16 additions and 12 deletions

View File

@ -720,10 +720,11 @@ class MessageWindowMgr:
return win.get_control(jid, acct)
return None
def get_controls(self, type):
# FIXME: Optionally accept an account arg
def get_controls(self, type, acct = None):
ctrls = []
for c in self.controls():
if acct and c.account != acct:
continue
if c.type_id == type:
ctrls.append(c)
return ctrls

View File

@ -243,19 +243,22 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
accounts = self.get_accounts_info()
for acct in gajim.connections:
# we count unread chat/pm messages
for ctl in gajim.interface.msg_win_mgr.controls():
c = gajim.contacts.get_first_contact_from_jid(acct, ctl.contact.jid)
if c:
unread_chat += ctl.nb_unread
else:
unread_pm += ctl.nb_unread
# Count unread chat messages
chat_t = message_control.TYPE_CHAT
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
unread_chat += ctrl.nb_unread
# Count unread PM messages for which we have a control
chat_t = message_control.TYPE_PM
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
unread_pm += ctrl.nb_unread
# we count unread gc/pm messages
chat_t = message_control.TYPE_GC
for gc_control in gajim.interface.msg_win_mgr.get_controls(chat_t):
pm_msgs = gc_control.get_specific_unread()
unread_gc += gc_control.nb_unread
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
# These are PMs for which the PrivateChatControl has not yet been created
pm_msgs = ctrl.get_specific_unread()
unread_gc += ctrl.nb_unread
unread_gc -= pm_msgs
unread_pm += pm_msgs