Count unread msgs correctly in systray tooltip, closes #1461
This commit is contained in:
parent
3b0079685f
commit
aeddca16b2
2 changed files with 16 additions and 12 deletions
|
@ -720,10 +720,11 @@ class MessageWindowMgr:
|
||||||
return win.get_control(jid, acct)
|
return win.get_control(jid, acct)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_controls(self, type):
|
def get_controls(self, type, acct = None):
|
||||||
# FIXME: Optionally accept an account arg
|
|
||||||
ctrls = []
|
ctrls = []
|
||||||
for c in self.controls():
|
for c in self.controls():
|
||||||
|
if acct and c.account != acct:
|
||||||
|
continue
|
||||||
if c.type_id == type:
|
if c.type_id == type:
|
||||||
ctrls.append(c)
|
ctrls.append(c)
|
||||||
return ctrls
|
return ctrls
|
||||||
|
|
|
@ -243,19 +243,22 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
||||||
accounts = self.get_accounts_info()
|
accounts = self.get_accounts_info()
|
||||||
|
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
# we count unread chat/pm messages
|
# Count unread chat messages
|
||||||
for ctl in gajim.interface.msg_win_mgr.controls():
|
chat_t = message_control.TYPE_CHAT
|
||||||
c = gajim.contacts.get_first_contact_from_jid(acct, ctl.contact.jid)
|
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
|
||||||
if c:
|
unread_chat += ctrl.nb_unread
|
||||||
unread_chat += ctl.nb_unread
|
|
||||||
else:
|
# Count unread PM messages for which we have a control
|
||||||
unread_pm += ctl.nb_unread
|
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
|
# we count unread gc/pm messages
|
||||||
chat_t = message_control.TYPE_GC
|
chat_t = message_control.TYPE_GC
|
||||||
for gc_control in gajim.interface.msg_win_mgr.get_controls(chat_t):
|
for ctrl in gajim.interface.msg_win_mgr.get_controls(chat_t, acct):
|
||||||
pm_msgs = gc_control.get_specific_unread()
|
# These are PMs for which the PrivateChatControl has not yet been created
|
||||||
unread_gc += gc_control.nb_unread
|
pm_msgs = ctrl.get_specific_unread()
|
||||||
|
unread_gc += ctrl.nb_unread
|
||||||
unread_gc -= pm_msgs
|
unread_gc -= pm_msgs
|
||||||
unread_pm += pm_msgs
|
unread_pm += pm_msgs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue