Fix a bug with receiving Private Messages when roster is minimized, print the number of unread pm in roster, and change icon when a pm is received.

This commit is contained in:
Julien Pivotto 2007-05-17 12:55:44 +00:00
parent 93dbdd3dd8
commit 993d72a8c1
5 changed files with 29 additions and 9 deletions

View File

@ -827,9 +827,15 @@ class ChatControlBase(MessageControl):
room_jid, nick = gajim.get_room_and_nick_from_fjid(jid) room_jid, nick = gajim.get_room_and_nick_from_fjid(jid)
groupchat_control = gajim.interface.msg_win_mgr.get_control( groupchat_control = gajim.interface.msg_win_mgr.get_control(
room_jid, self.account) room_jid, self.account)
if not groupchat_control and \
gajim.interface.minimized_controls.has_key(self.account) and \
room_jid in gajim.interface.minimized_controls[self.account]:
groupchat_control = \
gajim.interface.minimized_controls[self.account][room_jid]
groupchat_control.draw_contact(nick) groupchat_control.draw_contact(nick)
mw = gajim.interface.msg_win_mgr.get_window(room_jid, self.account) mw = gajim.interface.msg_win_mgr.get_window(room_jid, self.account)
mw.redraw_tab(groupchat_control) if mw:
mw.redraw_tab(groupchat_control)
else: else:
gajim.interface.roster.draw_contact(jid, self.account) gajim.interface.roster.draw_contact(jid, self.account)
gajim.interface.roster.show_title() gajim.interface.roster.show_title()

View File

@ -548,6 +548,10 @@ def get_icon_name_to_show(contact, account = None):
if account and gajim.events.get_nb_roster_events(account, if account and gajim.events.get_nb_roster_events(account,
contact.get_full_jid()): contact.get_full_jid()):
return 'message' return 'message'
if account and gajim.interface.minimized_controls.has_key(account) and \
contact.jid in gajim.interface.minimized_controls[account] and gajim.interface.\
minimized_controls[account][contact.jid].get_nb_unread_pm() > 0:
return 'message'
if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent if contact.jid.find('@') <= 0: # if not '@' or '@' starts the jid ==> agent
return contact.show return contact.show
if contact.sub in ('both', 'to'): if contact.sub in ('both', 'to'):

View File

@ -686,6 +686,10 @@ class Interface:
jid = jid.replace('@', '') jid = jid.replace('@', '')
groupchat_control = self.msg_win_mgr.get_control(jid, account) groupchat_control = self.msg_win_mgr.get_control(jid, account)
if not groupchat_control and \
gajim.interface.minimized_controls.has_key(account) and \
jid in gajim.interface.minimized_controls[account]:
groupchat_control = gajim.interface.minimized_controls[account][jid]
pm = False pm = False
if groupchat_control and groupchat_control.type_id == \ if groupchat_control and groupchat_control.type_id == \
message_control.TYPE_GC: message_control.TYPE_GC:

View File

@ -543,14 +543,16 @@ class GroupchatControl(ChatControlBase):
self.room_jid, icon_name = 'message') self.room_jid, icon_name = 'message')
image = state_images['message'] image = state_images['message']
model[iter][C_IMG] = image model[iter][C_IMG] = image
self.parent_win.show_title() if self.parent_win:
self.parent_win.redraw_tab(self) self.parent_win.show_title()
self.parent_win.redraw_tab(self)
else: else:
self._start_private_message(nick) self._start_private_message(nick)
# Scroll to line # Scroll to line
self.list_treeview.expand_row(path[0:1], False) self.list_treeview.expand_row(path[0:1], False)
self.list_treeview.scroll_to_cell(path) self.list_treeview.scroll_to_cell(path)
self.list_treeview.set_cursor(path) self.list_treeview.set_cursor(path)
gajim.interface.roster.draw_contact(self.room_jid, self.account)
def get_contact_iter(self, nick): def get_contact_iter(self, nick):
model = self.list_treeview.get_model() model = self.list_treeview.get_model()

View File

@ -581,13 +581,17 @@ class RosterWindow:
name = gobject.markup_escape_text(contact.get_shown_name()) name = gobject.markup_escape_text(contact.get_shown_name())
# gets number of unread gc marked messages # gets number of unread gc marked messages
nb_unread = len(gajim.events.get_events(account, jid, if gajim.interface.minimized_controls.has_key(account) and \
['printed_marked_gc_msg'])) jid in gajim.interface.minimized_controls[account]:
nb_unread = len(gajim.events.get_events(account, jid,
['printed_marked_gc_msg']))
nb_unread += \
gajim.interface.minimized_controls[account][jid].get_nb_unread_pm()
if nb_unread == 1: if nb_unread == 1:
name = '%s *' % name name = '%s *' % name
elif nb_unread > 1: elif nb_unread > 1:
name = '%s [%s]' % (name, str(nb_unread)) name = '%s [%s]' % (name, str(nb_unread))
strike = False strike = False
if jid in gajim.connections[account].blocked_contacts: if jid in gajim.connections[account].blocked_contacts: