aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-23 11:50:42 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-23 11:50:42 +0000
commit37bd5dcd1935f59865a05b1f46edd9e93aca4f21 (patch)
treedffe683610beda09b085b67b692ea0b11c09ee5f
parentdfdece66f1187b32f70336f22a333b55b40fc70f (diff)
downloadpaludis-37bd5dcd1935f59865a05b1f46edd9e93aca4f21.tar.gz
paludis-37bd5dcd1935f59865a05b1f46edd9e93aca4f21.tar.xz
Display more information about packages
-rw-r--r--src/gtkpaludis/Makefile.am9
-rw-r--r--src/gtkpaludis/package_overview.cc56
-rw-r--r--src/gtkpaludis/packages_list.cc39
-rw-r--r--src/gtkpaludis/packages_list.sr6
4 files changed, 87 insertions, 23 deletions
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 8eddc75..e329c5e 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -43,9 +43,18 @@ gtkpaludis_LDADD = \
$(GTKDEPS_LIBS) \
$(DYNAMIC_LD_LIBS)
+BUILT_SOURCES = packages_list-sr.hh packages_list-sr.cc
+
endif
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
MAINTAINERCLEANFILES = Makefile.in
+DISTCLEANFILES = packages_list-sr.hh packages_list-sr.cc
+EXTRA_DIST = packages_list.sr
+
+packages_list-sr.hh : packages_list.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/packages_list.sr > $@
+packages_list-sr.cc : packages_list.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/packages_list.sr > $@
diff --git a/src/gtkpaludis/package_overview.cc b/src/gtkpaludis/package_overview.cc
index 8417db2..99c66ec 100644
--- a/src/gtkpaludis/package_overview.cc
+++ b/src/gtkpaludis/package_overview.cc
@@ -106,6 +106,8 @@ namespace
void
Populate::operator() ()
{
+ StatusBarMessage m1(this, "Querying package...");
+
Glib::RefPtr<Gtk::TreeStore> model(Gtk::TreeStore::create(_imp->columns));
std::map<RepositoryName, Gtk::TreeModel::iterator> repository_rows;
@@ -113,26 +115,52 @@ namespace
top_row[_imp->columns.col_left] = stringify(_pkg);
top_row[_imp->columns.col_right] = "";
- StatusBarMessage m1(this, "Querying package versions...");
+ Gtk::TreeModel::Row description_row = *model->append(top_row.children());
+ description_row[_imp->columns.col_left] = "Description";
+
+ Gtk::TreeModel::Row homepage_row = *model->append(top_row.children());
+ homepage_row[_imp->columns.col_left] = "Homepage";
+
+ Gtk::TreeModel::Row versions_row = *model->append(top_row.children());
+ versions_row[_imp->columns.col_left] = "Versions";
+ versions_row[_imp->columns.col_right] = "";
- PackageDatabaseEntryCollection::ConstPointer results(DefaultEnvironment::get_instance()->package_database()->query(
- PackageDepAtom::Pointer(new PackageDepAtom(stringify(_pkg))), is_either));
+ PackageDepAtom::Pointer atom(new PackageDepAtom(stringify(_pkg)));
+ PackageDatabaseEntryCollection::ConstPointer
+ entries(DefaultEnvironment::get_instance()->package_database()->query(atom, is_either)),
+ preferred_entries(DefaultEnvironment::get_instance()->package_database()->query(atom, is_installed_only));
+ if (preferred_entries->empty())
+ preferred_entries = entries;
- for (PackageDatabaseEntryCollection::Iterator i(results->begin()), i_end(results->end()) ;
- i != i_end ; ++i)
{
- std::map<RepositoryName, Gtk::TreeModel::iterator>::iterator r(repository_rows.find(i->repository));
- if (repository_rows.end() == r)
+ StatusBarMessage m2(this, "Querying package versions...");
+
+ for (PackageDatabaseEntryCollection::Iterator i(entries->begin()), i_end(entries->end()) ;
+ i != i_end ; ++i)
{
- r = repository_rows.insert(std::make_pair(i->repository, model->append(top_row.children()))).first;
- (*r->second)[_imp->columns.col_left] = stringify(i->repository);
+ std::map<RepositoryName, Gtk::TreeModel::iterator>::iterator r(repository_rows.find(i->repository));
+ if (repository_rows.end() == r)
+ {
+ r = repository_rows.insert(std::make_pair(i->repository, model->append(versions_row.children()))).first;
+ (*r->second)[_imp->columns.col_left] = stringify(i->repository);
+ }
+
+ Glib::ustring value((*r->second)[_imp->columns.col_right]);
+ if (! value.empty())
+ value.append(" ");
+ value.append(stringify(i->version));
+ (*r->second)[_imp->columns.col_right] = value;
}
+ }
- Glib::ustring value((*r->second)[_imp->columns.col_right]);
- if (! value.empty())
- value.append(" ");
- value.append(stringify(i->version));
- (*r->second)[_imp->columns.col_right] = value;
+ if (! (preferred_entries->empty()))
+ {
+ StatusBarMessage m2(this, "Querying package metadata...");
+ VersionMetadata::ConstPointer metadata(DefaultEnvironment::get_instance()->package_database()->fetch_repository(
+ preferred_entries->last()->repository)->version_metadata(
+ preferred_entries->last()->name, preferred_entries->last()->version));
+ homepage_row[_imp->columns.col_right] = metadata->homepage;
+ description_row[_imp->columns.col_right] = metadata->description;
}
dispatch(sigc::bind<1>(sigc::mem_fun(_imp, &Implementation<PackageOverview>::set_model), model));
diff --git a/src/gtkpaludis/packages_list.cc b/src/gtkpaludis/packages_list.cc
index f4d2d3f..9a57e19 100644
--- a/src/gtkpaludis/packages_list.cc
+++ b/src/gtkpaludis/packages_list.cc
@@ -21,6 +21,8 @@
#include "paludis_thread.hh"
#include "main_window.hh"
#include <paludis/environment/default/default_environment.hh>
+#include <paludis/util/sr.hh>
+#include <paludis/util/compare.hh>
#include <gtkmm/treeview.h>
#include <gtkmm/liststore.h>
@@ -30,6 +32,12 @@
using namespace gtkpaludis;
using namespace paludis;
+namespace gtkpaludis
+{
+#include "packages_list-sr.hh"
+#include "packages_list-sr.cc"
+}
+
namespace
{
class Columns :
@@ -37,12 +45,14 @@ namespace
{
public:
Gtk::TreeModelColumn<Glib::ustring> col_package_display;
+ Gtk::TreeModelColumn<bool> col_is_installed;
Gtk::TreeModelColumn<Glib::ustring> col_package_real;
Gtk::TreeModelColumn<Glib::ustring> col_description;
Columns()
{
add(col_package_display);
+ add(col_is_installed);
add(col_package_real);
add(col_description);
}
@@ -65,15 +75,16 @@ namespace paludis
{
}
- void add_packages(const std::map<QualifiedPackageName, std::string> & s)
+ void add_packages(const std::map<QualifiedPackageName, PackagesListEntry> & s)
{
- for (std::map<QualifiedPackageName, std::string>::const_iterator n(s.begin()), n_end(s.end()) ;
+ for (std::map<QualifiedPackageName, PackagesListEntry>::const_iterator n(s.begin()), n_end(s.end()) ;
n != n_end ; ++n)
{
Gtk::TreeModel::Row row = *(model->append());
row[columns.col_package_display] = stringify(n->first.package);
row[columns.col_package_real] = stringify(n->first);
- row[columns.col_description] = n->second;
+ row[columns.col_is_installed] = n->second.is_installed;
+ row[columns.col_description] = n->second.description;
}
list->columns_autosize();
@@ -90,6 +101,7 @@ PackagesList::PackagesList() :
{
set_model(_imp->model);
append_column("Package", _imp->columns.col_package_display);
+ append_column("I", _imp->columns.col_is_installed);
append_column("Description", _imp->columns.col_description);
}
@@ -119,7 +131,7 @@ namespace
void
Populate::operator() ()
{
- std::map<QualifiedPackageName, std::string> names;
+ std::map<QualifiedPackageName, PackagesListEntry> names;
{
StatusBarMessage m1(this, "Loading package names...");
@@ -133,24 +145,33 @@ namespace
QualifiedPackageNameCollection::ConstPointer pkgs((*r)->package_names(_cat));
for (QualifiedPackageNameCollection::Iterator p(pkgs->begin()), p_end(pkgs->end()) ;
p != p_end ; ++p)
- names.insert(std::make_pair(*p, ""));
+ names.insert(std::make_pair(*p, PackagesListEntry::create().description("").is_installed(false)));
}
}
{
StatusBarMessage m1(this, "Loading package descriptions...");
- for (std::map<QualifiedPackageName, std::string>::iterator i(names.begin()), i_end(names.end()) ;
+ for (std::map<QualifiedPackageName, PackagesListEntry>::iterator i(names.begin()), i_end(names.end()) ;
i != i_end ; ++i)
{
- PackageDatabaseEntryCollection::ConstPointer results(DefaultEnvironment::get_instance()->package_database()->query(
- PackageDepAtom::Pointer(new PackageDepAtom(stringify(i->first))), is_either));
+ bool is_installed(true);
+ PackageDatabaseEntryCollection::ConstPointer results(DefaultEnvironment::get_instance()->package_database()->query(
+ PackageDepAtom::Pointer(new PackageDepAtom(stringify(i->first))), is_installed_only));
+ if (results->empty())
+ {
+ is_installed = false;
+ results = DefaultEnvironment::get_instance()->package_database()->query(
+ PackageDepAtom::Pointer(new PackageDepAtom(stringify(i->first))), is_either);
+ }
if (results->empty())
continue;
- i->second = DefaultEnvironment::get_instance()->package_database()->fetch_repository(
+
+ i->second.description = DefaultEnvironment::get_instance()->package_database()->fetch_repository(
results->last()->repository)->version_metadata(results->last()->name,
results->last()->version)->description;
+ i->second.is_installed = is_installed;
}
}
diff --git a/src/gtkpaludis/packages_list.sr b/src/gtkpaludis/packages_list.sr
new file mode 100644
index 0000000..4f6e4a6
--- /dev/null
+++ b/src/gtkpaludis/packages_list.sr
@@ -0,0 +1,6 @@
+make_class_PackagesListEntry()
+{
+ key description std::string
+ key is_installed bool
+ allow_named_args
+}