Ticket #4679: sourceURL-aboutsystem.patch

File sourceURL-aboutsystem.patch, 5.0 KB (added by mmadia, 15 years ago)
  • src/apps/aboutsystem/AboutSystem.cpp

     
    126126            void            AddCopyrightEntry(const char* name,
    127127                                const char* text,
    128128                                const StringVector& licenses,
     129                                const StringVector& sources,
    129130                                const char* url);
    130131            void            AddCopyrightEntry(const char* name,
    131132                                const char* text, const char* url = NULL);
     
    532533
    533534
    534535void
    535 AboutView::AddCopyrightEntry(const char *name, const char *text,
     536AboutView::AddCopyrightEntry(const char *name, const char *text, 
    536537    const char *url)
    537538{
    538     AddCopyrightEntry(name, text, StringVector(), url);
     539    AddCopyrightEntry(name, text, StringVector(), StringVector(), url);
    539540}
    540541
    541542
    542543void
    543544AboutView::AddCopyrightEntry(const char *name, const char *text,
    544     const StringVector& licenses, const char *url)
     545    const StringVector& licenses, const StringVector& sources, const char *url)
    545546{
    546547    BFont font(be_bold_font);
    547548    //font.SetSize(be_bold_font->Size());
     
    577578        fCreditsView->Insert("\n");
    578579    }
    579580
     581    if (sources.CountStrings() > 0) {
     582        if (sources.CountStrings() > 1)
     583            fCreditsView->Insert("Source Code: ");
     584        else
     585            fCreditsView->Insert("Source Code: ");
     586
     587        for (int32 i = 0; i < sources.CountStrings(); i++) {
     588            const char* source = sources.StringAt(i);
     589
     590            if (i > 0)
     591                fCreditsView->Insert(", ");
     592
     593            // TODO : what to do here?
     594            fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue);
     595            fCreditsView->InsertHyperText(source, new URLAction(source));
     596        }
     597
     598        fCreditsView->Insert("\n");
     599    }
     600
    580601    if (url) {
    581602        fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kLinkBlue);
    582603        fCreditsView->InsertHyperText(url, new URLAction(url));
     
    911932        "Bourne Again Shell.\n"
    912933        COPYRIGHT_STRING "The Free Software Foundation.",
    913934        StringVector("GNU LGPL v2.1", "GNU GPL v2", "GNU GPL v3", NULL),
     935        StringVector(),
    914936        "http://www.gnu.org");
    915937
    916938    // FreeBSD copyrights
     
    13031325            text << "\n" << package->CopyrightAt(i);
    13041326
    13051327        AddCopyrightEntry(package->PackageName(), text.String(),
    1306             package->Licenses(), package->URL());
     1328            package->Licenses(), package->Sources(), package->URL());
    13071329    }
    13081330}
    13091331
  • src/apps/aboutsystem/Utilities.h

     
    6767            PackageCredit&      SetCopyright(const char* copyright);
    6868            PackageCredit&      SetLicenses(const char* license,...);
    6969            PackageCredit&      SetLicense(const char* license);
     70            PackageCredit&      SetSources(const char* source,...);
     71            PackageCredit&      SetSource(const char* source);
    7072            PackageCredit&      SetURL(const char* url);
    7173
    7274            const char*         PackageName() const;
     
    7981            int32               CountLicenses() const;
    8082            const char*         LicenseAt(int32 index) const;
    8183
     84            const StringVector& Sources() const;
     85            int32               CountSources() const;
     86            const char*         SourceAt(int32 index) const;
     87
    8288            const char*         URL() const;
    8389
    8490private:
     
    8894            BString             fPackageName;
    8995            StringVector        fCopyrights;
    9096            StringVector        fLicenses;
     97            StringVector        fSources;
    9198            BString             fURL;
    9299};
    93100
  • src/apps/aboutsystem/Utilities.cpp

     
    198198{
    199199    const char* package;
    200200    const char* copyright;
     201    const char* source;
    201202    const char* url;
    202203
    203204    // package and copyright are mandatory
     
    213214    fPackageName = package;
    214215    fCopyrights.SetTo(packageDescription, "Copyright", COPYRIGHT_STRING);
    215216    fLicenses.SetTo(packageDescription, "License");
     217    fSources.SetTo(packageDescription, "SourceURL");
    216218    fURL = url;
    217219}
    218220
     
    222224    fPackageName(other.fPackageName),
    223225    fCopyrights(other.fCopyrights),
    224226    fLicenses(other.fLicenses),
     227    fSources(other.fSources),
    225228    fURL(other.fURL)
    226229{
    227230}
     
    249252
    250253    // Scan the copyrights for year numbers and let the greater one win.
    251254    return _MaxCopyrightYear() > other._MaxCopyrightYear();
     255   
     256    // TODO: Do we prefer credits that provide source code?
    252257}
    253258
    254259
     
    291296
    292297
    293298PackageCredit&
     299PackageCredit::SetSources(const char* source,...)
     300{
     301    va_list list;
     302    va_start(list, source);
     303    fSources.SetTo(source, list);
     304    va_end(list);
     305
     306    return *this;
     307}
     308
     309
     310PackageCredit&
     311PackageCredit::SetSource(const char* source)
     312{
     313    return SetSources(source, NULL);
     314}
     315
     316
     317PackageCredit&
    294318PackageCredit::SetURL(const char* url)
    295319{
    296320    fURL = url;
     
    348372}
    349373
    350374
     375const StringVector&
     376PackageCredit::Sources() const
     377{
     378    return fSources;
     379}
     380
     381
     382int32
     383PackageCredit::CountSources() const
     384{
     385    return fSources.CountStrings();
     386}
     387
     388
    351389const char*
     390PackageCredit::SourceAt(int32 index) const
     391{
     392    return fSources.StringAt(index);
     393}
     394
     395
     396const char*
    352397PackageCredit::URL() const
    353398{
    354399    return fURL.Length() > 0 ? fURL.String() : NULL;