After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 768014 - use native dialogs for opening and saving
use native dialogs for opening and saving
Status: RESOLVED FIXED
Product: gedit
Classification: Applications
Component: file loading and saving
unspecified
Other Linux
: Normal normal
: later release (3.27)
Assigned To: Gedit maintainers
Gedit maintainers
: 784584 793695 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-06-24 16:42 UTC by Matthias Clasen
Modified: 2018-10-15 21:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
first patch (3.96 KB, patch)
2016-06-24 19:53 UTC, Matthias Clasen
none Details | Review
second patch (3.96 KB, patch)
2016-06-24 19:53 UTC, Matthias Clasen
none Details | Review
second patch (11.99 KB, patch)
2016-06-25 13:21 UTC, Matthias Clasen
none Details | Review

Description Matthias Clasen 2016-06-24 16:42:04 UTC
GTK+ has GtkFileChooserNative nowadays. It would be great to use that, since that instead of your homegrown osx native dialogs (and it would also be great if those could be turned into an osx implementation of GtkFileChooserNative).

The big advantage of using GtkFileChoserNative is that it will work in a flatpak sandbox, by talking to a portal.
Comment 1 Sébastien Wilmet 2016-06-24 19:47:37 UTC
gedit adds comboboxes to the GtkFileChooserDialog to choose the character encoding and line ending type. It's convenient to have those in the file chooser, at least for file saving.
Comment 2 Matthias Clasen 2016-06-24 19:53:26 UTC
Created attachment 330338 [details] [review]
first patch
Comment 3 Matthias Clasen 2016-06-24 19:53:55 UTC
Created attachment 330339 [details] [review]
second patch
Comment 4 Matthias Clasen 2016-06-24 20:00:19 UTC
(In reply to Sébastien Wilmet from comment #1)
> gedit adds comboboxes to the GtkFileChooserDialog to choose the character
> encoding and line ending type. It's convenient to have those in the file
> chooser, at least for file saving.

Yeah, those will be lost with native file choosers.

The thing is: if you can't see any files because your sandboxed app has no direct access to the filesystem, those comboboxes don't really help.
Comment 5 Sébastien Wilmet 2016-06-25 09:44:08 UTC
The two patches are identical. The second one was maybe supposed to be for file saving?
Comment 6 Matthias Clasen 2016-06-25 13:21:59 UTC
Created attachment 330364 [details] [review]
second patch

sorry about that
Comment 7 Sébastien Wilmet 2016-06-27 14:37:37 UTC
I'm not a gedit maintainer, but it seems to me that removing important features of a text editor is not really an improvement.

The features that the above patch removes:
- choosing the character encoding;
- choosing the line ending type;
- support gzip compression.

If those are not possible to integrate with a native file chooser, it must be integrated in gedit in another way. But when saving a file seems like a good time to ask the user about those options.

Also, to support gedit in a Flatpak sandbox without host filesystem access, there is also the integrated file browser plugin to adapt. And I think it's more difficult to come up with something still convenient to use, and useful. So host filesystem access is anyway needed for the integrated file browser.
Comment 8 Ignacio Casal Quinteiro (nacho) 2016-06-27 14:39:30 UTC
From a selfish point of view I really don't care much about the character encoding and gzip compression, but choosing the line ending type is a must for me...
Comment 9 Matthias Clasen 2016-06-27 14:57:10 UTC
I understand that these are features that somewhat set gedit apart from the rest. Personally, I've always considered them a bit odd and out of place in the file chooser.

But clearly, we should have some way to handle the equivalent in a sandboxed scenario. One would be to just try loading the file with default settings and ask the user if that fails.

Regarding the file browser plugin: thats a feature that simply will not work in a sandbox. At the end of the day, there's tradeoffs required.
Comment 10 Alexander Larsson 2016-06-27 15:09:06 UTC
My long term plan was to extend the native file chooser API to let you specify a list of checkboxes and combobox dropdowns you could show in the dialog, and report the values of these when the user OKs. This could be implemented in both the win32 implementation and the portal one. Would that be enough for gedit?

Of course, other parts of gedit like the sidebar wouldn't be very useful in a sandboxed environment, but maybe at least it would do *something* and then you could grant it more access if you want to use it more heavily.
Comment 11 Matthias Clasen 2016-06-28 01:07:36 UTC
I've written some code for this today (only implemented for the portal case).

https://git.gnome.org/browse/gtk+/log/?h=portal

https://github.com/flatpak/xdg-desktop-portal-gtk/pull/12
Comment 12 Alexander Larsson 2016-06-28 08:00:45 UTC
I think the basic portal stuff is ok, but there are some wider issues:

a) You implemented the gtk filechooser support for choices in the portal, but it should really be in the gtk implementation of GtkFileChooserNative, so that it can easily be reused in the portal *and* by apps not using a portal (but using the GtkFileChooserNative interface).

