fix transient for windows. Fixes #7185

This commit is contained in:
Yann Leboulanger 2013-08-15 23:14:42 +02:00
parent 8f2dbdf05a
commit e1eb9af26f
5 changed files with 44 additions and 24 deletions

View File

@ -2834,11 +2834,13 @@ class ChatControl(ChatControlBase):
on_no(self)
dialogs.ConfirmationDialog(
# %s is being replaced in the code with JID
_('You just received a new message from "%s"') % self.contact.jid,
_('If you close this tab and you have history disabled, '\
'this message will be lost.'), on_response_ok=on_ok,
on_response_cancel=on_cancel)
#%s is being replaced in the code with JID
_('You just received a new message from "%s"') % \
self.contact.jid,
_('If you close this tab and you have history disabled, '\
'this message will be lost.'), on_response_ok=on_ok,
on_response_cancel=on_cancel,
transient_for=self.parent_win.window)
return
on_yes(self)

View File

@ -1531,10 +1531,10 @@ class ConfirmationDialog(HigDialog):
"""
def __init__(self, pritext, sectext='', on_response_ok=None,
on_response_cancel=None):
on_response_cancel=None, transient_for=None):
self.user_response_ok = on_response_ok
self.user_response_cancel = on_response_cancel
HigDialog.__init__(self, None,
HigDialog.__init__(self, transient_for,
Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, pritext, sectext,
self.on_response_ok, self.on_response_cancel)
self.popup()
@ -1612,8 +1612,10 @@ class InformationDialog(HigDialog):
HIG compliant info dialog
"""
def __init__(self, pritext, sectext=''):
if hasattr(gajim.interface, 'roster') and gajim.interface.roster:
def __init__(self, pritext, sectext='', 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
@ -1735,11 +1737,13 @@ class ConfirmationDialogCheck(ConfirmationDialog):
"""
def __init__(self, pritext, sectext='', checktext='', on_response_ok=None,
on_response_cancel=None, is_modal=True):
on_response_cancel=None, is_modal=True, transient_for=None):
self.user_response_ok = on_response_ok
self.user_response_cancel = on_response_cancel
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
else:
parent = None
@ -1995,13 +1999,16 @@ class CommonInputDialog:
Common Class for Input dialogs
"""
def __init__(self, title, label_str, is_modal, ok_handler, cancel_handler):
def __init__(self, title, label_str, is_modal, ok_handler, cancel_handler,
transient_for=None):
self.dialog = self.xml.get_object('input_dialog')
label = self.xml.get_object('label')
self.dialog.set_title(title)
label.set_markup(label_str)
self.cancel_handler = cancel_handler
self.vbox = self.xml.get_object('vbox')
if transient_for:
self.dialog.set_transient_for(transient_for)
self.ok_handler = ok_handler
okbutton = self.xml.get_object('okbutton')
@ -2038,10 +2045,10 @@ class InputDialog(CommonInputDialog):
"""
def __init__(self, title, label_str, input_str=None, is_modal=True,
ok_handler=None, cancel_handler=None):
ok_handler=None, cancel_handler=None, transient_for=None):
self.xml = gtkgui_helpers.get_gtk_builder('input_dialog.ui')
CommonInputDialog.__init__(self, title, label_str, is_modal, ok_handler,
cancel_handler)
cancel_handler, transient_for=transient_for)
self.input_entry = self.xml.get_object('input_entry')
if input_str:
self.set_entry(input_str)
@ -2221,7 +2228,8 @@ class DoubleInputDialog:
"""
def __init__(self, title, label_str1, label_str2, input_str1=None,
input_str2=None, is_modal=True, ok_handler=None, cancel_handler=None):
input_str2=None, is_modal=True, ok_handler=None, cancel_handler=None,
transient_for=None):
self.xml = gtkgui_helpers.get_gtk_builder('dubbleinput_dialog.ui')
self.dialog = self.xml.get_object('dubbleinput_dialog')
label1 = self.xml.get_object('label1')
@ -2238,6 +2246,8 @@ class DoubleInputDialog:
if input_str2:
self.input_entry2.set_text(input_str2)
self.input_entry2.select_region(0, -1) # select all
if transient_for:
self.dialog.set_transient_for(transient_for)
self.dialog.set_modal(is_modal)
@ -4574,7 +4584,8 @@ class PrivacyListsWindow:
name = self.new_privacy_list_entry.get_text()
if not name:
ErrorDialog(_('Invalid List Name'),
_('You must enter a name to create a privacy list.'))
_('You must enter a name to create a privacy list.'),
transient_for=self.window)
return
key_name = 'privacy_list_%s' % name
if key_name in gajim.interface.instances[self.account]:

View File

@ -765,13 +765,15 @@ _('Without a connection, you can not browse available services'))
# We can't travel anywhere else.
self.destroy()
dialogs.ErrorDialog(_('The service could not be found'),
_('There is no service at the address you entered, or it is not responding. '
'Check the address and try again.'))
_('There is no service at the address you entered, or it is '
'not responding. Check the address and try again.'),
transient_for=self.window)
return
klass = self.cache.get_browser(identities, features)
if not klass:
dialogs.ErrorDialog(_('The service is not browsable'),
_('This type of service does not contain any items to browse.'))
_('This type of service does not contain any items to browse.'),
transient_for=self.window)
return
elif klass is None:
klass = AgentBrowser

View File

@ -2139,7 +2139,8 @@ class GroupchatControl(ChatControlBase):
dialogs.ConfirmationDialogCheck(pritext, sectext,
_('_Do not ask me again'), on_response_ok=on_ok,
on_response_cancel=on_cancel)
on_response_cancel=on_cancel,
transient_for=self.parent_win.window)
return
on_yes(self)
@ -2215,7 +2216,8 @@ class GroupchatControl(ChatControlBase):
dialogs.DoubleInputDialog(_('Destroying %s') % '\u200E' + \
self.room_jid, _('You are going to definitively destroy this '
'room.\nYou may specify a reason below:'),
_('You may also enter an alternate venue:'), ok_handler=on_ok)
_('You may also enter an alternate venue:'), ok_handler=on_ok,
transient_for=self.parent_win.window)
def _on_bookmark_room_menuitem_activate(self, widget):
"""
@ -2415,7 +2417,8 @@ class GroupchatControl(ChatControlBase):
# ask for reason
dialogs.InputDialog(_('Kicking %s') % nick,
_('You may specify a reason below:'), ok_handler=on_ok)
_('You may specify a reason below:'), ok_handler=on_ok,
transient_for=self.parent_win.window)
def mk_menu(self, event, iter_):
"""
@ -2754,7 +2757,8 @@ class GroupchatControl(ChatControlBase):
nick = gajim.get_nick_from_jid(jid)
# ask for reason
dialogs.InputDialog(_('Banning %s') % nick,
_('You may specify a reason below:'), ok_handler=on_ok)
_('You may specify a reason below:'), ok_handler=on_ok,
transient_for=self.parent_win.window)
def grant_membership(self, widget, jid):
"""

View File

@ -413,7 +413,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
'acceptable?''') % (
negotiation.describe_features(ask_user)),
on_response_yes=accept_nondefault_options,
on_response_no=reject_nondefault_options)
on_response_no=reject_nondefault_options,
transient_for=self.control.parent_win.window)
else:
self.respond_e2e_bob(form, negotiated, not_acceptable)