From 4a5e2385b5e17d1009b710a99cb2605338d2d2a4 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 15 Aug 2013 15:11:51 +0200 Subject: [PATCH] make error diaogs in accounts window transient for ccounts window. See #7185 --- src/config.py | 43 ++++++++++++++++++++++++++----------------- src/dialogs.py | 6 ++++-- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/config.py b/src/config.py index d96a40807..61f91c455 100644 --- a/src/config.py +++ b/src/config.py @@ -2011,7 +2011,8 @@ class AccountsWindow: account = self.current_account if len(gajim.events.get_events(account)): 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 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: dialogs.ErrorDialog( _('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 if len(gajim.events.get_events(self.current_account)): dialogs.ErrorDialog(_('Unread events'), _('To change the account name, you must read all pending ' - 'events.')) + 'events.'), transient_for=self.window) return # Get the new name def on_renamed(new_name, old_name): if new_name in gajim.connections: dialogs.ErrorDialog(_('Account Name Already Used'), _('This name is already used by another of your accounts. ' - 'Please choose another name.')) + 'Please choose another name.'), transient_for=self.window) return if (new_name == ''): dialogs.ErrorDialog(_('Invalid account name'), - _('Account name cannot be empty.')) + _('Account name cannot be empty.'), + transient_for=self.window) return if new_name.find(' ') != -1: dialogs.ErrorDialog(_('Invalid account name'), - _('Account name cannot contain spaces.')) + _('Account name cannot contain spaces.'), + transient_for=self.window) return if active: # update variables @@ -2174,7 +2178,7 @@ class AccountsWindow: except helpers.InvalidFormat as s: if not widget.is_focus(): 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()) return True @@ -2185,7 +2189,7 @@ class AccountsWindow: pritext = _('Invalid Jabber ID') sectext = \ _('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()) return True @@ -2251,7 +2255,7 @@ class AccountsWindow: except helpers.InvalidFormat as s: if not widget.is_focus(): 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()) return True @@ -2409,7 +2413,8 @@ class AccountsWindow: except Exception: if not widget.is_focus(): 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()) return True if self.option_changed('custom_port', custom_port): @@ -2431,7 +2436,8 @@ class AccountsWindow: secret_keys = [] if not 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') def on_key_selected(keyID): @@ -2446,7 +2452,7 @@ class AccountsWindow: gpg_name_label = self.xml.get_object('gpg_name_label' + \ wiget_name_ext) use_gpg_agent_checkbutton = self.xml.get_object( - 'use_gpg_agent_checkbutton' + wiget_name_ext) + 'use_gpg_agent_checkbutton' + wiget_name_ext) if keyID[0] == _('None'): gpg_key_label.set_text(_('No key selected')) gpg_name_label.set_text('') @@ -2479,7 +2485,7 @@ class AccountsWindow: if self.current_account not in gajim.interface.instances: dlg = dialogs.ErrorDialog(_('No such account available'), _('You must create your account before editing your personal ' - 'information.')) + 'information.'), transient_for=self.window) return # 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: dialogs.ErrorDialog(_('You are not connected to the server'), _('Without a connection, you can not edit your personal ' - 'information.')) + 'information.'), transient_for=self.window) return if not gajim.connections[self.current_account].vcard_supported: 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 jid = gajim.get_jid_from_account(self.current_account) @@ -2608,7 +2615,8 @@ class AccountsWindow: self.ignore_events = False dialogs.ErrorDialog( _('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 if gajim.ZEROCONF_ACC_NAME in gajim.connections and not \ gajim.connections[gajim.ZEROCONF_ACC_NAME].is_zeroconf: @@ -2645,7 +2653,8 @@ class AccountsWindow: self.ignore_events = False dialogs.ErrorDialog( _('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 # add/remove account in roster and all variables if widget.get_active(): diff --git a/src/dialogs.py b/src/dialogs.py index 8ba50548c..f6609714d 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -1628,8 +1628,10 @@ class ErrorDialog(HigDialog): """ def __init__(self, pritext, sectext='', on_response_ok=None, - on_response_cancel=None): - if hasattr(gajim.interface, 'roster') and gajim.interface.roster: + on_response_cancel=None, transient_for=None): + if transient_for: + parent = transient_for + elif hasattr(gajim.interface, 'roster') and gajim.interface.roster: parent = gajim.interface.roster.window else: parent = None