diff options
| author | Matthias Melcher <github@matthiasm.com> | 2026-01-04 20:43:26 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2026-01-04 20:43:34 +0100 |
| commit | 7306b66d99fb529d65ddda1ea8e093454d7005e1 (patch) | |
| tree | 13803f53b2e921985abe54804b8d9131c46b9c3d /fluid/proj/mergeback.cxx | |
| parent | 811a188bbf276841365f2ad4b11197f5820fe571 (diff) | |
Fluid: Add automated MergeBack
Diffstat (limited to 'fluid/proj/mergeback.cxx')
| -rw-r--r-- | fluid/proj/mergeback.cxx | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/fluid/proj/mergeback.cxx b/fluid/proj/mergeback.cxx index d9e5b0136..4ddb86f10 100644 --- a/fluid/proj/mergeback.cxx +++ b/fluid/proj/mergeback.cxx @@ -617,14 +617,24 @@ int Mergeback::merge_back(const std::string &s, const std::string &p, Task task) 0 if MergeBack is not enabled, or the result of the merge_back function. */ -int mergeback_code_files(Project &proj) +int mergeback_code_files(Project &proj, Mergeback::Feedback feedback) { + static bool recursion_lock = false; + if (recursion_lock) return; + recursion_lock = true; + Fluid.flush_text_widgets(); - if (!proj.proj_filename) return 1; + if (!proj.proj_filename) { + recursion_lock = false; + return 1; + } if (!proj.write_mergeback_data) { - fl_message("MergeBack is not enabled for this project.\n" - "Please enable MergeBack in the project settings\n" - "dialog and re-save the project file and the code."); + if (feedback & Mergeback::CHATTY) { + fl_message("MergeBack is not enabled for this project.\n" + "Please enable MergeBack in the project settings\n" + "dialog and re-save the project file and the code."); + } + recursion_lock = false; return 0; } @@ -633,7 +643,7 @@ int mergeback_code_files(Project &proj) #if 1 if (!Fluid.batch_mode) { // Depending on the workflow in interactive mode, an external copy of - // Fluid may have written the source code elswhere (e.g. in a CMake setup). + // Fluid may have written the source code elsewhere (e.g. in a CMake setup). // Fluid tries to keep track of the last write location of a source file // matching a project, and uses that location instead. // TODO: this is not working as expected yet. @@ -656,15 +666,32 @@ int mergeback_code_files(Project &proj) } if (!Fluid.batch_mode) proj.leave_project_dir(); - if (c==0) fl_message("Comparing\n \"%s\"\nto\n \"%s\"\n\n" - "MergeBack found no external modifications\n" - "in the source code.", - code_filename.c_str(), proj_filename.c_str()); - if (c==-2) fl_message("No corresponding source code file found."); + if (feedback & Mergeback::CHATTY) { + if (c==0) fl_message("Comparing\n \"%s\"\nto\n \"%s\"\n\n" + "MergeBack found no external modifications\n" + "in the source code.", + code_filename.c_str(), proj_filename.c_str()); + if (c==-2) fl_message("No corresponding source code file found."); + } + recursion_lock = false; return c; } void mergeback_cb(Fl_Widget *, void *) { - mergeback_code_files(Fluid.proj); + mergeback_code_files(Fluid.proj, Mergeback::CHATTY); +} + +void mergeback_on_load() { + mergeback_code_files(Fluid.proj, Mergeback::QUIET); +} + +static int app_event_handler(int event) { + if (event == FL_APP_ACTIVATE) { + mergeback_code_files(Fluid.proj, Mergeback::QUIET); + } + return 0; } +void start_auto_mergeback() { + Fl::add_handler(app_event_handler); +} |
