fix ConfirmationDialogCheck callback behaviour

This commit is contained in:
Yann Leboulanger 2007-10-01 17:11:47 +00:00
parent ebfa1eba40
commit 0585a8475f
4 changed files with 19 additions and 19 deletions

View File

@ -1090,12 +1090,19 @@ class ConfirmationDialogCheck(ConfirmationDialog):
def on_response_ok(self, widget): def on_response_ok(self, widget):
if self.user_response_ok: if self.user_response_ok:
self.user_response_ok(self.is_checked()) if isinstance(self.user_response_ok, tuple):
self.user_response_ok[0](self.is_checked(),
*self.user_response_ok[1:])
else:
self.user_response_ok(self.is_checked())
self.destroy() self.destroy()
def on_response_cancel(self, widget): def on_response_cancel(self, widget):
if self.user_response_cancel: if self.user_response_cancel:
self.user_response_cancel() if isinstance(self.user_response_cancel, tuple):
self.user_response_cancel[0](*self.user_response_ok[1:])
else:
self.user_response_cancel()
self.destroy() self.destroy()
def is_checked(self): def is_checked(self):

View File

@ -1598,8 +1598,6 @@ class GroupchatControl(ChatControlBase):
if dialog.is_checked(): # user does not want to be asked again if dialog.is_checked(): # user does not want to be asked again
gajim.config.set('confirm_close_muc', False) gajim.config.set('confirm_close_muc', False)
dialog.destroy()
return retval return retval
def set_control_active(self, state): def set_control_active(self, state):

View File

@ -644,12 +644,10 @@ def possibly_set_gajim_as_xmpp_handler():
else: else:
path_to_kde_file = None path_to_kde_file = None
def set_gajim_as_xmpp_handler(widget = None): def set_gajim_as_xmpp_handler(is_checked=None):
if widget: if is_checked != None:
# come from confirmation dialog # come from confirmation dialog
gajim.config.set('check_if_gajim_is_default', gajim.config.set('check_if_gajim_is_default', is_checked)
dlg.checkbutton.get_active())
dlg.destroy()
path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True) path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True)
if path_to_gajim_script: if path_to_gajim_script:
if typ == 'svn': if typ == 'svn':
@ -712,10 +710,9 @@ Description=xmpp
sectext = _('Would you like to make Gajim the default Jabber client?') sectext = _('Would you like to make Gajim the default Jabber client?')
checktext = _('Always check to see if Gajim is the default Jabber client ' checktext = _('Always check to see if Gajim is the default Jabber client '
'on startup') 'on startup')
def on_cancel(widget): def on_cancel():
gajim.config.set('check_if_gajim_is_default', gajim.config.set('check_if_gajim_is_default',
dlg.checkbutton.get_active()) dlg.is_checked())
dlg.destroy()
dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, checktext, dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, checktext,
set_gajim_as_xmpp_handler, on_cancel) set_gajim_as_xmpp_handler, on_cancel)
if gajim.config.get('check_if_gajim_is_default'): if gajim.config.get('check_if_gajim_is_default'):

View File

@ -3319,12 +3319,11 @@ class RosterWindow:
def on_req_usub(self, widget, list_): def on_req_usub(self, widget, list_):
'''Remove a contact. list_ is a list of (contact, account) tuples''' '''Remove a contact. list_ is a list of (contact, account) tuples'''
def on_ok(widget, list_): def on_ok(is_checked, list_):
self.dialog.destroy()
remove_auth = True remove_auth = True
if len(list_) == 1: if len(list_) == 1:
contact = list_[0][0] contact = list_[0][0]
if contact.sub != 'to' and self.dialog.is_checked(): if contact.sub != 'to' and is_checked:
remove_auth = False remove_auth = False
for (contact, account) in list_: for (contact, account) in list_:
gajim.connections[account].unsubscribe(contact.jid, remove_auth) gajim.connections[account].unsubscribe(contact.jid, remove_auth)
@ -4804,10 +4803,9 @@ class RosterWindow:
'server'), 'server'),
_('Your server does not support storing metacontacts information. ' _('Your server does not support storing metacontacts information. '
'So those information will not be saved on next reconnection.')) 'So those information will not be saved on next reconnection.'))
def merge_contacts(widget = None): def merge_contacts(is_checked=None):
if widget: # dialog has been shown if is_checked != None: # dialog has been shown
dlg.destroy() if is_checked: # user does not want to be asked again
if dlg.is_checked(): # user does not want to be asked again
gajim.config.set('confirm_metacontacts', 'no') gajim.config.set('confirm_metacontacts', 'no')
else: else:
gajim.config.set('confirm_metacontacts', 'yes') gajim.config.set('confirm_metacontacts', 'yes')