From 1e9ba7f26caddfcee753422bea618fe3eac85ab7 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 20 Dec 2009 16:20:58 +0000 Subject: [PATCH] Patch by Matt Madia with small modifications by myself: Read and display the "SourceURL" fields in optional package descriptions. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34725 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/aboutsystem/AboutSystem.cpp | 29 +++++++++++++++++-- src/apps/aboutsystem/Utilities.cpp | 42 ++++++++++++++++++++++++++++ src/apps/aboutsystem/Utilities.h | 7 +++++ 3 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/apps/aboutsystem/AboutSystem.cpp b/src/apps/aboutsystem/AboutSystem.cpp index 9bf78ef0ad..7539918914 100644 --- a/src/apps/aboutsystem/AboutSystem.cpp +++ b/src/apps/aboutsystem/AboutSystem.cpp @@ -127,6 +127,7 @@ public: void AddCopyrightEntry(const char* name, const char* text, const StringVector& licenses, + const StringVector& sources, const char* url); void AddCopyrightEntry(const char* name, const char* text, const char* url = NULL); @@ -536,13 +537,13 @@ void AboutView::AddCopyrightEntry(const char* name, const char* text, const char* url) { - AddCopyrightEntry(name, text, StringVector(), url); + AddCopyrightEntry(name, text, StringVector(), StringVector(), url); } void AboutView::AddCopyrightEntry(const char* name, const char* text, - const StringVector& licenses, const char* url) + const StringVector& licenses, const StringVector& sources, const char* url) { BFont font(be_bold_font); //font.SetSize(be_bold_font->Size()); @@ -582,6 +583,27 @@ AboutView::AddCopyrightEntry(const char* name, const char* text, fCreditsView->Insert("\n"); } + if (sources.CountStrings() > 0) { + fCreditsView->Insert("Source Code: "); + + for (int32 i = 0; i < sources.CountStrings(); i++) { + const char* source = sources.StringAt(i); + + if (i > 0) + fCreditsView->Insert(", "); + + BString urlName; + BString urlAddress; + parse_named_url(source, urlName, urlAddress); + + fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, + &kLinkBlue); + fCreditsView->InsertHyperText(urlName, new URLAction(urlAddress)); + } + + fCreditsView->Insert("\n"); + } + if (url) { BString urlName; BString urlAddress; @@ -996,6 +1018,7 @@ AboutView::_CreateCreditsView() "Bourne Again Shell.\n" COPYRIGHT_STRING "The Free Software Foundation.", StringVector("GNU LGPL v2.1", "GNU GPL v2", "GNU GPL v3", NULL), + StringVector(), "http://www.gnu.org"); // FreeBSD copyrights @@ -1394,7 +1417,7 @@ AboutView::_AddPackageCreditEntries() text << "\n" << package->CopyrightAt(i); AddCopyrightEntry(package->PackageName(), text.String(), - package->Licenses(), package->URL()); + package->Licenses(), package->Sources(), package->URL()); } } diff --git a/src/apps/aboutsystem/Utilities.cpp b/src/apps/aboutsystem/Utilities.cpp index 8ca61ab7e6..1b4222e93d 100644 --- a/src/apps/aboutsystem/Utilities.cpp +++ b/src/apps/aboutsystem/Utilities.cpp @@ -233,6 +233,7 @@ PackageCredit::PackageCredit(const BMessage& packageDescription) fPackageName = package; fCopyrights.SetTo(packageDescription, "Copyright", COPYRIGHT_STRING); fLicenses.SetTo(packageDescription, "License"); + fSources.SetTo(packageDescription, "SourceURL"); fURL = url; } @@ -242,6 +243,7 @@ PackageCredit::PackageCredit(const PackageCredit& other) fPackageName(other.fPackageName), fCopyrights(other.fCopyrights), fLicenses(other.fLicenses), + fSources(other.fSources), fURL(other.fURL) { } @@ -310,6 +312,25 @@ PackageCredit::SetLicense(const char* license) } +PackageCredit& +PackageCredit::SetSources(const char* source,...) +{ + va_list list; + va_start(list, source); + fSources.SetTo(source, list); + va_end(list); + + return *this; +} + + +PackageCredit& +PackageCredit::SetSource(const char* source) +{ + return SetSources(source, NULL); +} + + PackageCredit& PackageCredit::SetURL(const char* url) { @@ -368,6 +389,27 @@ PackageCredit::LicenseAt(int32 index) const } +const StringVector& +PackageCredit::Sources() const +{ + return fSources; +} + + +int32 +PackageCredit::CountSources() const +{ + return fSources.CountStrings(); +} + + +const char* +PackageCredit::SourceAt(int32 index) const +{ + return fSources.StringAt(index); +} + + const char* PackageCredit::URL() const { diff --git a/src/apps/aboutsystem/Utilities.h b/src/apps/aboutsystem/Utilities.h index 730af51db3..bfa11b7fb2 100644 --- a/src/apps/aboutsystem/Utilities.h +++ b/src/apps/aboutsystem/Utilities.h @@ -69,6 +69,8 @@ public: PackageCredit& SetCopyright(const char* copyright); PackageCredit& SetLicenses(const char* license,...); PackageCredit& SetLicense(const char* license); + PackageCredit& SetSources(const char* source,...); + PackageCredit& SetSource(const char* source); PackageCredit& SetURL(const char* url); const char* PackageName() const; @@ -81,6 +83,10 @@ public: int32 CountLicenses() const; const char* LicenseAt(int32 index) const; + const StringVector& Sources() const; + int32 CountSources() const; + const char* SourceAt(int32 index) const; + const char* URL() const; private: @@ -90,6 +96,7 @@ private: BString fPackageName; StringVector fCopyrights; StringVector fLicenses; + StringVector fSources; BString fURL; };