From eef877d6ce24f84183b15d467f7db0851a6dae1a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 25 Aug 2020 16:23:41 +1000 Subject: [PATCH] tuhi: use a Gtk.FileChooserNative dialog This one hooks into the correct portal APIs, hopefully fixing the issue with the Flatpak version not saving files correctly. Signed-off-by: Peter Hutterer --- tuhi/gui/drawing.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tuhi/gui/drawing.py b/tuhi/gui/drawing.py index 79da826..9ebfbe2 100644 --- a/tuhi/gui/drawing.py +++ b/tuhi/gui/drawing.py @@ -112,11 +112,9 @@ class Drawing(Gtk.EventBox): @Gtk.Template.Callback('_on_download_button_clicked') def _on_download_button_clicked(self, button): - dialog = Gtk.FileChooserDialog(_('Please choose a file'), - None, - Gtk.FileChooserAction.SAVE, - (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, - Gtk.STOCK_SAVE, Gtk.ResponseType.OK)) + dialog = Gtk.FileChooserNative() + dialog.set_action(Gtk.FileChooserAction.SAVE) + dialog.set_transient_for(self.get_toplevel()) dialog.set_do_overwrite_confirmation(True) # Translators: the default filename to save to @@ -139,7 +137,7 @@ class Drawing(Gtk.EventBox): dialog.add_filter(filter_any) response = dialog.run() - if response == Gtk.ResponseType.OK: + if response == Gtk.ResponseType.ACCEPT: import shutil file = dialog.get_filename()