Merge lp://staging/~artem-anufrij/scratch/dont-force-to-save-unsaved into lp://staging/~elementary-apps/scratch/scratch

Proposed by Artem Anufrij
Status: Merged
Approved by: Robert Roth
Approved revision: 1414
Merged at revision: 1393
Proposed branch: lp://staging/~artem-anufrij/scratch/dont-force-to-save-unsaved
Merge into: lp://staging/~elementary-apps/scratch/scratch
Diff against target: 746 lines (+236/-186)
7 files modified
HACKING (+1/-1)
src/Dialogs/PreferencesDialog.vala (+1/-5)
src/MainWindow.vala (+53/-6)
src/Scratch.vala (+16/-2)
src/Services/Document.vala (+145/-161)
src/Widgets/DocumentView.vala (+13/-3)
src/Widgets/ToolBar.vala (+7/-8)
To merge this branch: bzr merge lp://staging/~artem-anufrij/scratch/dont-force-to-save-unsaved
Reviewer Review Type Date Requested Status
Robert Roth (community) code review Approve
Danielle Foré ux Approve
Review via email: mp+237154@code.staging.launchpad.net

Commit message

Use temporary files for unsaved files to be able to restore them at next startup

Description of the change

BLUEPRINT DESCRIPTION:
+1 for keeping in .local/share/scratch/unsaved/. Because losing work is the worst user experience ever. If we keep files in /tmp they can get deleted by the system (think sudden power outage and user boots again or even someone is keeping /tmp in RAM - other systems and maybe future eOS). And if we keep them in trash user can delete them unknowingly because he expects that only files that he himself moved to trash are there. Also files that are not saved anywhere IMHO should have a *highly visible* warning so that even user that is absolutely new to PCs knows it's not saved. (Perhaps a red exclamation mark on the tab? Or the entire tab tinted slightly red?) Won't it be annoying? No, because how often do you write and keep in editor (for a longer time) something that you don't want to save? ~grzesiek1e5

To post a comment you must log in.
1399. By artem-anufrij

Ready for check (clear 'file != null' block)

1400. By artem-anufrij

Replace 'scratch' to exec_name. Fix code style.

1401. By artem-anufrij

Delete old backup file after 'save as...'

Revision history for this message
Robert Roth (evfool) wrote :

Code looks mostly OK, here are some notes:
* Singleton is not needed here, accessing data_home_folder_unsaved seems to be the only reason you're making the Scratch instance a singleton, but that variable should be part of settings (e.g I want to configure that in dconf - or scratch Preferences if Dan allows - to use /tmp instead of my home dir)
* string message = _("File ") + " \"<b>%s</b>\" ".printf (get_basename ()) + _("was modified by an external application. Do you want to load it again or continue your editing?");
This is not translation-friendly, and there are more like this. Translatable strings should not be concatenated.
It can also be written like: _("File %s was modified by an external application.").printf ("<b>%s</b>".printf (get_basename ())).
I see that there are some of these coming from before your commits, so it's not 100% your code, but they should be fixed too (not necessarily on this branch), but at least the code we touch should get better after each touch.
* Add a description and a commit message to the merge proposal
I haven't tested this yet, this is just a code review, will test later, with the fixes.

review: Needs Fixing (code review)
1402. By artem-anufrij

dev-commit

1403. By artem-anufrij

get_user_cache_dir() for termporary files; changed the text.

1404. By artem-anufrij

always open temporary files on startup

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Please check the fixes.
- temporary location: .local/share/scretch-text-editor/unsaved
- text style was fixed.

Revision history for this message
Robert Roth (evfool) wrote :

See my inline comments. I'm still not sure the scratch app instance should be made singleton just to be able to access the path variable, that's a second reason why settings-based path was suggested, as the settings object is available globally.

review: Needs Fixing
1405. By artem-anufrij

code fixing

Revision history for this message
Robert Roth (evfool) wrote :

Ok, looks nice, as per Slack comments the path doesn't have to be configurable, so we're keeping the app instance singleton. Approved.

review: Approve
1406. By artem-anufrij

temporary typer

Revision history for this message
Danielle Foré (danrabbit) wrote :

I think if you close the individual tab (as opposed to the whole app) you should be prompted to either save or delete. I don't think we should encourage a workflow where users can perpetually store a bunch of documents in a hidden folder. Additionally, in the current workflow I'm not sure how I'm supposed to discard a document that I've decided I don't actually want to save.

I'm also thinking that we should override the tab/title name for unsaved documents and just call them "unsaved document" or something instead of referring to them as a file name with a location inside the app.

review: Needs Fixing (ux)
1407. By artem-anufrij

Implemented as agreed.

1408. By artem-anufrij

Implemented as agreed.

1409. By artem-anufrij

Implemented as agreed.

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

I have changed the functionality as agreed. Please check this out.

Revision history for this message
Robert Roth (evfool) wrote :

Code style is mostly ok, see one minor request inline.

review: Needs Fixing (code style)
1410. By artem-anufrij

Code style has been improved.

Revision history for this message
Robert Roth (evfool) wrote :

Code style fixed, approving, waiting for Dan's approval.

review: Approve (code style)
Revision history for this message
Danielle Foré (danrabbit) wrote :

Maybe I'm missing something, but the feature seems to no longer work at all. Trying to close the app with an unsaved document prompts me to save.

Also the window title still reflects the name and location of the file

1411. By artem-anufrij

Window title fixed

App closing: save 'unsaved' files in ./local/share/... without save dialog
Tab closing: show save dialog for 'unsaved' files

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :

Hey Dan,

sorry I have overlooked the: "...(as opposed to the whole app)...".

Now it feels smooth.

1412. By artem-anufrij

code style

1413. By artem-anufrij

code style

Revision history for this message
Danielle Foré (danrabbit) wrote :

Works as expected now. Thanks Artem! This is great :)

review: Approve (ux)
Revision history for this message
Robert Roth (evfool) wrote :

Looks fine, two more indentation issues to fix before the final approval.

review: Needs Fixing (code review)
1414. By artem-anufrij

code style fixed

Revision history for this message
Artem Anufrij (artem-anufrij) wrote :
Revision history for this message
Robert Roth (evfool) wrote :

Ok, Approving. Thanks for the several fixes and your perseverence, it is something of great value.

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches