New feature with new icon on toolbar & in the menu. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1471
-- Commit Summary --
* Add related icons to project * Add to ui 'Reload all' feature * Add shortcat key for 'Reload all' feature * Modify reload algorithm according to new feature * Insert some rows to doc file about new feature
-- File Changes --
M data/geany.glade (17) M doc/geany.txt (3) M icons/16x16/Makefile.am (3) A icons/16x16/geany-reload-all.png (0) M icons/24x24/Makefile.am (3) A icons/24x24/geany-reload-all.png (0) M icons/32x32/Makefile.am (3) A icons/32x32/geany-reload-all.png (0) M icons/48x48/Makefile.am (3) A icons/48x48/geany-reload-all.png (0) M icons/scalable/Makefile.am (3) A icons/scalable/geany-reload-all.svg (682) M icons/tango/16x16/Makefile.am (3) A icons/tango/16x16/geany-reload-all.png (0) M icons/tango/24x24/Makefile.am (3) A icons/tango/24x24/geany-reload-all.png (0) M icons/tango/32x32/Makefile.am (3) A icons/tango/32x32/geany-reload-all.png (0) M icons/tango/48x48/Makefile.am (3) A icons/tango/48x48/geany-reload-all.png (0) M icons/tango/scalable/Makefile.am (3) A icons/tango/scalable/geany-reload-all.svg (682) M src/callbacks.c (20) M src/callbacks.h (2) M src/keybindings.c (16) M src/keybindings.h (3) M src/toolbar.c (2) M src/ui_utils.c (7) M src/ui_utils.h (1)
-- Patch Links --
https://github.com/geany/geany/pull/1471.patch https://github.com/geany/geany/pull/1471.diff
Closed #1471.
Reopened #1471.
@attila-v pushed 1 commit.
b8e0103 Put two missed commits back
This silently reloads files that have unsaved changes. The changes can then be recovered by invoking “undo” in each affected document, but I think this is dangerous. I could invoke “reload all” by accident and then I don’t even know what to undo.
Maybe a dialog box like this would be appropriate:
The following 3 files have unsaved changes:
/home/vasiliy/foo/bar/baz /home/vasiliy/quux/xyzzy /home/vasiliy/wololo
Do you want to reload them as well? The changes will be gone, but you can restore them by invoking “undo” in individual documents.
<Yes, reload these files> <No, skip these files>
Personally, I would also be OK with silently skipping such files — that’s what I do now in my plugin. But at least a message in the status bar would be useful and easy to add.
vfaronov commented on this pull request.
- document_reload_prompt(doc, NULL); +/* reload all file */ +void on_toolbutton_reload_all_clicked(GtkAction *action, gpointer user_data) +{ + for (guint doc_count = 0; doc_count < documents_array->len; ++doc_count) {
I don’t know if this is relevant, but the [HACKING](https://github.com/geany/geany/blob/master/HACKING) docs say:
Bugs to watch out for [...] Forgetting to check *doc->is_valid* when looping through *documents_array* - instead use *foreach_document()*.
After all documents are reloaded, I end up in a different document than the one I invoked “reload all” in. I think you should remember the initial document and then switch back to it.
vfaronov commented on this pull request.
@@ -354,6 +354,9 @@ static void init_default_kb(void)
"menu_close_all1"); add_kb(group, GEANY_KEYS_FILE_RELOAD, NULL, GDK_r, GEANY_PRIMARY_MOD_MASK, "menu_reloadfile", _("Reload file"), "menu_reload1"); + add_kb(group, GEANY_KEYS_FILE_RELOAD_ALL, NULL, + GDK_r, GDK_MOD1_MASK, "menu_reloadallfile", _("Reload all file"),
This should be “Reload all file**s**”. Similarly in `doc/geany.txt`.
This may be out of scope for your PR, but personally, for [my use cases](https://github.com/geany/geany/pull/1246#issuecomment-298176055), the ideal feature would be “reload all documents that have changed on disk” — to avoid wasting time on reloading documents that have not actually changed.
Agree with @vfaronov that only files that have changed on disk should be reloaded, reloading other files just wastes time and wastes memory keeping the undo buffer for them. And even more importantly only reload files that do not have unsaved changes in the buffer, silently appearing to lose users changes is not acceptable.
@vfaronov I am not sure that one all or nothing dialog is the right way, maybe it should have a checklist of which to reload or otherwise it should be a separate dialog per file.
@attila-v pushed 2 commits.
1b3918f Fix 'Reload all' texts 75e43f8 Use 'foreach_document()' definition instead of using own iteration cycle
@attila-v pushed 1 commit.
67cf855 Switch back to the initial document after all files has reloaded
@vfaronov I have made the fixations you asked before. I examined the code of geany, and I think it's complicated to solve reloading the changed files only. When geany recognizes, that a file has different time mark on the disk than in a tag of struct of document, it immediately write back the new time into struct (document.c, row 3732). So I could not understood the difference when the reloading process is running. The solution is probably storing this information (diff is true/false) in a new tag in the struct, or checking again the time mark of the actual file in the time of reloading process. The first needs more memory allocations, the second needs more runtime. Sorry for my english, I hope it was clear for you what I wanted to tell you. cheers, Attila
@attila-v just use `document_check_disk_status()` to check if the file has changed on disk and use the `changed` field of the document structure to check if the buffer has been changed since it was last reloaded.
@attila-v pushed 1 commit.
0963dbb Check file status before reload it
@attila-v pushed 2 commits.
be27703 Move body of function 'reload all' to the source of the document 06762a2 Add new button to the 'reload' message bar & refact handle of buttons
@elextr thank you for your suggestions. I had a little time, and (I think) I ended and fixed this feature. I put a new button to the reload message to obtain well working feature. I hope you enjoy it.
@attila-v pushed 1 commit.
592a53a Change evaluation order
@attila-v Thank you for your work! I will try running Geany with this change to see how well it works for me.
So far I see a couple problems.
The first problem is that you still silently lose unsaved changes (in files that have diverged from disk).
The second problem is an assertion error. I can reproduce it as follows:
1. Open some file in Geany. 2. Delete it from disk. 3. Switch to Geany. At the top of the document, Geany shows an orange info bar that says: “File ... was not found on disk! Try to resave the file?”
With your change, when this orange info bar appears, I see the following in the console:
GtkWarning: IA__gtk_info_bar_add_button: assertion 'button_text != NULL' failed
Without your change, there is no such warning.
@vfaronov: Thank you for your reflections! You can solve the first problem, if you are checking the `keep_edit_history_on_reload` box in `Preferences - Various Preferences` menu. The simple reload is working in that way too, and I think this is a base behavior in Geany (or I did not understand the problem exactly). I see the second problem soon.
@attila-v As I said before, I think this can be a problem even when `keep_edit_history_on_reload` is enabled. Normal reload works per-document, so I know exactly which files have been reloaded, so I can go and undo there. But with reload-all, how do I know where to undo?
Perhaps a minimal fix would be to note such files (reloaded despite unsaved changes) in the status bar, so I could see them all in the “Status” pane.
@attila-v pushed 1 commit.
b2f080d Fix gtk assertion
@attila-v pushed 1 commit.
1e11eb0 Move button initializer into condition
@attila-v pushed 1 commit.
3a73276 Add status message if reloaded file was unsaved
@vfaronov I solved the gtk assertion. The problem was, that I fitfully made buttons from original version. Thank you for your detection. And I also put a message into status bar when unsaved file has reloaded. I hope you thought so.
@attila-v pushed 1 commit.
27cba28 Check if try to reload the untitled file
I have been running with this change for some time. So far it seems to work well.
(Just reporting my experience; the PR still needs a review by maintainers.)
I agree it should nit reload unsaved files, at least by default. Is this implemented?
It is working like the simple reload function: if the focus is on the unsaved document, then both functions reload it (and send message to the status); but if the focus is on the other document, then does not happen anything with unsaved document. When unsaved document reloaded, you can undo it to the unsaved status of course (if the 'keep_edit_history_on_reload' box is checked in the Preferences).
Closed #1471.
github-comments@lists.geany.org