From c43b72434e0ac771524e49875f1245964a9fe924 Mon Sep 17 00:00:00 2001 From: Dimitur Kirov Date: Fri, 29 Jul 2005 17:18:51 +0000 Subject: [PATCH] bug 461 - comfirm for close MUC dialog --- src/common/config.py | 1 + src/dialogs.py | 21 ++++++++++++++++++++- src/groupchat_window.py | 19 +++++++++++++++++-- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/common/config.py b/src/common/config.py index b28002731..07ac6d5cf 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -119,6 +119,7 @@ class Config: 'use_dbus': [opt_bool, True], # allow control via dbus service 'send_receive_chat_state_notifications': [opt_bool, True], 'print_ichat_every_foo_minutes': [opt_int, 5], # default is every 5 minutes + 'confirm_close_muc': [opt_bool, True], # confirm closing MUC window } __options_per_key = { diff --git a/src/dialogs.py b/src/dialogs.py index 261fef207..20f4248d2 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -479,7 +479,26 @@ class ConfirmationDialog(HigDialog): HigDialog.__init__(self, None, pritext, sectext, gtk.STOCK_DIALOG_WARNING, [ [gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL], [ gtk.STOCK_OK, gtk.RESPONSE_OK ] ]) - + +class ConfirmationDialogCheck(ConfirmationDialog): + '''HIG compliant confirmation dialog with checkbutton.''' + def __init__(self, pritext, sectext='', checktext = ''): + HigDialog.__init__(self, None, pritext, sectext, + gtk.STOCK_DIALOG_WARNING, [ [gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL], + [ gtk.STOCK_OK, gtk.RESPONSE_OK ] ]) + self.checkbutton = gtk.CheckButton(checktext) + self.vbox.pack_start(self.checkbutton, expand=False, fill=True) + + # override this method not to destroy the dialog + def get_response(self): + self.show_all() + response = gtk.Dialog.run(self) + return response + + def is_checked(self): + ''' Get active state of the checkbutton ''' + return self.checkbutton.get_active() + class WarningDialog(HigDialog): def __init__(self, pritext, sectext=''): """HIG compliant warning dialog.""" diff --git a/src/groupchat_window.py b/src/groupchat_window.py index 2e84c5ee7..dc0a96eee 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -84,7 +84,8 @@ class GroupchatWindow(chat.Chat): gajim.config.get('gc-y-position')) self.window.resize(gajim.config.get('gc-width'), gajim.config.get('gc-height')) - + self.confirm_close = gajim.config.get('confirm_close_muc') + self.confirm_close = True self.window.show_all() def save_var(self, room_jid): @@ -110,6 +111,7 @@ class GroupchatWindow(chat.Chat): def on_groupchat_window_delete_event(self, widget, event): """close window""" + stop_propagation = False for room_jid in self.xmls: if time.time() - gajim.last_message_time[self.account][room_jid] < 2: dialog = dialogs.ConfirmationDialog( @@ -117,7 +119,20 @@ class GroupchatWindow(chat.Chat): _('If you close this window, this message will be lost.') ) if dialog.get_response() != gtk.RESPONSE_OK: - return True #stop the propagation of the event + stop_propagation = True #stop the propagation of the event + if not stop_propagation and self.confirm_close: + dialog = dialogs.ConfirmationDialogCheck( + _('Do you want to leave room "%s"') %room_jid.split('@')[0], + _('If you close this window, you will be disconnected from the room.'), + _('Do not ask me again') + ) + if dialog.get_response() != gtk.RESPONSE_OK: + stop_propagation = True + if dialog.is_checked(): + gajim.config.set('confirm_close_muc', False) + dialog.destroy() + if stop_propagation: + return True for room_jid in self.xmls: gajim.connections[self.account].send_gc_status(self.nicks[room_jid], room_jid, 'offline', 'offline')