[GTK] Destroy the dialog before running the callback

Currently, the dialog window is displayed until after the callback has returned.
The result is that if a new dialog is opened from the callback, the first dialog
is still displayed until the new dialog is destroyed.

Fix by destroying the dialog before running the callback.
This commit is contained in:
bendikro 2019-11-05 15:45:30 +01:00 committed by Calum Lind
parent 3519f341d4
commit 1e3c624613
1 changed files with 4 additions and 2 deletions

View File

@ -72,12 +72,12 @@ class BaseDialog(Gtk.Dialog):
self.vbox.show_all()
def _on_delete_event(self, widget, event):
self.deferred.callback(Gtk.ResponseType.DELETE_EVENT)
self.destroy()
self.deferred.callback(Gtk.ResponseType.DELETE_EVENT)
def _on_response(self, widget, response):
self.deferred.callback(response)
self.destroy()
self.deferred.callback(response)
def run(self):
"""
@ -110,6 +110,8 @@ class YesNoDialog(BaseDialog):
(_('_No'), Gtk.ResponseType.NO, _('_Yes'), Gtk.ResponseType.YES),
parent,
)
# Use the preferred size calculated from the content
self.set_default_size(-1, -1)
class InformationDialog(BaseDialog):