diff --git a/src/roster_window.py b/src/roster_window.py index 323ebc70a..4b2655338 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -22,6 +22,7 @@ import gtk.glade import pango import gobject import os +import time import Queue import common.sleepy @@ -987,6 +988,35 @@ 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, do you still 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. Do you still want to quit Gajim ?')) + if dialog.get_response() != gtk.RESPONSE_YES: + return get_msg = False for acct in accounts: if gajim.connections[acct].connected: