reapack

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

commit ae05b4645224af99f9ff0b53e0a97790e65641dd
parent f8ae8309b0ef49f0bd189004cb6242af0e502383
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue,  6 Jun 2017 18:34:59 -0400

api: add tab parameter to About* functions

Diffstat:
Msrc/about.cpp | 9+++++++++
Msrc/about.hpp | 1+
Msrc/api.cpp | 22+++++++++++++++-------
Msrc/reapack.cpp | 9++++++---
Msrc/reapack.hpp | 2+-
Msrc/tabbar.cpp | 3+++
6 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -236,6 +236,15 @@ void About::setAction(const string &label) show(btn); } +void About::setTab(const int tab) +{ + // FIXME: Remove hard-codded maximum tab count + const int firstTab = 3 - m_tabs->count(); + assert(firstTab >= 0); + if(tab >= firstTab) + m_tabs->setCurrentIndex(tab - firstTab); +} + void About::selectLink(const int ctrl) { const auto &links = m_links[ctrl]; diff --git a/src/about.hpp b/src/about.hpp @@ -50,6 +50,7 @@ public: void setTitle(const std::string &); void setMetadata(const Metadata *, bool substitution = false); void setAction(const std::string &); + void setTab(int tab); ReaPack *reapack() const { return m_reapack; } TabBar *tabs() const { return m_tabs; } diff --git a/src/api.cpp b/src/api.cpp @@ -108,9 +108,11 @@ void APIDef::unregister(const char *key, void *ptr) "APIdef_" API_PREFIX #name, (void *)API_##name::definition, \ } -DEFINE_API(bool, AboutInstalledPackage, ((PackageEntry*, entry)), +DEFINE_API(bool, AboutInstalledPackage, ((PackageEntry*, entry))((int, tab)), R"(Show the about dialog of the given package entry. -The repository index is downloaded asynchronously if the cached copy doesn't exist or is older than one week.)", +The repository index is downloaded asynchronously if the cached copy doesn't exist or is older than one week. + +tab: 0=about (if available), 1=history, 2=contents)", { if(!s_entries.count(entry)) return false; @@ -135,20 +137,26 @@ The repository index is downloaded asynchronously if the cached copy doesn't exi return; const Package *pkg = indexes.front()->find(entryCopy.category, entryCopy.package); - if(pkg) - reapack->about()->setDelegate(make_shared<AboutPackageDelegate>(pkg, entryCopy.version)); + if(!pkg) + return; + + About *about = reapack->about(); + about->setDelegate(make_shared<AboutPackageDelegate>(pkg, entryCopy.version)); + about->setTab(tab); }); tx->runTasks(); return true; }); -DEFINE_API(bool, AboutRepository, ((const char*, repoName)), +DEFINE_API(bool, AboutRepository, ((const char*, repoName))((int, tab)), R"(Show the about dialog of the given repository. Returns true if the repository exists in the user configuration. -The repository index is downloaded asynchronously if the cached copy doesn't exist or is older than one week.)", +The repository index is downloaded asynchronously if the cached copy doesn't exist or is older than one week. + +tab: 0=about (if available), 1=packages, 2=installed files)", { if(const Remote &repo = reapack->remote(repoName)) { - reapack->about(repo); + reapack->about(repo, tab); return true; } diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -230,7 +230,7 @@ Remote ReaPack::remote(const string &name) const return m_config->remotes.get(name); } -void ReaPack::about(const Remote &repo) +void ReaPack::about(const Remote &repo, const int tab) { Transaction *tx = setupTransaction(); if(!tx) @@ -241,8 +241,11 @@ void ReaPack::about(const Remote &repo) tx->fetchIndexes(repos); tx->onFinish([=] { const auto &indexes = tx->getIndexes(repos); - if(!indexes.empty()) - about()->setDelegate(make_shared<AboutIndexDelegate>(indexes.front())); + if(!indexes.empty()) { + About *dlg = about(); + dlg->setDelegate(make_shared<AboutIndexDelegate>(indexes.front())); + dlg->setTab(tab); + } }); tx->runTasks(); } diff --git a/src/reapack.hpp b/src/reapack.hpp @@ -69,7 +69,7 @@ public: void importRemote(); void manageRemotes(); void aboutSelf(); - void about(const Remote &); + void about(const Remote &, int tab = -1); About *about(bool instantiate = true); Browser *browsePackages(); void refreshManager(); diff --git a/src/tabbar.cpp b/src/tabbar.cpp @@ -55,6 +55,9 @@ int TabBar::currentIndex() const void TabBar::setCurrentIndex(const int index) { + if(index < 0 && index >= count()) + return; + TabCtrl_SetCurSel(handle(), index); switchPage(); }