As discussed in #1180.
This change adds two new functions: document_rename_file_and_save()
, and document_rename_and_save()
. document_rename_file_and_save()
is kind of like the combination of document_rename_file()
and document_save_file_as()
, and is strictly about renaming the associated file, and doing the stuff necessary before and after the file has been renamed, like disabling file monitoring, and putting it back if a rename fails, saving/restoring file disk status, etc.
document_rename_and_save()
OTOH is more of a wrapper, and is about renaming the document itself. It doesn't require the document to have an associated file to it (i.e. doc->real_path != NULL
). But if there is an associated file, the file is also renamed, i.e., document_rename_file_and_save()
is called. The algorithm to check if the file has to be overwritten is also contained in it. This function should be adaptable to other implementations like in-place renaming.
In dialogs.c
, stuff about resetting doc->tm_file
and calling build_menu_update()
has been moved to document_save_file_as()
, since both are essentially needed to be done by anyone that calls the function. It helps significantly simplify the two new functions and the functions in dialogs.c
.
The function save_as_dialog_handle_response()
has been refactored, and is now simpler since the "overwrite file?" prompt has been moved to document_rename_and_save()
, and since it can now directly call document_rename_and_save()
and document_save_file_as()
. dialogs_show_save_as()
now also directly calls document_save_file_as()
if interface_prefs.use_native_windows_dialogs == TRUE
. handle_save_as()
is no longer needed, so it's been removed.
https://github.com/geany/geany/pull/1194
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.