[SCM] Development for GoFind! branch, master, updated. 0057c0d02145dee53c9331f1ca40a9505e2649d0
Miriam Ruiz
miriam at debian.org
Wed May 6 16:41:49 UTC 2009
The following commit has been merged in the master branch:
commit 0057c0d02145dee53c9331f1ca40a9505e2649d0
Author: Miriam Ruiz <miriam at debian.org>
Date: Wed May 6 18:48:59 2009 +0200
Simplify HTML package description subsystem
diff --git a/fltk/pkgbrowser.cpp b/fltk/pkgbrowser.cpp
index a76955d..42c9fa6 100644
--- a/fltk/pkgbrowser.cpp
+++ b/fltk/pkgbrowser.cpp
@@ -152,19 +152,20 @@ void PackageBrowser::item_select(void *p, int s)
if (img) ui.Screenshot(img);
- std::string pkg_desc;
+ std::string html_short, html_long;
+ if (!pkgdata.GetPkgHTMLDesc(rec.package(), html_short, html_long))
+ {
+ html_short.erase();
+ PackageData::AddTextAsHTML(rec.shortDescription(), html_short);
+ html_long.erase();
+ PackageData::AddTextAsHTML(rec.longDescription(), html_long);
+ }
+ std::string pkg_desc;
pkg_desc = std::string ("<center><h1><a href=\"pkg:") + rec.package() + "\">" + rec.package() +
"</a></h1></center><br />";
+ pkg_desc += std::string("<center>") + html_short + "</center><hr /><p>" + html_long;
- std::string shortdesc, htmldesc;
- if (pkgdata.GetPackageHTMLDesc(rec.package(), shortdesc, htmldesc))
- {
- pkg_desc += std::string("<center>") + shortdesc + "</center><hr /><p>" + htmldesc;
- } else {
- pkg_desc += std::string("<center>") + rec.shortDescription() + "</center><hr /><p>";
- PackageData::Text2HTML(rec.longDescription(), pkg_desc);
- }
ui.InfoView->value(pkg_desc.c_str());
static int widths[] = { 150, 0 }; // widths for each column
diff --git a/gui_fltk.cpp b/gui_fltk.cpp
index 56fc7c7..a014757 100644
--- a/gui_fltk.cpp
+++ b/gui_fltk.cpp
@@ -156,7 +156,7 @@ static void UpdateUILists(GamesUI& ui)
std::string desc;
std::string shortdesc;
- if (pkgdata.GetPackageShortDesc(rec.package(), shortdesc))
+ if (pkgdata.GetPkgShortDesc(rec.package(), shortdesc))
{
desc = std::string(fmtstr) + rec.package() + "\t" +
std::string(fmtstr) + shortdesc;
diff --git a/pkgdata.cpp b/pkgdata.cpp
index bd35ebf..a4eb595 100644
--- a/pkgdata.cpp
+++ b/pkgdata.cpp
@@ -102,7 +102,7 @@ bool PackageData::AppTemplate(const char *id)
static const char legalchars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz at _?+-,.~/%&=:*#";
-void PackageData::Text2HTML(const std::string &in_text, std::string &out_html)
+void PackageData::AddTextAsHTML(const std::string &in_text, std::string &out_html)
{
const char *text = in_text.c_str();
const char *src = text;
@@ -155,7 +155,7 @@ void PackageData::Text2HTML(const std::string &in_text, std::string &out_html)
}
}
-bool PackageData::GetPackageShortDesc(const std::string &pkgname, std::string &shortdesc)
+bool PackageData::GetPkgShortDesc(const std::string &pkgname, std::string &shortdesc)
{
if (!apt_helper || !apt_helper->IsInit()) return false;
AptHelper::PackageInfo info;
@@ -165,7 +165,16 @@ bool PackageData::GetPackageShortDesc(const std::string &pkgname, std::string &s
return true;
}
-bool PackageData::GetPackageHTMLDesc(const std::string &pkgname, std::string &shortdesc, std::string &html)
+bool PackageData::GetPkgHTMLShortDesc(const std::string &pkgname, std::string &shortdesc)
+{
+ std::string shdesc;
+ if (!GetPkgShortDesc(pkgname, shdesc))
+ return false;
+
+ return true;
+}
+
+bool PackageData::GetPkgHTMLDesc(const std::string &pkgname, std::string &html_short, std::string &html_long)
{
if (!apt_helper || !apt_helper->IsInit()) return false;
@@ -177,8 +186,11 @@ bool PackageData::GetPackageHTMLDesc(const std::string &pkgname, std::string &sh
<< ( (strcmp(info.LanguageCode.c_str(),"") != 0) ? "-" : "" ) << info.LanguageCode
<< ": " << info.ShortDescription << std::endl << info.LongDescription << std::endl;
- shortdesc = info.ShortDescription;
- Text2HTML(info.LongDescription, html);
+ html_short.erase();
+ AddTextAsHTML(info.ShortDescription, html_short);
+
+ html_long.erase();
+ AddTextAsHTML(info.LongDescription, html_long);
return true;
}
diff --git a/pkgdata.h b/pkgdata.h
index a174122..ea229ff 100644
--- a/pkgdata.h
+++ b/pkgdata.h
@@ -43,14 +43,15 @@ class PackageData : public Engine
bool AppTemplate(const char *id);
- bool GetPackageShortDesc(const std::string &pkgname, std::string &shortdesc);
- bool GetPackageHTMLDesc(const std::string &pkgname, std::string &shortdesc, std::string &html);
+ bool GetPkgShortDesc(const std::string &pkgname, std::string &shortdesc);
+ bool GetPkgHTMLShortDesc(const std::string &pkgname, std::string &shortdesc);
+ bool GetPkgHTMLDesc(const std::string &pkgname, std::string &html_short, std::string &html_long);
char *TagString(const Tag& tag);
char *PackageString(const std::string& name);
void PrintResults();
- static void Text2HTML(const std::string &in_text, std::string &out_html);
+ static void AddTextAsHTML(const std::string &in_text, std::string &out_html);
PackageFilter &GetPackageFilter()
{
--
Development for GoFind!
More information about the Pkg-games-commits
mailing list