-
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing neighboring files #997
Comments
For creating and saving multiple files:
Feasible? Opinions? |
Interesting, but I don't think it's feasible. Usually the file chooser returns a location. As things stand, I don't think it's possible to pass much information. Such a mechanism involve the system api rather than the UI, would this mean modifying every existing file chooser? A few days ago I was seeing Gtk file chooser, I don't know if there are hooks to do this or make it possible with portals api. |
I don't know because I'm not a developer. But this will certainly involve modifying the way file choosers work. |
There's already the SaveFiles method in the FileChooser portal, the application send the list of files it want written and the portal will return the ones that got actually written. |
@Marukesu: Indeed, but does it work by also creating folders? Also, the phrasing in the documentation leads me to think that the files are saved as is, with no option to change the name. Also, is file size taken into account? Another question: What about the Firefox case? Are the relevant files of the website to save already downloaded or downloaded after saving the html file? |
no, all the paths used will be exported to the sandbox as files.
yes, it's intended. if we are dealing with auxiliary files, like all the use cases said does, allowing to change the name won't be helpful.
no. why it would, the chooser is to select a location.
i don't get it, the firefox case seem simple:
keep in mind that the portal doesn't save (or in the case of OpenFile, open) anything. it just return paths that can be used by the application, how and in what order things are written is up to the application. |
expanding in the user cases:
|
Although Inform and Metadata Cleaner are cases related to opening files/folders, I thought it was a good idea to address them separately so that #463 just focuses on the opening part, because the rest is about writing files. Note that I have not discussed these cases yet. The first part offered is just when creating a project that also writes other files (KiCad) or an app that saves multiple files (Firefox). The goal is for the user to be aware of an app's writing activity (here: that other files are being written, which ones and how much storage space they take). This obviously requires extending the portal and file choosers. |
In my case the multiple files are saved on folder, but only the first file gets the right name, the other files get hashed file name, eg.
Files are saved but are unrecognizable, except the first one that is saved. This was a month ago in Arch Linux, with xdg-desktop-portal-gtk, file chooser Gtk3, Qt6. Opening files from folder works as expected. |
Unless the user set the chooser to "open in read-only mode" (availability depends of the backend), if you open a path you can already write to it. so any case that deals with "give access to a neighbour path based in a opened path" is a #463 case solely. This issue only make sense if you are talking about "also create theses others files when creating this file".
You can show the file names sent in the SaveFiles call already, that just need implementation changes in the backends to use that information. The file size doesn't make sense at all with how the portal (or even any chooser API) works. Even if a option to send the file sizes is added, i don't think it will be used by libraries.
AFAIK, none of the more common libraries make use of the SaveFiles method, so a application will need to talk to the portal directly, or update the used library to make use of it. |
Thanks! For me, neighbor files are additional files to open (I made proposals for this which are now in the Discussions tab), and not provide access to the parent directory. But even if it would be to give access to the parent directory, in the case of Metadata Cleaner it is better to have something specific, rather than having access to the parent directory of each file (because the files can come from different locations). |
For saving pages in case of firefox it should be sufficient to give access to the directory named after the selected filename from the file chooser. Having something like a #463 (comment) would be great. |
That would be great. I could image that you would have some kind of special tailored case for the Firefox by passing portal that
Or do you want to avoid additional changes on the application part beside than filechooser picker portal invocation or some other approach? |
Don’t really know as I’m not a developper. I think that an app should adapt its request depending on what filter is selected or just sends the request (in Firefox case, telling which files to write) with some hint and file chooser adapt relative to selected filter. |
Considering that this issue is old and that the discussion is almost 6 months old, I think I can look at the different cases to see what kind of user interface to expect and what can be grouped. |
For the developer side, one way to do this would be:
This way, Firefox would first usa a SaveFile call for the main file, with the possible filters and with the neighbor flag set, and if the selected filter is the one that save extra files, use a SaveFiles call to write them with the correct names. |
But changing the location in the Or you mean all the work would be done by the portal depending what filter had been chosen? That's basically does not require any code change on the Firefox side, but it seems that's really customization just for Firefox on the portal side (I'm fine with that, but I guess not many are :) ). |
Anyway, @matthiasclasen you may have some ideas, at least according to some random quote on https://gitlab.com/fedora/sigs/flatpak/fedora-flatpaks/-/issues/13#medium-impact-issues :). |
...not to mention all the applications where upstream gets the chooser automatically because they use Qt or GTK, may not even see Linux as a primary platform, and aren't really interested in Flatpak or Snap, so the package maintainers just have to go for something like |
A second dialog is not excluded, as there is the case of the "Save Location" where the user will be asked to confirm the saving of the files (at least for now). Otherwise, I guess some descriptive file that can be read by the portal might work (the thing I used for my other neighboring files proposals). However, this indeed depends on which cases other than Firefox can use it. My main point is just to avoid two dialogs just to save one thing (the entire web page which is composed of multiple files). So depends on cases and development effort. |
*nod* I can certainly agree on the "no two dialogs" part. |
I don’t understand the thing on "changing the location in the SaveFiles dialog". What does this mean? Isn’t the user expected to choose the location, or that’s another thing? |
That's why the "relative" flag would be added, so that the portal have the necessary information to skip the directory chooser, or show a "create neighbor" dialog like @Mikenux suggested. The, also added, "neighbor" flag in the SaveFile method , would alow backend implementers to inform that the application may write other files in the same directory or subdirectories. |
@Marukesu: It is preferable to avoid two UXes for the same case. By re-reading my proposal (the discussion I opened), write access is given when a file is saved by showing a file chooser (if the app has the focus), and is valid until the app is closed (because that’s difficult to externalize the save function). I wanted the user to have the opportunity to see at least which files will be saved, but I can forget that as the user is not necessarily aware of it in all cases. A system might also track that and probably show a write activity report to users, say when the app is closed. Maybe this is acceptable? So:
Here, no need for a flag or a specific dialog. |
The current behaviour for mounting files into documents portal paths results in the provided file path being valid at least as long as the session and, if it's not marked as session-only, until explicitly revoked using the flatpak CLI. (Try running I wouldn't want some "ToC file adjacent to the subresources" project-based tool like Eclipse or LyX or whatever to work initially and then unexpectedly start throwing errors about being able to write some files but not others when I go to Ctrl+S again later. That sounds like it'd be hell to diagnose and insanely frustrating for anyone who doesn't have it click that "Oh, this is how the documents portal works". |
So, there's already the need of either a flag or a fully new method in the portal, because, IIRC, the application doesn't have access to the full host path of the file. So you need a way to say that the list of paths is relative to the specified file.
The alternative dialog covers the case of a application trying to save neighbor files when it doesn't have permission to do so, either because it didn't request, or the user revoked it afterwards. So i wouldn't say it cover the same case of the choser (no relative file specified), nor the skip case (the user is aware and give the application permission to write neighbor files relative to the specified one). |
I would say the permission revoking for saving neighbors removes the ability of creating new files, not to writing to the ones already created from it. |
Except that those sorts of project tools won't pop up a file picker the first time you choose something like File > Export > PDF (pdflatex). They'll just derive a filename from the existing file (eg. ...and so you'll get an error if you've been using the Same for an IDE where you've been doing debug builds that show up in the project folder for a while and then try to make a release build after the timeout has run its course, assuming it's an IDE which supports "multiple projects in a single folder" by expecting you to pick the project file instead of the containing folder. It's just part of their design that they assume that permissions won't time out because that's not how POSIX normally works. It's "Once you've 'Save As...''d once, you don't need to pick the file again when 'Save'-ing", except extended to newly created derived files from things like Export or Build too. |
@Marukesu: I’m not assuming that the user will give permission to write additional files as we don’t necessarily know if these files are needed. So, I’m assuming to write these files without a permission. Even with what I said, given it is detectable (making the request within the timeout), I guess it is possible to make it a permission. Anyway, a flag can be used if needed. However, I don’t get why an app would forget to use the flag. Writing additional files is predictable, at least in the case of Firefox. @ssokolow: Take a look at #1397. I’m working by case (like what I done for opening neighboring files), and I prefer to make things coherent. All cases don’t necessarily get the same treatment. For any new file or new group of files, except for exceptions, a dialog will be shown. Is that problematic if a dialog is shown asking the user where to save the file to export? Also, what’s the thing with the dvi? Is the app convert the lyx file to a dvi file in order to preview it? (Maybe that’s something for temporary files?) |
This is the equivalent of #463, but for writing files.
To be exact, it is about writing/creating folders or files after the opening or creation of a folder or file.
There are already 4 app cases listed:
site.html
) and Firefox automatically saves several files in a folder with the same name as the html file with a suffix (e.g.site_files
). The html file and its companion folder are saved in the same folder..materials
folder (folder extension) with the same name and in the same folder as an open.inform
folder. It also creates folders and files in the.inform
project folder after creating it.filename.cleaned.ext
, whereext
is the extension of the original file)..kicad_pro
,.kicad_pcb
and.kicad_sch
.Cases, said another way:
Other cases are welcome. If they are different from those mentioned, please provide a description if possible.
Addition (June 18, 2023)
Other cases :
.materials
folder if it does not exist after opening the.inform
folder.The text was updated successfully, but these errors were encountered: