api_misc.cpp (1813B)
1 /* ReaPack: Package manager for REAPER 2 * Copyright (C) 2015-2025 Christian Fillion 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "api.hpp" 19 #include "api_helper.hpp" 20 21 #include "browser.hpp" 22 #include "reapack.hpp" 23 24 DEFINE_API(void, BrowsePackages, ((const char*, filter)), 25 R"(Opens the package browser with the given filter string.)", 26 { 27 if(Browser *browser = g_reapack->browsePackages()) 28 browser->setFilter(filter); 29 }); 30 31 DEFINE_API(int, CompareVersions, ((const char*, ver1))((const char*, ver2)) 32 ((char*, errorOut))((int, errorOut_sz)), 33 R"(Returns 0 if both versions are equal, a positive value if ver1 is higher than ver2 and a negative value otherwise.)", 34 { 35 VersionName a, b; 36 std::string error; 37 38 b.tryParse(ver2, &error); 39 a.tryParse(ver1, &error); 40 41 if(errorOut) 42 snprintf(errorOut, errorOut_sz, "%s", error.c_str()); 43 44 return a.compare(b); 45 }); 46 47 DEFINE_API(void, ProcessQueue, ((bool, refreshUI)), 48 R"(Run pending operations and save the configuration file. If refreshUI is true the browser and manager windows are guaranteed to be refreshed (otherwise it depends on which operations are in the queue).)", 49 { 50 g_reapack->commitConfig(refreshUI); 51 });