mirror of https://github.com/tuhiproject/tuhi.git
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 <peter.hutterer@who-t.net>pull/264/head
parent
ea5177027c
commit
eef877d6ce
|
@ -112,11 +112,9 @@ class Drawing(Gtk.EventBox):
|
||||||
|
|
||||||
@Gtk.Template.Callback('_on_download_button_clicked')
|
@Gtk.Template.Callback('_on_download_button_clicked')
|
||||||
def _on_download_button_clicked(self, button):
|
def _on_download_button_clicked(self, button):
|
||||||
dialog = Gtk.FileChooserDialog(_('Please choose a file'),
|
dialog = Gtk.FileChooserNative()
|
||||||
None,
|
dialog.set_action(Gtk.FileChooserAction.SAVE)
|
||||||
Gtk.FileChooserAction.SAVE,
|
dialog.set_transient_for(self.get_toplevel())
|
||||||
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
|
|
||||||
Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
|
|
||||||
|
|
||||||
dialog.set_do_overwrite_confirmation(True)
|
dialog.set_do_overwrite_confirmation(True)
|
||||||
# Translators: the default filename to save to
|
# Translators: the default filename to save to
|
||||||
|
@ -139,7 +137,7 @@ class Drawing(Gtk.EventBox):
|
||||||
dialog.add_filter(filter_any)
|
dialog.add_filter(filter_any)
|
||||||
|
|
||||||
response = dialog.run()
|
response = dialog.run()
|
||||||
if response == Gtk.ResponseType.OK:
|
if response == Gtk.ResponseType.ACCEPT:
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
file = dialog.get_filename()
|
file = dialog.get_filename()
|
||||||
|
|
Loading…
Reference in New Issue