Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jeremypw
Copy link
Collaborator

@jeremypw jeremypw commented Apr 11, 2023

Speculative PR investigating possibility of replacing the infobar (with limited layout possibilities) with a dialog when it comes to dealing with problems saving to the current location.

Because of the focus changes caused by the dialog (which trigger handlers in document) several other significant changes were needed, principally giving the document a "locked" state in which it cannot be saved or autosaved and does not react to focus changes nor is saved when closed. The document enters this state (shown as a lock in the tab) whenever it cannot be saved to the current location and before the dialog is shown. The document remains in that state until "save as" is performed.

The ask save location dialog is called from fewer places than previously - now only after a save failure and after a status change to "not exist" or "unwritable".

External edits to the document still show an infobar - that can be revisited in another PR.

As now, the document is always opened unlocked and and does not become locked until edited (or unmounted or deleted). This allows viewing read-only documents without unnecessary interruption.

It needs to be decided if the more intrusive dialog is a better option. It can then be smartened up.

@jeremypw jeremypw mentioned this pull request Apr 12, 2023
Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments. This seems to work well, nice job!

/* Copyright 2023 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
public class Scratch.Dialogs.AskSaveLocationDialog : Granite.MessageDialog {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell this is only used once. It seems kind of excessive to create a class for a MessageDialog since this is already quite abstract

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to clutter up Document.vala any more than necessary as it already well over 1000 lines. Also there will potentially be a need for another similar dialog to deal with external changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, but ask_save_location () is already an abstraction for this dialog so to add another layer of abstraction here seems like we're creating lasagna and we should have one or the other

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will merge these one way or another.

Jeremy Wootten and others added 6 commits April 25, 2023 17:21
Change button text to "Save Duplicate"

Co-authored-by: Danielle Foré <[email protected]>
Use emblem-readonly-symbolic for locked document

Co-authored-by: Danielle Foré <[email protected]>
Better primary text

Co-authored-by: Danielle Foré <[email protected]>
@jeremypw
Copy link
Collaborator Author

@danirabbit Thanks for the review comments! I have actioned most of them. There are couple that require further discussion.

/* Copyright 2023 elementary, Inc. <https://elementary.io>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
public class Scratch.Dialogs.AskSaveLocationDialog : Granite.MessageDialog {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, but ask_save_location () is already an abstraction for this dialog so to add another layer of abstraction here seems like we're creating lasagna and we should have one or the other

@jeremypw jeremypw marked this pull request as ready for review April 26, 2023 17:16
@jeremypw jeremypw requested a review from danirabbit April 26, 2023 17:16
@jeremypw
Copy link
Collaborator Author

I have now inlined the new dialog and made the other requested changes. Also fixed some new critical warnings on startup.

Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works as far as I can tell!

@danirabbit danirabbit merged commit 1934886 into master Apr 26, 2023
@danirabbit danirabbit deleted the ask-savelocation-dialog branch April 26, 2023 21:28
if (!locked && !can_write () && source_view.buffer.get_modified ()) {
// The file has become unwritable while changes are pending
locked = true;
var details = _("File “%s” was does not have write permission.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit late to the party but this sentence should probably be rephrased

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Thanks for noticing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants