reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit eba271280338864391feaf44c2cbf961d6215ea5
parent 74bfe0b73792a286ea93de7623ae56bae2e7e3e0
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri, 15 Sep 2017 16:17:17 -0400

api: add ReaPack_Commit(bool refreshUI) function

This replaces AddSetRepository's commit parameter

Diffstat:
Msrc/api.hpp | 1+
Msrc/api_misc.cpp | 6++++++
Msrc/api_repo.cpp | 8++------
Msrc/main.cpp | 1+
Msrc/reapack.cpp | 14+++++++++-----
Msrc/reapack.hpp | 2+-
6 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/api.hpp b/src/api.hpp @@ -43,6 +43,7 @@ private: namespace API { // api_misc.cpp extern APIFunc BrowsePackages; + extern APIFunc Commit; extern APIFunc CompareVersions; // api_package.cpp diff --git a/src/api_misc.cpp b/src/api_misc.cpp @@ -30,6 +30,12 @@ R"(Opens the package browser with the given filter string.)", browser->setFilter(filter); }); +DEFINE_API(void, Commit, ((bool, refreshUI)), +R"(Run pending tasks and save the configuration file. If refreshUI is true the browser and manager windows are guaranteed to be refreshed (otherwise it depends on which tasks are performed).)", +{ + g_reapack->commitConfig(refreshUI); +}); + DEFINE_API(int, CompareVersions, ((const char*, ver1))((const char*, ver2)) ((char*, errorOut))((int, errorOut_sz)), R"(Returns 0 if both versions are equal, a positive value if ver1 is higher than ver2 and a negative value otherwise.)", diff --git a/src/api_repo.cpp b/src/api_repo.cpp @@ -40,9 +40,8 @@ The repository index is downloaded asynchronously if the cached copy doesn't exi }); DEFINE_API(bool, AddSetRepository, ((const char*, name))((const char*, url)) - ((bool, enable))((int, autoInstall))((bool, commit)) - ((char*, errorOut))((int, errorOut_sz)), -R"(Add or modify a repository. Set url to nullptr (or empty string in Lua) to keep the existing URL. Set commit to true for the last call to process the new list and update the GUI. + ((bool, enable))((int, autoInstall))((char*, errorOut))((int, errorOut_sz)), +R"(Add or modify a repository. Set url to nullptr (or empty string in Lua) to keep the existing URL. Call <a href="#ReaPack_Commit">ReaPack_Commit(true)</a> when done to process the new list and update the GUI. autoInstall: usually set to 2 (obey user setting).)", { @@ -66,9 +65,6 @@ autoInstall: usually set to 2 (obey user setting).)", return false; } - if(commit) - g_reapack->commitConfig(); - return true; }); diff --git a/src/main.cpp b/src/main.cpp @@ -155,6 +155,7 @@ static void setupAPI() g_reapack->setupAPI(&API::AboutRepository); g_reapack->setupAPI(&API::AddSetRepository); g_reapack->setupAPI(&API::BrowsePackages); + g_reapack->setupAPI(&API::Commit); g_reapack->setupAPI(&API::CompareVersions); g_reapack->setupAPI(&API::EnumOwnedFiles); g_reapack->setupAPI(&API::FreeEntry); diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -352,17 +352,21 @@ void ReaPack::teardownTransaction() refreshBrowser(); } -void ReaPack::commitConfig() +void ReaPack::commitConfig(bool refresh) { if(m_tx) { - m_tx->receipt()->setIndexChanged(); // force browser refresh - m_tx->onFinish(bind(&ReaPack::refreshManager, this)); + if(refresh) { + m_tx->receipt()->setIndexChanged(); // force browser refresh + m_tx->onFinish(bind(&ReaPack::refreshManager, this)); + } m_tx->onFinish(bind(&Config::write, m_config)); m_tx->runTasks(); } else { - refreshManager(); - refreshBrowser(); + if(refresh) { + refreshManager(); + refreshBrowser(); + } m_config->write(); } } diff --git a/src/reapack.hpp b/src/reapack.hpp @@ -80,7 +80,7 @@ public: Remote remote(const std::string &name) const; Transaction *setupTransaction(); - void commitConfig(); + void commitConfig(bool refresh = true); Config *config() const { return m_config; } private: