[meld] misc: Break out the modal parent logic; it's useful for other dialogs
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] misc: Break out the modal parent logic; it's useful for other dialogs
- Date: Sat, 7 Apr 2018 22:22:09 +0000 (UTC)
commit dd79049f48c7b98900a1de1871fb6189de158919
Author: Kai Willadsen <kai willadsen gmail com>
Date: Fri Apr 6 10:08:38 2018 +1000
misc: Break out the modal parent logic; it's useful for other dialogs
meld/misc.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/meld/misc.py b/meld/misc.py
index bc92d867..4b5751c7 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -54,6 +54,17 @@ def with_focused_pane(function):
return wrap_function
+def get_modal_parent(widget: Gtk.Widget = None) -> Gtk.Window:
+ if not widget:
+ from meld.meldapp import app
+ parent = app.get_active_window()
+ elif not isinstance(widget, Gtk.Window):
+ parent = widget.get_toplevel()
+ else:
+ parent = widget
+ return parent
+
+
def error_dialog(primary, secondary) -> Gtk.ResponseType:
"""A common error dialog handler for Meld
@@ -79,19 +90,13 @@ def modal_dialog(
Primary must be plain text. Secondary must be valid markup.
"""
- if not parent:
- from meld.meldapp import app
- parent = app.get_active_window()
- elif not isinstance(parent, Gtk.Window):
- parent = parent.get_toplevel()
-
if isinstance(buttons, Gtk.ButtonsType):
custom_buttons = []
else:
custom_buttons, buttons = buttons, Gtk.ButtonsType.NONE
dialog = Gtk.MessageDialog(
- transient_for=parent,
+ transient_for=get_modal_parent(parent),
modal=True,
destroy_with_parent=True,
message_type=messagetype,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]