b) such new feature additions to the native filechooser interface needs work in the other native file chooser implementations so that they fall back on the gtk implementation instead of e.g. the win32 dialog until such a time as we add proper choice support to those implementations.
Comment 13 Matthias Clasen 2016-06-28 10:37:17 UTC
(In reply to Alexander Larsson from comment #12)
> I think the basic portal stuff is ok, but there are some wider issues:
> 
> a) You implemented the gtk filechooser support for choices in the portal,
> but it should really be in the gtk implementation of GtkFileChooserNative,
> so that it can easily be reused in the portal *and* by apps not using a
> portal (but using the GtkFileChooserNative interface).

Good point, I can look at that.

> b) such new feature additions to the native filechooser interface needs work
> in the other native file chooser implementations so that they fall back on
> the gtk implementation instead of e.g. the win32 dialog until such a time as
> we add proper choice support to those implementations.

I'll look at fixing up the fallback implementation; I don't think I can do win32.
Comment 14 Matthias Clasen 2016-06-28 10:51:19 UTC
So ftr, the plan is to move the new api to GtkFileChooser, and then implement it for the various native dialogs.
Comment 16 Sébastien Wilmet 2016-07-01 11:54:21 UTC
(In reply to Alexander Larsson from comment #10)
> My long term plan was to extend the native file chooser API to let you
> specify a list of checkboxes and combobox dropdowns you could show in the
> dialog, and report the values of these when the user OKs. This could be
> implemented in both the win32 implementation and the portal one. Would that
> be enough for gedit?

As is, it would not be enough for choosing the encoding in gedit, because when we click on "Add or Remove…" in the combobox, another dialog is opened. Although it should be possible to find a better UI for that.
Comment 17 Matthias Clasen 2016-07-01 14:34:23 UTC
Yes, I'm not going to add portal api for that sort of interactive back-and-forth between the application and the portal process. We will have to find another place in the application ui to configure encodings to show.
Comment 18 Matthias Clasen 2016-07-07 18:56:31 UTC
I've added a working print portal too now. It comes for free if you are using GtkPrintOperation - does gedit do that ?
Comment 19 Ignacio Casal Quinteiro (nacho) 2016-07-07 19:19:58 UTC
Paolo is the one who made it but if I recall correct we have some text editor widget as well.
Comment 20 Paolo Borelli 2016-07-07 19:31:38 UTC
Yes, we use printoperation but we use the feature adds a custom tab to the dialog, not sure if that is a problem for portals.

Thanks a lot for all your work on this and I am sorry that I did not provide timely feedback
Comment 21 Matthias Clasen 2016-07-07 19:53:42 UTC
(In reply to Paolo Borelli from comment #20)
> Yes, we use printoperation but we use the feature adds a custom tab to the
> dialog, not sure if that is a problem for portals.

It is not currently supported :-( I can look at doing something similar to the filechooser, just needs some time.
Comment 22 George White 2017-08-27 18:31:08 UTC
*** Bug 784584 has been marked as a duplicate of this bug. ***
Comment 23 Chris Murphy 2017-11-25 20:29:58 UTC
As a consequence of this bug, it's not possible for Text Editor flatpak build to use SMB shares for opening or saving documents.
Comment 24 Piotr Drąg 2018-02-22 19:18:32 UTC
*** Bug 793695 has been marked as a duplicate of this bug. ***
Comment 25 Jeremy Bicha 2018-10-15 21:45:49 UTC
This is fixed in gedit 3.30.0.