* YesNo dialog now destroy itself when we click on a button
* yes YesNo dialog when a contact removes us to as if user wants to remove it too * fix some coding standards
This commit is contained in:
parent
335079dd9b
commit
d27f9a9c85
|
@ -256,7 +256,7 @@ class PassphraseDialog:
|
|||
self.window.destroy()
|
||||
return passphrase, checked
|
||||
|
||||
def __init__(self, titletext, labeltext, checkbuttontext=None, is_modal = True,
|
||||
def __init__(self, titletext, labeltext, checkbuttontext=None, is_modal=True,
|
||||
ok_handler = None, cancel_handler = None):
|
||||
self.xml = gtkgui_helpers.get_glade('passphrase_dialog.glade')
|
||||
self.window = self.xml.get_widget('passphrase_dialog')
|
||||
|
@ -1223,12 +1223,32 @@ class YesNoDialog(HigDialog):
|
|||
def __init__(self, pritext, sectext='', on_response_yes = None,
|
||||
on_response_no = None):
|
||||
'''HIG compliant YesNo dialog.'''
|
||||
self.user_response_yes = on_response_yes
|
||||
self.user_response_no = on_response_no
|
||||
HigDialog.__init__( self, None,
|
||||
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, pritext, sectext,
|
||||
on_response_yes = on_response_yes, on_response_no = on_response_no)
|
||||
on_response_yes=self.on_response_yes,
|
||||
on_response_no=self.on_response_no)
|
||||
self.set_modal(False)
|
||||
self.popup()
|
||||
|
||||
def on_response_yes(self, widget):
|
||||
if self.user_response_yes:
|
||||
if isinstance(self.user_response_yes, tuple):
|
||||
self.user_response_yes[0](*self.user_response_yes[1:])
|
||||
else:
|
||||
self.user_response_yes(self.is_checked())
|
||||
self.destroy()
|
||||
|
||||
def on_response_no(self, widget):
|
||||
if self.user_response_no:
|
||||
if isinstance(self.user_response_no, tuple):
|
||||
self.user_response_no[0](*self.user_response_no[1:])
|
||||
else:
|
||||
self.user_response_no()
|
||||
self.destroy()
|
||||
|
||||
|
||||
class ConfirmationDialogCheck(ConfirmationDialog):
|
||||
'''HIG compliant confirmation dialog with checkbutton.'''
|
||||
def __init__(self, pritext, sectext='', checktext = '',
|
||||
|
@ -1264,7 +1284,7 @@ class ConfirmationDialogCheck(ConfirmationDialog):
|
|||
def on_response_cancel(self, widget):
|
||||
if self.user_response_cancel:
|
||||
if isinstance(self.user_response_cancel, tuple):
|
||||
self.user_response_cancel[0](*self.user_response_ok[1:])
|
||||
self.user_response_cancel[0](*self.user_response_cancel[1:])
|
||||
else:
|
||||
self.user_response_cancel()
|
||||
self.destroy()
|
||||
|
|
27
src/gajim.py
27
src/gajim.py
|
@ -455,7 +455,7 @@ class Interface:
|
|||
|
||||
def handle_event_http_auth(self, account, data):
|
||||
#('HTTP_AUTH', account, (method, url, transaction_id, iq_obj, msg))
|
||||
def response(widget, account, iq_obj, answer):
|
||||
def response(account, iq_obj, answer):
|
||||
self.dialog.destroy()
|
||||
gajim.connections[account].build_http_auth_answer(iq_obj, answer)
|
||||
|
||||
|
@ -948,13 +948,22 @@ class Interface:
|
|||
self.remote_ctrl.raise_signal('Subscribed', (account, array))
|
||||
|
||||
def handle_event_unsubscribed(self, account, jid):
|
||||
dialogs.InformationDialog(_('Contact "%s" removed subscription from you')\
|
||||
% jid, _('You will always see him or her as offline.'))
|
||||
# FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does not show deny
|
||||
gajim.connections[account].ack_unsubscribed(jid)
|
||||
if self.remote_ctrl:
|
||||
self.remote_ctrl.raise_signal('Unsubscribed', (account, jid))
|
||||
|
||||
contact = gajim.contacts.get_first_contact_from_jid(account, jid)
|
||||
if not contact:
|
||||
return
|
||||
def on_yes(list_):
|
||||
self.roster.on_req_usub(None, list_)
|
||||
list_ = [(contact, account)]
|
||||
dialogs.YesNoDialog(
|
||||
_('Contact "%s" removed subscription from you') % jid,
|
||||
_('You will always see him or her as offline.\nDo you want to remove him or her from your contact list?'),
|
||||
on_response_yes = (on_yes, list_))
|
||||
# FIXME: Per RFC 3921, we can "deny" ack as well, but the GUI does not show deny
|
||||
|
||||
def handle_event_agent_info_error(self, account, agent):
|
||||
#('AGENT_ERROR_INFO', account, (agent))
|
||||
try:
|
||||
|
@ -1932,12 +1941,12 @@ class Interface:
|
|||
negotiated, not_acceptable, ask_user = session.verify_options_bob(form)
|
||||
|
||||
if ask_user:
|
||||
def accept_nondefault_options(widget):
|
||||
def accept_nondefault_options():
|
||||
self.dialog.destroy()
|
||||
negotiated.update(ask_user)
|
||||
session.respond_e2e_bob(form, negotiated, not_acceptable)
|
||||
|
||||
def reject_nondefault_options(widget):
|
||||
def reject_nondefault_options():
|
||||
self.dialog.destroy()
|
||||
for key in ask_user.keys():
|
||||
not_acceptable.append(key)
|
||||
|
@ -1973,7 +1982,7 @@ class Interface:
|
|||
session.check_identity = _cb
|
||||
|
||||
if ask_user:
|
||||
def accept_nondefault_options(widget):
|
||||
def accept_nondefault_options():
|
||||
dialog.destroy()
|
||||
|
||||
negotiated.update(ask_user)
|
||||
|
@ -1983,7 +1992,7 @@ class Interface:
|
|||
except exceptions.NegotiationError, details:
|
||||
session.fail_bad_negotiation(details)
|
||||
|
||||
def reject_nondefault_options(widget):
|
||||
def reject_nondefault_options():
|
||||
session.reject_negotiation()
|
||||
dialog.destroy()
|
||||
|
||||
|
@ -2237,7 +2246,7 @@ class Interface:
|
|||
gajim.config.set_per('accounts', account, 'ssl_fingerprint_sha1',
|
||||
data[0])
|
||||
gajim.connections[account].ssl_certificate_accepted()
|
||||
def on_no(widget):
|
||||
def on_no():
|
||||
dialog.destroy()
|
||||
gajim.connections[account].disconnect(on_purpose=True)
|
||||
self.handle_event_status(account, 'offline')
|
||||
|
|
Loading…
Reference in New Issue