reapack

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

commit 99b0811d06608f59c54df8e1abc711e8ec69769a
parent a0bddc7f4c715688c3cbdc6e1cb03cb5a10aef1a
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue,  1 Mar 2016 19:54:04 -0500

enhance behavior of the "Install this repository" button

Diffstat:
Msrc/about.cpp | 9++++-----
Msrc/about.hpp | 2+-
Msrc/main.cpp | 2+-
Msrc/manager.cpp | 19+------------------
Msrc/manager.hpp | 1-
Msrc/reapack.cpp | 37++++++++++++++++++++++++++++++++-----
Msrc/reapack.hpp | 3++-
Msrc/resource.hpp | 2+-
Msrc/resource.rc | 2+-
9 files changed, 43 insertions(+), 34 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -105,8 +105,8 @@ void About::onCommand(const int id) case IDC_DONATE: selectLink(id, m_donationLinks); break; - case IDC_ENABLE: - close(EnableResult); + case IDC_INSTALL: + close(InstallResult); break; case ACTION_HISTORY: packageHistory(); @@ -178,9 +178,6 @@ void About::populate() if(m_donationLinks.empty()) hide(getControl(IDC_DONATE)); - if(m_remote->isEnabled()) - hide(getControl(IDC_ENABLE)); - string aboutText = m_index->aboutText(); if(m_index->name() == "ReaPack") { @@ -279,6 +276,8 @@ void About::updateInstalledFiles() stream << path.join() << "\r\n"; SetWindowText(m_installedFiles, make_autostring(stream.str()).c_str()); + + hide(getControl(IDC_INSTALL)); } } diff --git a/src/about.hpp b/src/about.hpp @@ -35,7 +35,7 @@ struct Link; class About : public Dialog { public: - enum { EnableResult = 100 }; + enum { InstallResult = 100 }; About(const Remote *); ~About(); diff --git a/src/main.cpp b/src/main.cpp @@ -162,7 +162,7 @@ extern "C" REAPER_PLUGIN_DLL_EXPORT int REAPER_PLUGIN_ENTRYPOINT( reapack->setupAction("REAPACK_MANAGE", "ReaPack: Manage repositories...", &reapack->configAction, bind(&ReaPack::manageRemotes, reapack)); - reapack->setupAction("REAPACK_ABOUT", bind(&ReaPack::about, reapack)); + reapack->setupAction("REAPACK_ABOUT", bind(&ReaPack::aboutSelf, reapack)); plugin_register("hookcommand", (void *)commandHook); plugin_register("hookcustommenu", (void *)menuHook); diff --git a/src/manager.cpp b/src/manager.cpp @@ -195,24 +195,7 @@ void Manager::uninstall() void Manager::about() { - Remote remote = currentRemote(); - - if(remote.isNull()) - return; - - // show the pending enable state changes as if they were already applied - remote.setEnabled(isRemoteEnabled(remote)); - - m_reapack->requireIndex(remote, bind(&Manager::showAbout, this, remote)); -} - -void Manager::showAbout(const Remote &remote) -{ - switch(Dialog::Show<About>(instance(), handle(), &remote)) { - case About::EnableResult: - setRemoteEnabled(true); - break; - } + m_reapack->about(currentRemote(), handle()); } bool Manager::confirm() const diff --git a/src/manager.hpp b/src/manager.hpp @@ -47,7 +47,6 @@ private: bool isRemoteEnabled(const Remote &) const; void uninstall(); void about(); - void showAbout(const Remote &); bool confirm() const; void apply(); diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -153,13 +153,28 @@ void ReaPack::synchronizeAll() void ReaPack::enable(Remote remote) { remote.setEnabled(true); - m_config->remotes()->add(remote); - if(!hitchhikeTransaction()) + if(!hitchhikeTransaction()) { + m_config->remotes()->add(remote); + + if(m_manager) + m_manager->refresh(); + return; + } m_transaction->registerAll(remote); m_transaction->synchronize(remote, false); + + m_transaction->onFinish([=] { + if(m_transaction->isCancelled()) + return; + + m_config->remotes()->add(remote); + + if(m_manager) + m_manager->refresh(); + }); } void ReaPack::disable(Remote remote) @@ -289,11 +304,23 @@ void ReaPack::manageRemotes() }); } -void ReaPack::about() +void ReaPack::aboutSelf() +{ + about(m_config->remotes()->get("ReaPack"), m_mainWindow); +} + +void ReaPack::about(const Remote &remote, HWND parent) { - const Remote &remote = m_config->remotes()->get("ReaPack"); + if(remote.isNull()) + return; + requireIndex(remote, [=] { - Dialog::Show<About>(m_instance, m_mainWindow, &remote); + const auto ret = Dialog::Show<About>(m_instance, parent, &remote); + + if(ret != About::InstallResult) + return; + + enable(remote); }); } diff --git a/src/reapack.hpp b/src/reapack.hpp @@ -59,7 +59,8 @@ public: void importRemote(); void import(const Remote &); void manageRemotes(); - void about(); + void aboutSelf(); + void about(const Remote &, HWND parent); void runTasks(); diff --git a/src/resource.hpp b/src/resource.hpp @@ -46,7 +46,7 @@ #define IDC_LIST 212 #define IDC_IMPORT 213 #define IDC_TABS 214 -#define IDC_ENABLE 215 +#define IDC_INSTALL 215 #define IDC_WEBSITE 216 #define IDC_DONATE 217 #define IDC_ABOUT 218 diff --git a/src/resource.rc b/src/resource.rc @@ -58,7 +58,7 @@ BEGIN WS_VSCROLL | ES_MULTILINE | ES_READONLY | NOT WS_TABSTOP PUSHBUTTON "&Website", IDC_WEBSITE, 5, 250, 45, 14 PUSHBUTTON "&Donate...", IDC_DONATE, 54, 250, 45, 14 - PUSHBUTTON "&Enable this repository!", IDC_ENABLE, 285, 250, 120, 14 + PUSHBUTTON "&Install this repository", IDC_INSTALL, 285, 250, 120, 14 DEFPUSHBUTTON "&Close", IDOK, 409, 250, 45, 14 END