reapack

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

commit 22aca8e7bd373f02a9df827a8bf8e5f76f719726
parent 74b03cf002a114f1fcfbc7b9e81017298e4c79f0
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Mon,  6 Jun 2016 18:27:14 -0400

browser: don't uninstall packages from protected repositories

Diffstat:
Msrc/browser.cpp | 13++++++++-----
Msrc/browser.hpp | 1+
Msrc/reapack.cpp | 8++++----
Msrc/reapack.hpp | 2++
4 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/src/browser.cpp b/src/browser.cpp @@ -236,7 +236,6 @@ void Browser::fillMenu(Menu &menu) { const Entry *entry = getEntry(m_currentIndex); - if(m_list->selectionSize() > 1) { menu.addAction(AUTO_STR("&Install/update selection"), ACTION_LATEST_ALL); menu.addAction(AUTO_STR("&Reinstall selection"), ACTION_REINSTALL_ALL); @@ -312,10 +311,9 @@ void Browser::fillMenu(Menu &menu) if(entry->pin.value_or(entry->regEntry.pinned)) menu.check(pinIndex); - const UINT uninstallIndex = menu.addAction(AUTO_STR("&Uninstall"), ACTION_UNINSTALL); - if(!entry->test(InstalledFlag)) + if(!entry->test(InstalledFlag) || getRemote(*entry).isProtected()) menu.disable(uninstallIndex); else if(entry->target && *entry->target == nullptr) menu.check(uninstallIndex); @@ -684,6 +682,11 @@ string Browser::getValue(const Column col, const Entry &entry) const return {}; // for MSVC } +Remote Browser::getRemote(const Entry &entry) const +{ + return m_reapack->remote(getValue(RemoteColumn, entry)); +} + bool Browser::match(const Entry &entry) const { switch(currentTab()) { @@ -751,7 +754,7 @@ void Browser::contents(const int index) void Browser::about(const int index) { if(const Entry *entry = getEntry(index)) - m_reapack->about(getValue(RemoteColumn, *entry), handle()); + m_reapack->about(getRemote(*entry), handle()); } void Browser::installLatest(const int index, const bool toggle) @@ -793,7 +796,7 @@ void Browser::uninstall(const int index, const bool toggle) { const Entry *entry = getEntry(index); - if(entry && entry->test(InstalledFlag)) + if(entry && entry->test(InstalledFlag) && !getRemote(*entry).isProtected()) setTarget(index, nullptr, toggle); } diff --git a/src/browser.hpp b/src/browser.hpp @@ -107,6 +107,7 @@ private: std::string getValue(Column, const Entry &entry) const; ListView::Row makeRow(const Entry &) const; Entry *getEntry(int); + Remote getRemote(const Entry &) const; void updateDisplayLabel(); void displayButton(); void actionsButton(); diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -296,14 +296,14 @@ void ReaPack::manageRemotes() }); } -void ReaPack::aboutSelf() +Remote ReaPack::remote(const string &name) const { - about("ReaPack", m_mainWindow); + return m_config->remotes()->get(name); } -void ReaPack::about(const string &remoteName, HWND parent) +void ReaPack::aboutSelf() { - about(m_config->remotes()->get(remoteName), parent); + about(remote("ReaPack"), m_mainWindow); } void ReaPack::about(const Remote &remote, HWND parent) diff --git a/src/reapack.hpp b/src/reapack.hpp @@ -79,6 +79,8 @@ public: void refreshManager(); void refreshBrowser(); + Remote remote(const std::string &name) const; + void fetchIndex(const Remote &remote, const IndexCallback &, HWND parent, bool stale = false); void fetchIndexes(const std::vector<Remote> &,