ChatControl: Use NewConfirmationDialog

This commit is contained in:
Philipp Hörist 2019-03-27 23:33:50 +01:00
parent f838c2faa2
commit ae29c937ba
1 changed files with 16 additions and 18 deletions

View File

@ -54,7 +54,8 @@ from gajim import gui_menu_builder
from gajim import message_control from gajim import message_control
from gajim import dialogs from gajim import dialogs
from gajim.gtk.dialogs import ConfirmationDialog from gajim.gtk.dialogs import NewConfirmationDialog
from gajim.gtk.dialogs import DialogButton
from gajim.gtk.add_contact import AddNewContactWindow from gajim.gtk.add_contact import AddNewContactWindow
from gajim.gtk.util import get_icon_name from gajim.gtk.util import get_icon_name
from gajim.gtk.util import get_cursor from gajim.gtk.util import get_cursor
@ -1168,25 +1169,22 @@ class ChatControl(ChatControlBase):
def safe_shutdown(self): def safe_shutdown(self):
return False return False
def allow_shutdown(self, method, on_yes, on_no, on_minimize): def allow_shutdown(self, method, on_yes, on_no, _on_minimize):
if time.time() - app.last_message_time[self.account]\ time_ = app.last_message_time[self.account][self.get_full_jid()]
[self.get_full_jid()] < 2: if time.time() - time_ < 2:
# 2 seconds # 2 seconds
def on_ok(): NewConfirmationDialog(
on_yes(self) _('Close'),
_('You just received a new message from %s') % self.contact.jid,
def on_cancel(): _('If you close this tab and you have history disabled, '
on_no(self) 'this message will be lost.'),
[DialogButton.make('Cancel',
ConfirmationDialog( callback=lambda: on_no(self)),
#%s is being replaced in the code with JID DialogButton.make('OK',
_('You just received a new message from "%s"') % \ text=_('Close'),
self.contact.jid, callback=lambda: on_yes(self))],
_('If you close this tab and you have history disabled, '\ transient_for=self.parent_win.window).show()
'this message will be lost.'), on_response_ok=on_ok,
on_response_cancel=on_cancel,
transient_for=self.parent_win.window)
return return
on_yes(self) on_yes(self)