bug 461 - comfirm for close MUC dialog

This commit is contained in:
Dimitur Kirov 2005-07-29 17:18:51 +00:00
parent 38d5253b2e
commit c43b72434e
3 changed files with 38 additions and 3 deletions

View File

@ -119,6 +119,7 @@ class Config:
'use_dbus': [opt_bool, True], # allow control via dbus service 'use_dbus': [opt_bool, True], # allow control via dbus service
'send_receive_chat_state_notifications': [opt_bool, True], 'send_receive_chat_state_notifications': [opt_bool, True],
'print_ichat_every_foo_minutes': [opt_int, 5], # default is every 5 minutes '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 = { __options_per_key = {

View File

@ -479,7 +479,26 @@ class ConfirmationDialog(HigDialog):
HigDialog.__init__(self, None, pritext, sectext, HigDialog.__init__(self, None, pritext, sectext,
gtk.STOCK_DIALOG_WARNING, [ [gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL], gtk.STOCK_DIALOG_WARNING, [ [gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL],
[ gtk.STOCK_OK, gtk.RESPONSE_OK ] ]) [ 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): class WarningDialog(HigDialog):
def __init__(self, pritext, sectext=''): def __init__(self, pritext, sectext=''):
"""HIG compliant warning dialog.""" """HIG compliant warning dialog."""

View File

@ -84,7 +84,8 @@ class GroupchatWindow(chat.Chat):
gajim.config.get('gc-y-position')) gajim.config.get('gc-y-position'))
self.window.resize(gajim.config.get('gc-width'), self.window.resize(gajim.config.get('gc-width'),
gajim.config.get('gc-height')) gajim.config.get('gc-height'))
self.confirm_close = gajim.config.get('confirm_close_muc')
self.confirm_close = True
self.window.show_all() self.window.show_all()
def save_var(self, room_jid): def save_var(self, room_jid):
@ -110,6 +111,7 @@ class GroupchatWindow(chat.Chat):
def on_groupchat_window_delete_event(self, widget, event): def on_groupchat_window_delete_event(self, widget, event):
"""close window""" """close window"""
stop_propagation = False
for room_jid in self.xmls: for room_jid in self.xmls:
if time.time() - gajim.last_message_time[self.account][room_jid] < 2: if time.time() - gajim.last_message_time[self.account][room_jid] < 2:
dialog = dialogs.ConfirmationDialog( dialog = dialogs.ConfirmationDialog(
@ -117,7 +119,20 @@ class GroupchatWindow(chat.Chat):
_('If you close this window, this message will be lost.') _('If you close this window, this message will be lost.')
) )
if dialog.get_response() != gtk.RESPONSE_OK: 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: for room_jid in self.xmls:
gajim.connections[self.account].send_gc_status(self.nicks[room_jid], gajim.connections[self.account].send_gc_status(self.nicks[room_jid],
room_jid, 'offline', 'offline') room_jid, 'offline', 'offline')