reapack

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

commit 5ab2389c8e38507c829924eb7b2780e0afad63f9
parent 7e1628eac5bcd700bdd5bc8cf679bf472b8ca4ee
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Thu,  9 Feb 2017 18:19:14 -0500

manage: UI for import/export offline archive + experimental open/save dialogs

Diffstat:
MTupfile | 2+-
Msrc/manager.cpp | 76+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Msrc/manager.hpp | 5++++-
Msrc/reapack.cpp | 2+-
Msrc/resource.rc | 4++--
5 files changed, 77 insertions(+), 12 deletions(-)

diff --git a/Tupfile b/Tupfile @@ -1,5 +1,5 @@ WDL := vendor/WDL/WDL -WDLSOURCE := $(WDL)/wingui/wndsize.cpp +WDLSOURCE := $(WDL)/wingui/wndsize.cpp $(WDL)/filebrowse.cpp TINYXML := $(WDL)/tinyxml WDLSOURCE += $(TINYXML)/tinyxml.cpp $(TINYXML)/tinystr.cpp diff --git a/src/manager.cpp b/src/manager.cpp @@ -27,13 +27,22 @@ #include "resource.hpp" #include "transaction.hpp" +#include <filebrowse.h> + +static const char *ARCHIVE_FILTER = + "ReaPack Offline Archive (*.ReaPackArchive)\0*.ReaPackArchive\0"; +static const char *ARCHIVE_EXT = "ReaPackArchive"; + using namespace std; -enum { ACTION_ENABLE = 80, ACTION_DISABLE, ACTION_UNINSTALL, ACTION_ABOUT, - ACTION_REFRESH, ACTION_COPYURL, ACTION_SELECT, ACTION_UNSELECT, - ACTION_AUTOINSTALL_GLOBAL, ACTION_AUTOINSTALL_OFF, ACTION_AUTOINSTALL_ON, - ACTION_AUTOINSTALL, ACTION_BLEEDINGEDGE, ACTION_PROMPTOBSOLETE, - ACTION_NETCONFIG, ACTION_RESETCONFIG }; +enum { + ACTION_ENABLE = 80, ACTION_DISABLE, ACTION_UNINSTALL, ACTION_ABOUT, + ACTION_REFRESH, ACTION_COPYURL, ACTION_SELECT, ACTION_UNSELECT, + ACTION_AUTOINSTALL_GLOBAL, ACTION_AUTOINSTALL_OFF, ACTION_AUTOINSTALL_ON, + ACTION_AUTOINSTALL, ACTION_BLEEDINGEDGE, ACTION_PROMPTOBSOLETE, + ACTION_NETCONFIG, ACTION_RESETCONFIG, ACTION_IMPORT_REPO, + ACTION_IMPORT_ARCHIVE, ACTION_EXPORT_ARCHIVE +}; Manager::Manager(ReaPack *reapack) : Dialog(IDD_CONFIG_DIALOG), @@ -88,7 +97,7 @@ void Manager::onCommand(const int id, int) { switch(id) { case IDC_IMPORT: - import(); + importExport(); break; case IDC_BROWSE: launchBrowser(); @@ -120,6 +129,15 @@ void Manager::onCommand(const int id, int) case ACTION_UNINSTALL: uninstall(); break; + case ACTION_IMPORT_REPO: + importRepo(); + break; + case ACTION_IMPORT_ARCHIVE: + importArchive(); + break; + case ACTION_EXPORT_ARCHIVE: + exportArchive(); + break; case ACTION_AUTOINSTALL: toggle(m_autoInstall, m_config->install.autoInstall); break; @@ -446,7 +464,18 @@ void Manager::copyUrl() setClipboard(values); } -bool Manager::import() +void Manager::importExport() +{ + Menu menu; + menu.addAction(AUTO_STR("Import a &repository..."), ACTION_IMPORT_REPO); + menu.addSeparator(); + menu.addAction(AUTO_STR("Import offline archive..."), ACTION_IMPORT_ARCHIVE); + menu.addAction(AUTO_STR("&Export offline archive..."), ACTION_EXPORT_ARCHIVE); + + menu.show(getControl(IDC_IMPORT), handle()); +} + +bool Manager::importRepo() { if(m_importing) // avoid opening the import dialog twice on windows return true; @@ -458,6 +487,39 @@ bool Manager::import() return ret != 0; } +void Manager::importArchive() +{ + const char *title = "Import offline archive"; + + char *path = WDL_ChooseFileForOpen(handle(), title, + Path::prefixRoot(Path::DATA).join().c_str(), + nullptr, ARCHIVE_FILTER, ARCHIVE_EXT, true, false); + + if(!path) + return; + + auto_char msg[255] = {}; + auto_snprintf(msg, auto_size(msg), "%s (%zu)\n", path, string(path).size()); + MessageBox(handle(), msg, AUTO_STR("Import"), MB_OK); +} + +void Manager::exportArchive() +{ + const char *title = "Export offline archive"; + + char path[4096] = {}; + const bool ok = WDL_ChooseFileForSave(handle(), title, + Path::prefixRoot(Path::DATA).join().c_str(), + nullptr, ARCHIVE_FILTER, ARCHIVE_EXT, true, path, sizeof(path)); + + if(!ok) + return; + + auto_char msg[255] = {}; + auto_snprintf(msg, auto_size(msg), "%s (%zu)\n", path, string(path).size()); + MessageBox(handle(), msg, AUTO_STR("Export"), MB_OK); +} + void Manager::launchBrowser() { const auto promptApply = [&] { diff --git a/src/manager.hpp b/src/manager.hpp @@ -39,7 +39,7 @@ public: Manager(ReaPack *); void refresh(); - bool import(); + bool importRepo(); protected: void onInit() override; @@ -71,8 +71,11 @@ private: void about(int index); void copyUrl(); void launchBrowser(); + void importExport(); void options(); void setupNetwork(); + void importArchive(); + void exportArchive(); void setChange(int); bool confirm() const; diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -199,7 +199,7 @@ void ReaPack::importRemote() manageRemotes(); - if(!m_manager->import() && autoClose) + if(!m_manager->importRepo() && autoClose) m_manager->close(); } diff --git a/src/resource.rc b/src/resource.rc @@ -35,8 +35,8 @@ BEGIN CONTROL "", IDC_LIST, WC_LISTVIEW, LVS_REPORT | LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, 5, 18, 360, 170 PUSHBUTTON "&Browse packages", IDC_BROWSE, 5, 191, 75, 14 - PUSHBUTTON "&Import...", IDC_IMPORT, 83, 191, 45, 14 - PUSHBUTTON "&Options...", IDC_OPTIONS, 131, 191, 45, 14 + PUSHBUTTON "&Import/export...", IDC_IMPORT, 83, 191, 60, 14 + PUSHBUTTON "&Options...", IDC_OPTIONS, 146, 191, 45, 14 DEFPUSHBUTTON "&OK", IDOK, 238, 191, 40, 14 PUSHBUTTON "&Cancel", IDCANCEL, 281, 191, 40, 14 PUSHBUTTON "&Apply", IDAPPLY, 324, 191, 40, 14