Add transient argument to Dialogs

This commit is contained in:
Philipp Hörist 2018-03-07 19:39:33 +01:00
parent ce4d273dd7
commit 3fbce77818
1 changed files with 8 additions and 8 deletions

View File

@ -230,7 +230,7 @@ class PassphraseDialog:
Class for Passphrase dialog Class for Passphrase dialog
""" """
def __init__(self, titletext, labeltext, checkbuttontext=None, def __init__(self, titletext, labeltext, checkbuttontext=None,
ok_handler=None, cancel_handler=None): ok_handler=None, cancel_handler=None, transient_for=None):
self.xml = gtkgui_helpers.get_gtk_builder('passphrase_dialog.ui') self.xml = gtkgui_helpers.get_gtk_builder('passphrase_dialog.ui')
self.window = self.xml.get_object('passphrase_dialog') self.window = self.xml.get_object('passphrase_dialog')
self.passphrase_entry = self.xml.get_object('passphrase_entry') self.passphrase_entry = self.xml.get_object('passphrase_entry')
@ -248,7 +248,9 @@ class PassphraseDialog:
cancelbutton.connect('clicked', self.on_cancelbutton_clicked) cancelbutton.connect('clicked', self.on_cancelbutton_clicked)
self.xml.connect_signals(self) self.xml.connect_signals(self)
self.window.set_transient_for(app.interface.roster.window) if transient_for is None:
transient_for = app.app.get_active_window()
self.window.set_transient_for(transient_for)
self.window.show_all() self.window.show_all()
self.check = bool(checkbuttontext) self.check = bool(checkbuttontext)
@ -1856,15 +1858,13 @@ class ConfirmationDialogDoubleRadio(ConfirmationDialog):
""" """
def __init__(self, pritext, sectext='', radiotext1='', radiotext2='', def __init__(self, pritext, sectext='', radiotext1='', radiotext2='',
on_response_ok=None, on_response_cancel=None, is_modal=True): on_response_ok=None, on_response_cancel=None, is_modal=True, transient_for=None):
self.user_response_ok = on_response_ok self.user_response_ok = on_response_ok
self.user_response_cancel = on_response_cancel self.user_response_cancel = on_response_cancel
if hasattr(app.interface, 'roster') and app.interface.roster: if transient_for is None:
parent = app.interface.roster.window transient_for = app.app.get_active_window()
else: HigDialog.__init__(self, transient_for, Gtk.MessageType.QUESTION,
parent = None
HigDialog.__init__(self, parent, Gtk.MessageType.QUESTION,
Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok, Gtk.ButtonsType.OK_CANCEL, pritext, sectext, self.on_response_ok,
self.on_response_cancel) self.on_response_cancel)