From bbada2ecd4c86eb54c9678c8bbf1cccb1bb57345 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com>
Date: Tue, 26 Mar 2019 23:49:45 +0100
Subject: [PATCH] Improve NewConfirmationDialog

- Add setting for modal/non-modal
- Add default transient
- Dont call run() it only returns after response
---
 gajim/gtk/dialogs.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/gajim/gtk/dialogs.py b/gajim/gtk/dialogs.py
index 1f87fc29a9..ff7510e465 100644
--- a/gajim/gtk/dialogs.py
+++ b/gajim/gtk/dialogs.py
@@ -990,12 +990,16 @@ class ChangePasswordDialog(Gtk.Dialog):
 
 
 class NewConfirmationDialog(Gtk.MessageDialog):
-    def __init__(self, title, text, sec_text, buttons, transient_for=None):
+    def __init__(self, title, text, sec_text, buttons,
+                 modal=True, transient_for=None):
+        if transient_for is None:
+            transient_for = app.app.get_active_window()
         Gtk.MessageDialog.__init__(self,
                                    title=title,
                                    text=text,
                                    transient_for=transient_for,
-                                   message_type=Gtk.MessageType.QUESTION)
+                                   message_type=Gtk.MessageType.QUESTION,
+                                   modal=modal)
 
         self._buttons = {}
 
@@ -1012,8 +1016,6 @@ class NewConfirmationDialog(Gtk.MessageDialog):
 
         self.connect('response', self._on_response)
 
-        self.run()
-
     def _on_response(self, _dialog, response):
         if response == Gtk.ResponseType.DELETE_EVENT:
             # Look if DELETE_EVENT is mapped to another response
@@ -1031,6 +1033,9 @@ class NewConfirmationDialog(Gtk.MessageDialog):
             button.callback(*button.args, **button.kwargs)
         self.destroy()
 
+    def show(self):
+        self.show_all()
+
 
 class ShortcutsWindow:
     def __init__(self):
-- 
GitLab