when we quit gajim, check if we have unread or recently received messages and warn the user

This commit is contained in:
Yann Leboulanger 2005-04-18 21:35:39 +00:00
parent a2e8692f80
commit af5dbbe880
1 changed files with 30 additions and 0 deletions

View File

@ -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: