From 156c81846bfb9a98349c5add4fcc4381668471df Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Fri, 13 May 2005 20:50:49 +0000 Subject: [PATCH] look if we have unread / recent messages AFTER we get the status message (we can also do it before AND after ... comments ?) --- src/roster_window.py | 59 ++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/roster_window.py b/src/roster_window.py index 879304238..c9f2d8e58 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1032,35 +1032,6 @@ class Roster_window: def on_quit_menuitem_activate(self, widget): accounts = gajim.connections.keys() - # check if we have unread or recent mesages - unread = False - recent = False - if self.nb_unread > 0: - unread = True - for account in accounts: - if self.plugin.windows[account]['chats'].has_key('tabbed'): - wins = [self.plugin.windows[account]['chats']['tabbed']] - else: - wins = self.plugin.windows[account]['chats'].values() - for win in wins: - unrd = 0 - for jid in win.nb_unread: - unrd += win.nb_unread[jid] - if unrd: - unread = True - break - for jid in win.users: - if time.time() - win.last_message_time[jid] < 2: - recent = True - break - if unread: - dialog = dialogs.Confirmation_dialog(_('You have unread messages.\nAre you sure you want to quit Gajim?')) - if dialog.get_response() != gtk.RESPONSE_YES: - return - if recent: - dialog = dialogs.Confirmation_dialog(_('You received a message in the last two seconds.\nAre you sure you want to quit Gajim?')) - if dialog.get_response() != gtk.RESPONSE_YES: - return get_msg = False for acct in accounts: if gajim.connections[acct].connected: @@ -1070,6 +1041,36 @@ class Roster_window: message = self.get_status_message('offline') if message == -1: return + # check if we have unread or recent mesages + unread = False + recent = False + if self.nb_unread > 0: + unread = True + for account in accounts: + if self.plugin.windows[account]['chats'].has_key('tabbed'): + wins = [self.plugin.windows[account]['chats']['tabbed']] + else: + wins = self.plugin.windows[account]['chats'].values() + for win in wins: + unrd = 0 + for jid in win.nb_unread: + unrd += win.nb_unread[jid] + if unrd: + unread = True + break + for jid in win.users: + if time.time() - win.last_message_time[jid] < 2: + recent = True + break + if unread: + dialog = dialogs.Confirmation_dialog(_('You have unread messages.\nAre you sure you want to quit Gajim?')) + if dialog.get_response() != gtk.RESPONSE_YES: + return + #FIXME: do we keep that ? + if recent: + dialog = dialogs.Confirmation_dialog(_('You received a message in the last two seconds.\nAre you sure you want to quit Gajim?')) + if dialog.get_response() != gtk.RESPONSE_YES: + return for acct in accounts: if gajim.connections[acct].connected: self.send_status(acct, 'offline', message)