-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Add dialog to ask for overwrite #1989
Add dialog to ask for overwrite #1989
Conversation
I havent tested yet but presumably this is intended to replace any dialog the calling app throws up when a file conflict occurs? Otherwise the user will be presented with two dialogs if the user confirms overwriting is intended. |
I see that Gtk.FileChooser interface has "do_overwrite_confirmation" property to deal with this but does the freedesktop portal interface support this? |
The documentation for the portal linked to above says
Does this mean other options can also be supported - in which case we need to support and honour the "do-overwrite-confirmation" property in the portal and default that to "false". |
Hmm. I agree, I don't see any such option in the freedesktop portal. Do you mean that it could be possible to pass it in the dictionary anyway out of spec? If so, then do we need to reimplement the whole GtkFileChooser overwrite interface? FWIW I read that wording to mean that these are the only supported options. But I'm not familiar with portals or their documentation so that probably doesn't mean much. |
Using the word "include" does not exclude the possibility of other options - to do that you would say "The supported keys in the options vardict are:". However it is possible that it is an unintentional miswording. Would need to add some code to
and add |
Yeah, adding a simple key like that would be relatively easy. I guess I may be misunderstanding. I was referring to the So are you thinking of just including a single key that turns on/off the overwrite dialog, or should we work on reaching more feature completeness with the Gtk interface? The second would be much harder. |
I am assuming that the portal interface will expect a dictionary Variant for the options but not be concerned with what it contains. I would be very wary of changing the spec of the portal. Just need to try it with one extra boolean option first. |
about the code, IMHO, it's better to do the check inside the
The frontend filter out unsupported options. so we cannot add an extra
Fature completeness with the Gtk.FileChooser shouldn't be an goal, we should only provide what's needed for the org.freedesktop.portal.impl.FileChooser interface. |
That's a pity. I guess the client app will have to continue do the check then. So does this make this PR a non-starter then? |
Is your concern that apps calling the portal will check for duplicates, making a dialog in the portal redundant? I can't think of any app that does that. At least for a selected file (as opposed to a directory into which it places multiple files, like Audacity's bulk export). That's what led me to this issue. Note that in GtkFileChooserNative, which is the only widget that would call the xdg portal afaik (?), the
I guess we could see what GNOME's portal does, but if we don't handle it in the file chooser, then my experience is that files will be silently overwritten. |
It depends on whether the portal expects the filechooser to always check for and confirm overwriting duplicates or never to check - since the option is not supported. You may be right that most apps leave it to the filechooser, but since, currently, that option defaults to I notice that Code sets the Either way some apps are going to have to change. |
Since apps are supposedly sandboxed, they shouldn't be able to see files outside the sandbox and thus wouldn't be able to check for duplicates. So this responsibility should fall on the file chooser portal. According to the spec:
|
This does not sound like the portal must always take an action. However, for the elementary portal, I guess we can specify that it does and that apps do not have to do any checking. In this case, any app that does check will have to be amended to remove the checks. Presumably the user could confirm that they want to overwrite the file with the same name? Or is that not allowed for sandboxed apps? |
Yeah I think making things the responsibility of the portal makes sense anyways so developers don't have to worry about it |
So are there any design changes I should be making, or do you think this is good to continue how I have it broadly set up here? I'm not quite understanding where this conversation ended up, sorry. @Marukesu I agree that in principle handling this in |
@mcclurgm the FileChooser calls However, i think having the dialog be like the FileConflictDialog offering to replace/rename (and a extra skip option, for the |
So if I understand correctly, you're saying the code that's currently in I see what you're saying about offering to rename the file in the dialog. Offering to rename does seem like a nice idea. But I'm wary of having a new dialog with no way to get back to the file chooser in its current state, for example if someone wanted to change the directory when they realized that there's a conflict. This could probably use input from UX. Sorry for letting this PR languish. Since I started working on it things have come up and I don't really have time right now, so I'm going to have to leave it be for a while. I may be able to come back to it, but it may be a while, since there's quite a bit of work left to do. If someone else wants to pick up from my work here I'd welcome it. |
Since the save file portal already has the ability to rename, we probably don't need to add that to this confirmation since "Cancel" for the confirmation should just take the user back to the save file portal where they can rename or change locations. |
If the file to be overwritten is read-only then the operation seems to fail silently. |
Am I right in thinking that this means that there is no need to check that |
Thanks for the update. It does work, although performing the action on key press instead of release is inconsistent with other UI. I wonder if it would be possible to capture the key event in the replace dialog instead and then stop propagation there, so it would never reach the Also, your change was overwritten by the latest merge commit. If we want to use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the replace dialog needs a transient parent. Currently it doesn't have one. That means that it appears in the window switcher, which it shouldn't.
I assume that it should be transient to the FileChooserDialog.
The changes suggested here would implement that. This is a set of 3 changes that all need to be committed together to work, since we need to pass around a FileChooserDialog
reference.
Update: I do remember doing this in my original code, but ran into some issues. The calling app window was never un-dimmed when the file chooser was dismissed. I don't see that with the changes I added here, so I am going to assume something about the way you've changed it fixed an issue with the replace dialog not being disposed properly. I'm not sure though.
Co-authored-by: Michael McClurg <mcgearboulder@gmail.com>
Co-authored-by: Michael McClurg <mcgearboulder@gmail.com>
Co-authored-by: Michael McClurg <mcgearboulder@gmail.com>
Sorry for the late review (again). This looks good to me for the most part. I've done my best to collect a list of the outstanding issues here. Potential blocking bugs:
Requires design input:
There are also some minor cosmetic issues, none of which I think are blocking:
I will also note that there may be some strange behavior when a file is deleted/moved/renamed from under the conflict dialog and you then save to the original, conflicted file. In Code, a warning infobar appears wrongly saying that the file has been deleted. It was deleted, but is now reinstated by saving. This issue is probably outside of the filechooser, but it seems possible that the chooser is passing something strange back to Code that is causing it to present that infobar. I have not been able to check this yet. Overall, I think this is essentially ready to go in my view. Just needs some input to determine whether we consider any of the above issues worth holding it up for longer. |
If the application fails silently with an non-writable file, it's an application bug, the user can always mark the file as non-writable. Something to check is if the GNOME and KDE portals let you select non-writeable files too, but not for this PR.
It's both, the user is selecting an file to the app get access, and then save somthing in it. What i had in mind was "don't warn users about something they're are already aware", if an sandboxed application has an valid "current_file", it's mean that he got the path from an previous portal call.
That's an gala issue, if the FileChooser has an parent, the dim is applied to the parent window again. Launching it without an parent window makes the FileChooserDialog be dimmed as expected.
Maybe we should port the FileChooser to be a Granite/Gtk.Dialog (we would need to port away from Hdy for Gtk4 anyway), but not in this PR. The
All we do is return an URI to the frontend, There's nothing we can do if the file gets deleted after that. If code shows strange behaviour if the file get deleted by it back, it's should be fixed there. |
Seems to make sense - I'll commit and test. Co-authored-by: Gustavo Marques <pushstarttocontinue@outlook.com>
@Marukesu This seems to work pretty well now. It may be better to merge and iterate with smaller PRs? There is a Files release coming up and it would be good to get this in. |
@mcclurgm I have now fixed the |
@jeremypw the portal frontend expect the response begin 0 on success, 1 on cancel, and 2 for any other reason, what we do here is what GNOME do in the Gtk/GNOME portal. one last change: on |
Both the filechooser dialog and the conflict dialog now dismiss separately with Actions linked to accelerators fire on key down. |
Fixes #1955
Adds a new second-layer modal dialog that asks whether to overwrite a file when the name clashes with an existing file.
Known issues:
Things to check:
Any other testing, code, or design input would be hugely appreciated.