fix transient for windows. Fixes #7185

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

View File

@ -2787,11 +2787,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

@ -1508,10 +1508,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.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, pritext, sectext,
self.on_response_ok, self.on_response_cancel)
self.popup()
@ -1589,8 +1589,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
@ -1712,11 +1714,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
@ -1972,13 +1976,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')
@ -2015,10 +2022,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)
@ -2198,7 +2205,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')
@ -2215,6 +2223,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)
@ -4531,7 +4541,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

@ -759,13 +759,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

@ -2130,7 +2130,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)
@ -2206,7 +2207,8 @@ class GroupchatControl(ChatControlBase):
dialogs.DoubleInputDialog(_('Destroying %s') % u'\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):
"""
@ -2406,7 +2408,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_):
"""
@ -2738,7 +2741,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)