reapack

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

commit 4f27bed8b0b9b36262ae5ccc20f35a6879da62cb
parent f75c89c1282b9d105c1695a3df1a17371a8efa1a
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Thu, 31 Dec 2015 15:13:13 -0500

implement remote list display & import button of the config dialog

Diffstat:
Mmacosx.tup | 2+-
Msrc/dialog.hpp | 6+++---
Msrc/manager.cpp | 28++++++++++++++++++++++------
Msrc/manager.hpp | 5++++-
Msrc/reapack.cpp | 3++-
Msrc/reapack.hpp | 2++
Msrc/resource.hpp | 12++++++------
Msrc/resource.rc | 11++++++-----
8 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/macosx.tup b/macosx.tup @@ -12,7 +12,7 @@ CXXFLAGS += -arch @(OSXARCH) WDLFLAGS := -std=c++98 -w SWELL := $(WDL)/swell -WDLSOURCE += $(SWELL)/swell.cpp $(SWELL)/swell-ini.cpp +WDLSOURCE += $(SWELL)/swell.cpp $(SWELL)/swell-ini.cpp $(SWELL)/swell-miscdlg.mm WDLSOURCE += $(SWELL)/swell-gdi.mm $(SWELL)/swell-kb.mm $(SWELL)/swell-menu.mm WDLSOURCE += $(SWELL)/swell-misc.mm $(SWELL)/swell-dlg.mm $(SWELL)/swell-wnd.mm diff --git a/src/dialog.hpp b/src/dialog.hpp @@ -33,10 +33,10 @@ public: Modal, }; - template<class T> - static T *Create(REAPER_PLUGIN_HINSTANCE instance, HWND parent) + template<class T, class... Args> + static T *Create(REAPER_PLUGIN_HINSTANCE instance, HWND parent, Args&&... args) { - Dialog *dlg = new T(); + Dialog *dlg = new T(args...); dlg->init(instance, parent, Dialog::Modeless); return dynamic_cast<T *>(dlg); diff --git a/src/manager.cpp b/src/manager.cpp @@ -17,14 +17,16 @@ #include "manager.hpp" +#include "config.hpp" #include "encoding.hpp" +#include "reapack.hpp" #include "resource.hpp" const auto_char *NAME = AUTO_STR("Name"); const auto_char *URL = AUTO_STR("URL"); -Manager::Manager() - : Dialog(IDD_CONFIG_DIALOG), m_list(0) +Manager::Manager(ReaPack *reapack) + : Dialog(IDD_CONFIG_DIALOG), m_reapack(reapack), m_list(0) { } @@ -36,14 +38,22 @@ Manager::~Manager() void Manager::onInit() { m_list = new ListView({ - {AUTO_STR("Name"), 130}, - {AUTO_STR("URL"), 350}, + {AUTO_STR("Name"), 100}, + {AUTO_STR("URL"), 360}, + {AUTO_STR("State"), 60}, }, getItem(IDC_LIST)); } void Manager::onCommand(WPARAM wParam, LPARAM) { switch(LOWORD(wParam)) { + case IDC_IMPORT: + m_reapack->importRemote(); + break; + case IDC_UNINSTALL: + MessageBox(handle(), AUTO_STR("Not Implemented"), + AUTO_STR("Uninstall"), MB_OK); + break; case IDOK: apply(); case IDCANCEL: @@ -55,8 +65,14 @@ void Manager::onCommand(WPARAM wParam, LPARAM) void Manager::refresh() { m_list->clear(); - m_list->addRow({AUTO_STR("Hello"), AUTO_STR("http://hello.com/index.xml")}); - m_list->addRow({AUTO_STR("World"), AUTO_STR("http://world.com/index.xml")}); + + const RemoteMap remotes = m_reapack->config()->remotes(); + for(auto it = remotes.begin(); it != remotes.end(); it++) { + const auto_string &name = make_autostring(it->first); + const auto_string &url = make_autostring(it->second); + + m_list->addRow({name.c_str(), url.c_str(), AUTO_STR("Enabled")}); + } } void Manager::apply() diff --git a/src/manager.hpp b/src/manager.hpp @@ -22,9 +22,11 @@ #include "listview.hpp" +class ReaPack; + class Manager : public Dialog { public: - Manager(); + Manager(ReaPack *); ~Manager(); void refresh(); @@ -36,6 +38,7 @@ protected: private: void apply(); + ReaPack *m_reapack; ListView *m_list; }; diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -46,7 +46,7 @@ void ReaPack::init(REAPER_PLUGIN_HINSTANCE instance, reaper_plugin_info_t *rec) m_config->read(m_resourcePath + "reapack.ini"); m_progress = Dialog::Create<Progress>(m_instance, m_mainWindow); - m_manager = Dialog::Create<Manager>(m_instance, m_mainWindow); + m_manager = Dialog::Create<Manager>(m_instance, m_mainWindow, this); } void ReaPack::cleanup() @@ -57,6 +57,7 @@ void ReaPack::cleanup() delete m_config; Dialog::Destroy(m_progress); + Dialog::Destroy(m_manager); } int ReaPack::setupAction(const char *name, const ActionCallback &callback) diff --git a/src/reapack.hpp b/src/reapack.hpp @@ -50,6 +50,8 @@ public: void importRemote(); void manageRemotes(); + Config *config() const { return m_config; } + private: Transaction *createTransaction(); diff --git a/src/resource.hpp b/src/resource.hpp @@ -33,11 +33,11 @@ #define IDD_REPORT_DIALOG 101 #define IDD_CONFIG_DIALOG 102 -#define IDC_LABEL 200 -#define IDC_PROGRESS 201 -#define IDC_REPORT 202 -#define IDC_LIST 203 -#define IDC_IMPORT 204 -#define IDC_REMOVE 205 +#define IDC_LABEL 200 +#define IDC_PROGRESS 201 +#define IDC_REPORT 202 +#define IDC_LIST 203 +#define IDC_IMPORT 204 +#define IDC_UNINSTALL 205 #endif diff --git a/src/resource.rc b/src/resource.rc @@ -24,15 +24,16 @@ BEGIN DEFPUSHBUTTON "OK", IDOK, 105, 220, 50, 14 END -IDD_CONFIG_DIALOG DIALOGEX 0, 0, 300, 180 +IDD_CONFIG_DIALOG DIALOGEX 0, 0, 330, 180 STYLE DIALOG_STYLE FONT DIALOG_FONT CAPTION "ReaPack Configuration" BEGIN - LTEXT "Enabled remotes:", IDC_LABEL, 5, 5, 290, 10 + LTEXT "Remote repositories:", IDC_LABEL, 5, 5, 320, 10 CONTROL "", IDC_LIST, WC_LISTVIEW, LVS_REPORT | LVS_SINGLESEL | - LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, 5, 18, 290, 136 + LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, 5, 18, 320, 136 PUSHBUTTON "Import", IDC_IMPORT, 5, 160, 40, 14 - PUSHBUTTON "Remove", IDC_REMOVE, 48, 160, 40, 14 - DEFPUSHBUTTON "Close", IDOK, 244, 160, 50, 14 + PUSHBUTTON "Uninstall", IDC_UNINSTALL, 48, 160, 40, 14 + DEFPUSHBUTTON "OK", IDOK, 240, 160, 40, 14 + PUSHBUTTON "Cancel", IDCANCEL, 284, 160, 40, 14 END