make error diaogs in accounts window transient for ccounts window. See #7185

This commit is contained in:
Yann Leboulanger 2013-08-15 15:11:51 +02:00
parent a8d831b6de
commit 4a5e2385b5
2 changed files with 30 additions and 19 deletions

View File

@ -2011,7 +2011,8 @@ class AccountsWindow:
account = self.current_account account = self.current_account
if len(gajim.events.get_events(account)): if len(gajim.events.get_events(account)):
dialogs.ErrorDialog(_('Unread events'), dialogs.ErrorDialog(_('Unread events'),
_('Read all pending events before removing this account.')) _('Read all pending events before removing this account.'),
transient_for=self.window)
return return
if gajim.config.get_per('accounts', account, 'is_zeroconf'): if gajim.config.get_per('accounts', account, 'is_zeroconf'):
@ -2054,27 +2055,30 @@ class AccountsWindow:
if active and gajim.connections[self.current_account].connected != 0: if active and gajim.connections[self.current_account].connected != 0:
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('You are currently connected to the server'), _('You are currently connected to the server'),
_('To change the account name, you must be disconnected.')) _('To change the account name, you must be disconnected.'),
transient_for=self.window)
return return
if len(gajim.events.get_events(self.current_account)): if len(gajim.events.get_events(self.current_account)):
dialogs.ErrorDialog(_('Unread events'), dialogs.ErrorDialog(_('Unread events'),
_('To change the account name, you must read all pending ' _('To change the account name, you must read all pending '
'events.')) 'events.'), transient_for=self.window)
return return
# Get the new name # Get the new name
def on_renamed(new_name, old_name): def on_renamed(new_name, old_name):
if new_name in gajim.connections: if new_name in gajim.connections:
dialogs.ErrorDialog(_('Account Name Already Used'), dialogs.ErrorDialog(_('Account Name Already Used'),
_('This name is already used by another of your accounts. ' _('This name is already used by another of your accounts. '
'Please choose another name.')) 'Please choose another name.'), transient_for=self.window)
return return
if (new_name == ''): if (new_name == ''):
dialogs.ErrorDialog(_('Invalid account name'), dialogs.ErrorDialog(_('Invalid account name'),
_('Account name cannot be empty.')) _('Account name cannot be empty.'),
transient_for=self.window)
return return
if new_name.find(' ') != -1: if new_name.find(' ') != -1:
dialogs.ErrorDialog(_('Invalid account name'), dialogs.ErrorDialog(_('Invalid account name'),
_('Account name cannot contain spaces.')) _('Account name cannot contain spaces.'),
transient_for=self.window)
return return
if active: if active:
# update variables # update variables
@ -2174,7 +2178,7 @@ class AccountsWindow:
except helpers.InvalidFormat as s: except helpers.InvalidFormat as s:
if not widget.is_focus(): if not widget.is_focus():
pritext = _('Invalid Jabber ID') pritext = _('Invalid Jabber ID')
dialogs.ErrorDialog(pritext, str(s)) dialogs.ErrorDialog(pritext, str(s), transient_for=self.window)
GLib.idle_add(lambda: widget.grab_focus()) GLib.idle_add(lambda: widget.grab_focus())
return True return True
@ -2185,7 +2189,7 @@ class AccountsWindow:
pritext = _('Invalid Jabber ID') pritext = _('Invalid Jabber ID')
sectext = \ sectext = \
_('A Jabber ID must be in the form "user@servername".') _('A Jabber ID must be in the form "user@servername".')
dialogs.ErrorDialog(pritext, sectext) dialogs.ErrorDialog(pritext, sectext, transient_for=self.window)
GLib.idle_add(lambda: widget.grab_focus()) GLib.idle_add(lambda: widget.grab_focus())
return True return True
@ -2251,7 +2255,7 @@ class AccountsWindow:
except helpers.InvalidFormat as s: except helpers.InvalidFormat as s:
if not widget.is_focus(): if not widget.is_focus():
pritext = _('Invalid Jabber ID') pritext = _('Invalid Jabber ID')
dialogs.ErrorDialog(pritext, str(s)) dialogs.ErrorDialog(pritext, str(s), transient_for=self.window)
GLib.idle_add(lambda: widget.grab_focus()) GLib.idle_add(lambda: widget.grab_focus())
return True return True
@ -2409,7 +2413,8 @@ class AccountsWindow:
except Exception: except Exception:
if not widget.is_focus(): if not widget.is_focus():
dialogs.ErrorDialog(_('Invalid entry'), dialogs.ErrorDialog(_('Invalid entry'),
_('Custom port must be a port number.')) _('Custom port must be a port number.'),
transient_for=self.window)
GLib.idle_add(lambda: widget.grab_focus()) GLib.idle_add(lambda: widget.grab_focus())
return True return True
if self.option_changed('custom_port', custom_port): if self.option_changed('custom_port', custom_port):
@ -2431,7 +2436,8 @@ class AccountsWindow:
secret_keys = [] secret_keys = []
if not secret_keys: if not secret_keys:
dialogs.ErrorDialog(_('Failed to get secret keys'), dialogs.ErrorDialog(_('Failed to get secret keys'),
_('There is no OpenPGP secret key available.')) _('There is no OpenPGP secret key available.'),
transient_for=self.window)
secret_keys[_('None')] = _('None') secret_keys[_('None')] = _('None')
def on_key_selected(keyID): def on_key_selected(keyID):
@ -2479,7 +2485,7 @@ class AccountsWindow:
if self.current_account not in gajim.interface.instances: if self.current_account not in gajim.interface.instances:
dlg = dialogs.ErrorDialog(_('No such account available'), dlg = dialogs.ErrorDialog(_('No such account available'),
_('You must create your account before editing your personal ' _('You must create your account before editing your personal '
'information.')) 'information.'), transient_for=self.window)
return return
# show error dialog if account is newly created (not in gajim.connections) # show error dialog if account is newly created (not in gajim.connections)
@ -2487,12 +2493,13 @@ class AccountsWindow:
gajim.connections[self.current_account].connected < 2: gajim.connections[self.current_account].connected < 2:
dialogs.ErrorDialog(_('You are not connected to the server'), dialogs.ErrorDialog(_('You are not connected to the server'),
_('Without a connection, you can not edit your personal ' _('Without a connection, you can not edit your personal '
'information.')) 'information.'), transient_for=self.window)
return return
if not gajim.connections[self.current_account].vcard_supported: if not gajim.connections[self.current_account].vcard_supported:
dialogs.ErrorDialog(_("Your server doesn't support vCard"), dialogs.ErrorDialog(_("Your server doesn't support vCard"),
_("Your server can't save your personal information.")) _("Your server can't save your personal information."),
transient_for=self.window)
return return
jid = gajim.get_jid_from_account(self.current_account) jid = gajim.get_jid_from_account(self.current_account)
@ -2608,7 +2615,8 @@ class AccountsWindow:
self.ignore_events = False self.ignore_events = False
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('You are currently connected to the server'), _('You are currently connected to the server'),
_('To disable the account, you must be disconnected.')) _('To disable the account, you must be disconnected.'),
transient_for=self.window)
return return
if gajim.ZEROCONF_ACC_NAME in gajim.connections and not \ if gajim.ZEROCONF_ACC_NAME in gajim.connections and not \
gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf: gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf:
@ -2645,7 +2653,8 @@ class AccountsWindow:
self.ignore_events = False self.ignore_events = False
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('You are currently connected to the server'), _('You are currently connected to the server'),
_('To disable the account, you must be disconnected.')) _('To disable the account, you must be disconnected.'),
transient_for=self.window)
return return
# add/remove account in roster and all variables # add/remove account in roster and all variables
if widget.get_active(): if widget.get_active():

View File

@ -1628,8 +1628,10 @@ class ErrorDialog(HigDialog):
""" """
def __init__(self, pritext, sectext='', on_response_ok=None, def __init__(self, pritext, sectext='', on_response_ok=None,
on_response_cancel=None): on_response_cancel=None, transient_for=None):
if hasattr(gajim.interface, 'roster') and gajim.interface.roster: if transient_for:
parent = transient_for
elif hasattr(gajim.interface, 'roster') and gajim.interface.roster:
parent = gajim.interface.roster.window parent = gajim.interface.roster.window
else: else:
parent = None parent = None