aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-07 13:10:25 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-06-07 13:10:25 +0000
commit0ad917cb4aa79304c593bcb3925f5511ecfd1f99 (patch)
treef8eab43581d5bd4b7a15d1e092bab458e73cd3fe
parent0a3a60f61425acf8389fc09452d6bce0aa1e3bea (diff)
downloadpaludis-0ad917cb4aa79304c593bcb3925f5511ecfd1f99.tar.gz
paludis-0ad917cb4aa79304c593bcb3925f5511ecfd1f99.tar.xz
r3354@snowflake: ciaranm | 2007-06-07 14:09:48 +0100
More gtkpaludis work
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/Makefile.am2
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_list.cc9
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc283
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_list_model.hh9
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_page.cc34
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/packages_page.hh3
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/sets_list.cc60
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/sets_list.hh30
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/sets_list_model.cc120
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/sets_list_model.hh44
10 files changed, 490 insertions, 104 deletions
diff --git a/src/clients/gtkpaludis/libgtkpaludis/Makefile.am b/src/clients/gtkpaludis/libgtkpaludis/Makefile.am
index 6d888a9..f0e5adf 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/Makefile.am
+++ b/src/clients/gtkpaludis/libgtkpaludis/Makefile.am
@@ -34,6 +34,8 @@ libgtkpaludis_a_SOURCES = \
repository_buttons.cc repository_buttons.hh \
repository_info.cc repository_info.hh \
repository_info_model.cc repository_info_model.hh \
+ sets_list.cc sets_list.hh \
+ sets_list_model.cc sets_list_model.hh \
task_sequence_list.cc task_sequence_list.hh \
task_sequence_list_model.cc task_sequence_list_model.hh \
task_window.cc task_window.hh \
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_list.cc b/src/clients/gtkpaludis/libgtkpaludis/packages_list.cc
index 0868bda..0b432ad 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_list.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_list.cc
@@ -55,11 +55,12 @@ void
PackagesList::handle_signal_cursor_changed()
{
if (get_selection()->get_selected())
- _imp->repositories_page->set_qpn(paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- (*get_selection()->get_selected())[_imp->real_model->columns().col_pde].operator
- paludis::tr1::shared_ptr<const PackageDatabaseEntry>()->name)));
+ {
+ tr1::shared_ptr<const QualifiedPackageName> qpn((*get_selection()->get_selected())[_imp->real_model->columns().col_qpn]);
+ _imp->repositories_page->set_qpn(qpn);
+ }
else
- _imp->repositories_page->set_qpn(paludis::tr1::shared_ptr<QualifiedPackageName>());
+ _imp->repositories_page->set_qpn(tr1::shared_ptr<QualifiedPackageName>());
}
void
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
index d2e7444..f2cb7c5 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.cc
@@ -1,17 +1,23 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-#include "packages_list_model.hh"
#include "main_window.hh"
-#include "packages_page.hh"
#include "markup.hh"
+#include "packages_list_model.hh"
+#include "packages_page.hh"
+#include <paludis/dep_spec_flattener.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/iterator.hh>
+#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
-#include <paludis/environment.hh>
-#include <paludis/package_database.hh>
+#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/visitor-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <list>
+#include <algorithm>
+#include <set>
using namespace paludis;
using namespace gtkpaludis;
@@ -35,32 +41,30 @@ namespace paludis
namespace
{
- struct PopulateDataSubItem
+ struct PopulateItem
{
- std::string slot;
- std::string status;
+ std::string title;
+ std::string status_markup;
std::string description;
- PackageDatabaseEntry pde;
-
- PopulateDataSubItem(const std::string & s, const std::string & t, const std::string & d,
- const PackageDatabaseEntry p) :
- slot(s),
- status(t),
- description(d),
- pde(p)
+ tr1::shared_ptr<const QualifiedPackageName> qpn;
+ PackagesPackageFilterOption local_best_option;
+ std::list<PopulateItem> children;
+ bool merge_if_one_child;
+
+ const PackagesPackageFilterOption children_best_option() const
{
- }
- };
+ PackagesPackageFilterOption result(local_best_option);
+ for (std::list<PopulateItem>::const_iterator i(children.begin()), i_end(children.end()) ;
+ i != i_end ; ++i)
+ result = std::max(result, i->children_best_option());
- struct PopulateDataItem
- {
- std::string package;
- PackagesPackageFilterOption best_option;
- std::list<PopulateDataSubItem> subitems;
+ return result;
+ }
- PopulateDataItem(const std::string & p) :
- package(p),
- best_option(ppfo_all_packages)
+ PopulateItem(const std::string & t) :
+ title(t),
+ local_best_option(ppfo_all_packages),
+ merge_if_one_child(true)
{
}
};
@@ -70,7 +74,16 @@ namespace gtkpaludis
{
struct PackagesListModel::PopulateData
{
- std::list<PopulateDataItem> items;
+ std::list<PopulateItem> items;
+ };
+
+ struct PackagesListModel::PopulateDataIterator :
+ libwrapiter::ForwardIterator<PackagesListModel::PopulateDataIterator, const PopulateItem>
+ {
+ PopulateDataIterator(const std::list<PopulateItem>::const_iterator & i) :
+ libwrapiter::ForwardIterator<PackagesListModel::PopulateDataIterator, const PopulateItem>(i)
+ {
+ }
};
}
@@ -90,7 +103,7 @@ PackagesListModel::Columns::Columns()
add(col_package);
add(col_status_markup);
add(col_description);
- add(col_pde);
+ add(col_qpn);
add(col_best_package_filter_option);
}
@@ -113,53 +126,56 @@ PackagesListModel::populate()
namespace
{
- PopulateDataSubItem make_item(const PackageDatabaseEntry & pde,
+ PopulateItem make_item(const PackageDepSpec & pds,
+ const QualifiedPackageName & qpn,
paludis::tr1::shared_ptr<const VersionMetadata> metadata,
- const Environment * const environment,
- PackagesPackageFilterOption * const best_option)
+ const Environment * const environment)
{
+ PackagesPackageFilterOption best_option(ppfo_all_packages);
std::string status;
paludis::tr1::shared_ptr<const PackageDatabaseEntryCollection> ci(
environment->package_database()->query(
+ query::InstalledAtRoot(environment->root()) &
+ query::Matches(pds) &
query::Matches(PackageDepSpec(
- paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(pde.name)),
+ paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(qpn)),
paludis::tr1::shared_ptr<CategoryNamePart>(),
paludis::tr1::shared_ptr<PackageNamePart>(),
paludis::tr1::shared_ptr<VersionRequirements>(),
vr_and,
- paludis::tr1::shared_ptr<SlotName>(new SlotName(metadata->slot)))) &
- query::InstalledAtRoot(environment->root()),
+ paludis::tr1::shared_ptr<SlotName>(new SlotName(metadata->slot)))),
qo_order_by_version));
paludis::tr1::shared_ptr<const PackageDatabaseEntryCollection> av(
environment->package_database()->query(
+ query::RepositoryHasInstallableInterface() &
+ query::Matches(pds) &
query::Matches(PackageDepSpec(
- paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(pde.name)),
+ paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(qpn)),
paludis::tr1::shared_ptr<CategoryNamePart>(),
paludis::tr1::shared_ptr<PackageNamePart>(),
paludis::tr1::shared_ptr<VersionRequirements>(),
vr_and,
paludis::tr1::shared_ptr<SlotName>(new SlotName(metadata->slot)))) &
- query::RepositoryHasInstallableInterface() &
query::NotMasked(),
qo_order_by_version));
if (! ci->empty())
{
status = markup_escape(stringify(ci->last()->version));
- *best_option = std::max(*best_option, ppfo_installed_packages);
+ best_option = ppfo_installed_packages;
if (! av->empty())
{
if (av->last()->version < ci->last()->version)
{
status.append(markup_bold(markup_escape(" > " + stringify(av->last()->version))));
- *best_option = std::max(*best_option, ppfo_upgradable_packages);
+ best_option = ppfo_upgradable_packages;
}
else if (av->last()->version > ci->last()->version)
{
status.append(markup_bold(markup_escape(" < " + stringify(av->last()->version))));
- *best_option = std::max(*best_option, ppfo_upgradable_packages);
+ best_option = ppfo_upgradable_packages;
}
}
}
@@ -167,8 +183,9 @@ namespace
{
paludis::tr1::shared_ptr<const PackageDatabaseEntryCollection> av(
environment->package_database()->query(
+ query::Matches(pds) &
query::Matches(PackageDepSpec(
- paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(pde.name)),
+ paludis::tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(qpn)),
paludis::tr1::shared_ptr<CategoryNamePart>(),
paludis::tr1::shared_ptr<PackageNamePart>(),
paludis::tr1::shared_ptr<VersionRequirements>(),
@@ -180,20 +197,21 @@ namespace
if (av->empty())
{
status.append(markup_foreground("grey", markup_escape("masked")));
- *best_option = std::max(*best_option, ppfo_all_packages);
+ best_option = ppfo_all_packages;
}
else
{
status.append(markup_foreground("grey", markup_escape(stringify(av->last()->version))));
- *best_option = std::max(*best_option, ppfo_visible_packages);
+ best_option = ppfo_visible_packages;
}
}
- return PopulateDataSubItem(
- stringify(metadata->slot),
- status,
- metadata->description,
- pde);
+ PopulateItem result(stringify(metadata->slot));
+ result.status_markup = status;
+ result.description = metadata->description;
+ result.qpn = make_shared_ptr(new QualifiedPackageName(qpn));
+ result.local_best_option = best_option;
+ return result;
}
}
@@ -201,36 +219,105 @@ void
PackagesListModel::populate_in_paludis_thread()
{
paludis::tr1::shared_ptr<PopulateData> data(new PopulateData);
- paludis::tr1::shared_ptr<const PackageDatabaseEntryCollection> c;
if (_imp->packages_page->get_category())
- c = _imp->main_window->environment()->package_database()->query(
- *_imp->packages_page->get_repository_filter() &
- query::Category(*_imp->packages_page->get_category()),
- qo_best_version_in_slot_only);
- else
- c.reset(new PackageDatabaseEntryCollection::Concrete);
-
- QualifiedPackageName old_qpn("OLD/OLD");
- PackagesPackageFilterOption * best_option(0);
-
- for (PackageDatabaseEntryCollection::ReverseIterator p(c->rbegin()), p_end(c->rend()) ;
- p != p_end ; ++p)
{
- paludis::tr1::shared_ptr<const VersionMetadata> metadata(
- _imp->main_window->environment()->package_database()->fetch_repository(p->repository)->version_metadata(
- p->name, p->version));
+ paludis::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(
+ _imp->main_window->environment()->package_database()->query(
+ *_imp->packages_page->get_repository_filter() &
+ query::Category(*_imp->packages_page->get_category()),
+ qo_best_version_in_slot_only));
- if (old_qpn != p->name)
+ QualifiedPackageName old_qpn("OLD/OLD");
+
+ for (PackageDatabaseEntryCollection::ReverseIterator p(c->rbegin()), p_end(c->rend()) ;
+ p != p_end ; ++p)
{
- best_option = &data->items.insert(data->items.begin(), PopulateDataItem(stringify(p->name.package)))->best_option;
- data->items.begin()->subitems.push_front(make_item(*p, metadata, _imp->main_window->environment(),
- best_option));
- old_qpn = p->name;
+ paludis::tr1::shared_ptr<const VersionMetadata> metadata(
+ _imp->main_window->environment()->package_database()->fetch_repository(p->repository)->version_metadata(
+ p->name, p->version));
+
+ if (old_qpn != p->name)
+ {
+ data->items.push_front(PopulateItem(stringify(p->name.package)));
+ data->items.begin()->children.push_front(make_item(
+ PackageDepSpec(make_shared_ptr(new QualifiedPackageName(p->name))),
+ p->name, metadata, _imp->main_window->environment()));
+ data->items.begin()->qpn = data->items.begin()->children.begin()->qpn;
+ old_qpn = p->name;
+ }
+ else
+ data->items.begin()->children.push_front(make_item(
+ PackageDepSpec(make_shared_ptr(new QualifiedPackageName(p->name))),
+ p->name, metadata, _imp->main_window->environment()));
+ }
+ }
+ else if (_imp->packages_page->get_set())
+ {
+ DepSpecFlattener f(_imp->main_window->environment(), 0);
+ _imp->main_window->environment()->set(*_imp->packages_page->get_set())->accept(f);
+ std::set<std::string> a;
+ std::transform(indirect_iterator(f.begin()), indirect_iterator(f.end()), std::inserter(a, a.begin()),
+ std::tr1::mem_fn(&StringDepSpec::text));
+
+ for (std::set<std::string>::const_iterator i(a.begin()), i_end(a.end()) ;
+ i != i_end ; ++i)
+ {
+ std::list<PopulateItem>::iterator atom_iter(data->items.insert(data->items.end(), PopulateItem(*i)));
+ atom_iter->merge_if_one_child = false;
+ PackageDepSpec ds(*i, pds_pm_unspecific);
+ if (ds.package_ptr())
+ {
+ paludis::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(
+ _imp->main_window->environment()->package_database()->query(
+ *_imp->packages_page->get_repository_filter() &
+ query::Matches(ds),
+ qo_best_version_in_slot_only));
+
+ for (PackageDatabaseEntryCollection::ReverseIterator p(c->rbegin()), p_end(c->rend()) ;
+ p != p_end ; ++p)
+ {
+ paludis::tr1::shared_ptr<const VersionMetadata> metadata(
+ _imp->main_window->environment()->package_database()->fetch_repository(p->repository)->version_metadata(
+ p->name, p->version));
+
+ atom_iter->children.push_back(make_item(ds,
+ p->name, metadata, _imp->main_window->environment()));
+ atom_iter->qpn = atom_iter->children.back().qpn;
+ }
+ }
+ else
+ {
+ paludis::tr1::shared_ptr<const PackageDatabaseEntryCollection> c(
+ _imp->main_window->environment()->package_database()->query(
+ *_imp->packages_page->get_repository_filter() &
+ query::Matches(ds),
+ qo_best_version_in_slot_only));
+
+ QualifiedPackageName old_qpn("OLD/OLD");
+ std::list<PopulateItem>::iterator pkg_iter;
+
+ for (PackageDatabaseEntryCollection::ReverseIterator p(c->rbegin()), p_end(c->rend()) ;
+ p != p_end ; ++p)
+ {
+ paludis::tr1::shared_ptr<const VersionMetadata> metadata(
+ _imp->main_window->environment()->package_database()->fetch_repository(p->repository)->version_metadata(
+ p->name, p->version));
+
+ if (old_qpn != p->name)
+ {
+ pkg_iter = atom_iter->children.insert(atom_iter->children.end(), PopulateItem(stringify(p->name)));
+ pkg_iter->children.push_back(make_item(ds,
+ p->name, metadata, _imp->main_window->environment()));
+ pkg_iter->qpn = pkg_iter->children.back().qpn;
+ old_qpn = p->name;
+ }
+ else
+ pkg_iter->children.push_front(make_item(ds,
+ p->name, metadata, _imp->main_window->environment()));
+ }
+ }
}
- else
- data->items.begin()->subitems.push_front(make_item(*p, metadata, _imp->main_window->environment(),
- best_option));
}
_imp->main_window->gui_thread_action(
@@ -241,38 +328,42 @@ void
PackagesListModel::populate_in_gui_thread(paludis::tr1::shared_ptr<const PackagesListModel::PopulateData> names)
{
clear();
+ Gtk::TreeNodeChildren c(children());
+ _populate_in_gui_thread_recursive(c,
+ PopulateDataIterator(names->items.begin()),
+ PopulateDataIterator(names->items.end()));
+}
- for (std::list<PopulateDataItem>::const_iterator i(names->items.begin()), i_end(names->items.end()) ;
- i != i_end ; ++i)
+void
+PackagesListModel::_populate_in_gui_thread_recursive(
+ Gtk::TreeNodeChildren & t,
+ PopulateDataIterator i,
+ PopulateDataIterator i_end)
+{
+ for ( ; i != i_end ; ++i)
{
- if (i->subitems.empty())
- continue;
-
- iterator r(append());
- (*r)[_imp->columns.col_package] = i->package;
- (*r)[_imp->columns.col_pde] = paludis::tr1::shared_ptr<PackageDatabaseEntry>(
- new PackageDatabaseEntry(i->subitems.begin()->pde));
- (*r)[_imp->columns.col_best_package_filter_option] = i->best_option;
-
- if (next(i->subitems.begin()) == i->subitems.end())
- {
- (*r)[_imp->columns.col_status_markup] = i->subitems.begin()->status;
- (*r)[_imp->columns.col_description] = i->subitems.begin()->description;
- }
- else
+ iterator r(append(t));
+ (*r)[_imp->columns.col_package] = i->title;
+ (*r)[_imp->columns.col_best_package_filter_option] = i->children_best_option();
+ (*r)[_imp->columns.col_qpn] = i->qpn;
+ (*r)[_imp->columns.col_description] = i->description;
+ (*r)[_imp->columns.col_status_markup] = i->status_markup;
+
+ if (! i->children.empty())
{
- for (std::list<PopulateDataSubItem>::const_iterator j(i->subitems.begin()), j_end(i->subitems.end()) ;
- j != j_end ; ++j)
+ if (i->merge_if_one_child && (next(i->children.begin()) == i->children.end()))
{
- iterator s(append(r->children()));
- (*s)[_imp->columns.col_package] = ":" + j->slot;
- (*s)[_imp->columns.col_status_markup] = j->status;
- (*s)[_imp->columns.col_description] = j->description;
- (*s)[_imp->columns.col_pde] = paludis::tr1::shared_ptr<PackageDatabaseEntry>(new PackageDatabaseEntry(j->pde));
- (*s)[_imp->columns.col_best_package_filter_option] = i->best_option;
+ (*r)[_imp->columns.col_description] = i->children.begin()->description;
+ (*r)[_imp->columns.col_status_markup] = i->children.begin()->status_markup;
+
+ }
+ else
+ {
+ Gtk::TreeNodeChildren c(r->children());
+ _populate_in_gui_thread_recursive(c, PopulateDataIterator(i->children.begin()),
+ PopulateDataIterator(i->children.end()));
}
}
}
}
-
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.hh b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.hh
index 1b2dc4e..74e135a 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.hh
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_list_model.hh
@@ -7,6 +7,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/name.hh>
#include <paludis/package_database_entry.hh>
+#include <paludis/util/tr1_functional.hh>
#include <libgtkpaludis/packages_package_filter_option.hh>
namespace gtkpaludis
@@ -20,6 +21,12 @@ namespace gtkpaludis
{
protected:
class PopulateData;
+ class PopulateDataIterator;
+
+ void _populate_in_gui_thread_recursive(
+ Gtk::TreeNodeChildren &,
+ PopulateDataIterator,
+ PopulateDataIterator);
void populate_in_paludis_thread();
void populate_in_gui_thread(paludis::tr1::shared_ptr<const PopulateData> names);
@@ -38,7 +45,7 @@ namespace gtkpaludis
Gtk::TreeModelColumn<Glib::ustring> col_package;
Gtk::TreeModelColumn<Glib::ustring> col_status_markup;
Gtk::TreeModelColumn<Glib::ustring> col_description;
- Gtk::TreeModelColumn<paludis::tr1::shared_ptr<const paludis::PackageDatabaseEntry> > col_pde;
+ Gtk::TreeModelColumn<paludis::tr1::shared_ptr<const paludis::QualifiedPackageName> > col_qpn;
Gtk::TreeModelColumn<PackagesPackageFilterOption> col_best_package_filter_option;
};
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_page.cc b/src/clients/gtkpaludis/libgtkpaludis/packages_page.cc
index c7d9276..c79135d 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_page.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_page.cc
@@ -3,6 +3,7 @@
#include "packages_page.hh"
#include "packages_filter.hh"
#include "categories_list.hh"
+#include "sets_list.hh"
#include "packages_list.hh"
#include "package_buttons.hh"
@@ -25,12 +26,16 @@ namespace paludis
Gtk::ScrolledWindow categories_list_scroll;
CategoriesList categories_list;
+ Gtk::ScrolledWindow sets_list_scroll;
+ SetsList sets_list;
+
Gtk::ScrolledWindow packages_list_scroll;
PackagesList packages_list;
PackageButtons package_buttons;
paludis::tr1::shared_ptr<const Query> repository_filter;
paludis::tr1::shared_ptr<const CategoryNamePart> category;
+ paludis::tr1::shared_ptr<const SetName> set;
paludis::tr1::shared_ptr<const QualifiedPackageName> qpn;
PackagesPackageFilterOption package_filter;
PackagesTextFilterSourceOption text_filter;
@@ -40,6 +45,7 @@ namespace paludis
main_window(m),
packages_filter(m, p),
categories_list(m, p),
+ sets_list(m, p),
packages_list(m, p),
package_buttons(m, p),
repository_filter(new query::All()),
@@ -51,7 +57,7 @@ namespace paludis
}
PackagesPage::PackagesPage(MainWindow * const m) :
- Gtk::Table(3, 2),
+ Gtk::Table(4, 2),
MainNotebookPage(),
PrivateImplementationPattern<PackagesPage>(new Implementation<PackagesPage>(m, this))
{
@@ -61,11 +67,15 @@ PackagesPage::PackagesPage(MainWindow * const m) :
_imp->categories_list_scroll.add(_imp->categories_list);
attach(_imp->categories_list_scroll, 0, 1, 1, 2, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 4, 4);
+ _imp->sets_list_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ _imp->sets_list_scroll.add(_imp->sets_list);
+ attach(_imp->sets_list_scroll, 0, 1, 2, 3, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 4, 4);
+
_imp->packages_list_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
_imp->packages_list_scroll.add(_imp->packages_list);
- attach(_imp->packages_list_scroll, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 4, 4);
- attach(_imp->package_buttons, 0, 2, 2, 3, Gtk::FILL, Gtk::FILL, 4, 4);
+ attach(_imp->packages_list_scroll, 1, 2, 1, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 4, 4);
+ attach(_imp->package_buttons, 0, 2, 3, 4, Gtk::FILL, Gtk::FILL, 4, 4);
}
PackagesPage::~PackagesPage()
@@ -76,6 +86,7 @@ void
PackagesPage::populate()
{
_imp->categories_list.populate();
+ _imp->sets_list.populate();
_imp->packages_filter.populate();
_imp->packages_list.populate_real();
_imp->package_buttons.populate();
@@ -85,6 +96,16 @@ void
PackagesPage::set_category(paludis::tr1::shared_ptr<const CategoryNamePart> c)
{
_imp->category = c;
+ _imp->set.reset();
+ _imp->packages_list.populate_real();
+ _imp->package_buttons.populate();
+}
+
+void
+PackagesPage::set_set(paludis::tr1::shared_ptr<const SetName> c)
+{
+ _imp->set = c;
+ _imp->category.reset();
_imp->packages_list.populate_real();
_imp->package_buttons.populate();
}
@@ -95,6 +116,12 @@ PackagesPage::get_category() const
return _imp->category;
}
+paludis::tr1::shared_ptr<const SetName>
+PackagesPage::get_set() const
+{
+ return _imp->set;
+}
+
void
PackagesPage::set_qpn(paludis::tr1::shared_ptr<const QualifiedPackageName> q)
{
@@ -113,6 +140,7 @@ PackagesPage::set_repository_filter(paludis::tr1::shared_ptr<const Query> q)
{
_imp->repository_filter = q;
_imp->categories_list.populate();
+ _imp->sets_list.populate();
_imp->packages_list.populate_real();
_imp->package_buttons.populate();
}
diff --git a/src/clients/gtkpaludis/libgtkpaludis/packages_page.hh b/src/clients/gtkpaludis/libgtkpaludis/packages_page.hh
index d722d43..e6b4fcb 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/packages_page.hh
+++ b/src/clients/gtkpaludis/libgtkpaludis/packages_page.hh
@@ -30,6 +30,9 @@ namespace gtkpaludis
void set_category(paludis::tr1::shared_ptr<const paludis::CategoryNamePart>);
paludis::tr1::shared_ptr<const paludis::CategoryNamePart> get_category() const;
+ void set_set(paludis::tr1::shared_ptr<const paludis::SetName>);
+ paludis::tr1::shared_ptr<const paludis::SetName> get_set() const;
+
void set_repository_filter(paludis::tr1::shared_ptr<const paludis::Query>);
paludis::tr1::shared_ptr<const paludis::Query> get_repository_filter() const;
diff --git a/src/clients/gtkpaludis/libgtkpaludis/sets_list.cc b/src/clients/gtkpaludis/libgtkpaludis/sets_list.cc
new file mode 100644
index 0000000..807f9fb
--- /dev/null
+++ b/src/clients/gtkpaludis/libgtkpaludis/sets_list.cc
@@ -0,0 +1,60 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include "sets_list.hh"
+#include "sets_list_model.hh"
+#include "packages_page.hh"
+#include <paludis/util/private_implementation_pattern-impl.hh>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<SetsList>
+ {
+ Glib::RefPtr<SetsListModel> model;
+ MainWindow * const main_window;
+ PackagesPage * const packages_page;
+
+ Implementation(MainWindow * const m, PackagesPage * const p) :
+ model(new SetsListModel(m, p)),
+ main_window(m),
+ packages_page(p)
+ {
+ }
+ };
+}
+
+SetsList::SetsList(MainWindow * const m, PackagesPage * const p) :
+ Gtk::TreeView(),
+ PrivateImplementationPattern<SetsList>(new Implementation<SetsList>(m, p))
+{
+ set_model(_imp->model);
+
+ append_column("Set", _imp->model->columns().col_set_name);
+
+ signal_cursor_changed().connect(sigc::mem_fun(this, &SetsList::handle_signal_cursor_changed));
+}
+
+SetsList::~SetsList()
+{
+}
+
+void
+SetsList::populate()
+{
+ _imp->model->populate();
+}
+
+void
+SetsList::handle_signal_cursor_changed()
+{
+ if (get_selection()->get_selected())
+ _imp->packages_page->set_set(paludis::tr1::shared_ptr<SetName>(new SetName(
+ static_cast<Glib::ustring>((*get_selection()->get_selected())[_imp->model->columns().col_set_name]).raw())));
+ else
+ _imp->packages_page->set_set(
+ paludis::tr1::shared_ptr<SetName>());
+}
+
diff --git a/src/clients/gtkpaludis/libgtkpaludis/sets_list.hh b/src/clients/gtkpaludis/libgtkpaludis/sets_list.hh
new file mode 100644
index 0000000..dff6a06
--- /dev/null
+++ b/src/clients/gtkpaludis/libgtkpaludis/sets_list.hh
@@ -0,0 +1,30 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef GTKPALUDIS_GUARD_LIBGTKPALUDIS_SETS_LIST_HH
+#define GTKPALUDIS_GUARD_LIBGTKPALUDIS_SETS_LIST_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <gtkmm/treeview.h>
+
+namespace gtkpaludis
+{
+ class MainWindow;
+ class PackagesPage;
+
+ class SetsList :
+ public Gtk::TreeView,
+ private paludis::PrivateImplementationPattern<SetsList>
+ {
+ protected:
+ void handle_signal_cursor_changed();
+
+ public:
+ SetsList(MainWindow * const m, PackagesPage * const p);
+ ~SetsList();
+
+ void populate();
+ };
+}
+
+
+#endif
diff --git a/src/clients/gtkpaludis/libgtkpaludis/sets_list_model.cc b/src/clients/gtkpaludis/libgtkpaludis/sets_list_model.cc
new file mode 100644
index 0000000..d81853c
--- /dev/null
+++ b/src/clients/gtkpaludis/libgtkpaludis/sets_list_model.cc
@@ -0,0 +1,120 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include "sets_list_model.hh"
+#include "main_window.hh"
+#include "packages_page.hh"
+#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/environment.hh>
+#include <paludis/package_database.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+#include <libwrapiter/libwrapiter_output_iterator.hh>
+
+using namespace paludis;
+using namespace gtkpaludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<SetsListModel>
+ {
+ MainWindow * const main_window;
+ PackagesPage * const packages_page;
+ SetsListModel::Columns columns;
+
+ Implementation(MainWindow * const m, PackagesPage * const p) :
+ main_window(m),
+ packages_page(p)
+ {
+ }
+ };
+}
+
+SetsListModel::SetsListModel(MainWindow * const m, PackagesPage * const p) :
+ PrivateImplementationPattern<SetsListModel>(new Implementation<SetsListModel>(m, p)),
+ Gtk::ListStore(_imp->columns)
+{
+}
+
+SetsListModel::~SetsListModel()
+{
+}
+
+void
+SetsListModel::populate()
+{
+ _imp->main_window->paludis_thread_action(
+ sigc::mem_fun(this, &SetsListModel::populate_in_paludis_thread), "Populating sets list model");
+}
+
+void
+SetsListModel::populate_in_paludis_thread()
+{
+ paludis::tr1::shared_ptr<SetNameCollection> columns(
+ new SetNameCollection::Concrete);
+
+ paludis::tr1::shared_ptr<RepositoryNameCollection> repos(
+ _imp->packages_page->get_repository_filter()->repositories(*_imp->main_window->environment()));
+
+ if (repos)
+ {
+ for (RepositoryNameCollection::Iterator r(repos->begin()), r_end(repos->end()) ;
+ r != r_end ; ++r)
+ {
+ RepositorySetsInterface * const i(_imp->main_window->environment()->package_database()->fetch_repository(*r)->sets_interface);
+ if (i)
+ {
+ paludis::tr1::shared_ptr<const SetNameCollection> sets(i->sets_list());
+ std::copy(sets->begin(), sets->end(), columns->inserter());
+ }
+ }
+ }
+ else
+ {
+ for (IndirectIterator<PackageDatabase::RepositoryIterator>
+ r(indirect_iterator(_imp->main_window->environment()->package_database()->begin_repositories())),
+ r_end(indirect_iterator(_imp->main_window->environment()->package_database()->end_repositories())) ;
+ r != r_end ; ++r)
+ {
+ RepositorySetsInterface * const i(r->sets_interface);
+ if (i)
+ {
+ paludis::tr1::shared_ptr<const SetNameCollection> sets(i->sets_list());
+ std::copy(sets->begin(), sets->end(), columns->inserter());
+ }
+ }
+ }
+
+ tr1::shared_ptr<const SetNameCollection> sets(_imp->main_window->environment()->set_names());
+ std::copy(sets->begin(), sets->end(), columns->inserter());
+
+ _imp->main_window->gui_thread_action(
+ sigc::bind(sigc::mem_fun(this, &SetsListModel::populate_in_gui_thread), columns));
+}
+
+void
+SetsListModel::populate_in_gui_thread(paludis::tr1::shared_ptr<const SetNameCollection> names)
+{
+ clear();
+ for (SetNameCollection::Iterator n(names->begin()), n_end(names->end()) ;
+ n != n_end ; ++n)
+ (*append())[_imp->columns.col_set_name] = stringify(*n);
+}
+
+
+SetsListModel::Columns::Columns()
+{
+ add(col_set_name);
+}
+
+SetsListModel::Columns::~Columns()
+{
+}
+
+SetsListModel::Columns &
+SetsListModel::columns()
+{
+ return _imp->columns;
+}
+
diff --git a/src/clients/gtkpaludis/libgtkpaludis/sets_list_model.hh b/src/clients/gtkpaludis/libgtkpaludis/sets_list_model.hh
new file mode 100644
index 0000000..882e26b
--- /dev/null
+++ b/src/clients/gtkpaludis/libgtkpaludis/sets_list_model.hh
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef GTKPALUDIS_GUARD_LIBGTKPALUDIS_SETS_LIST_MODEL_HH
+#define GTKPALUDIS_GUARD_LIBGTKPALUDIS_SETS_LIST_MODEL_HH 1
+
+#include <gtkmm/liststore.h>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+
+namespace gtkpaludis
+{
+ class MainWindow;
+ class PackagesPage;
+
+ class SetsListModel :
+ private paludis::PrivateImplementationPattern<SetsListModel>,
+ public Gtk::ListStore
+ {
+ protected:
+ void populate_in_paludis_thread();
+ void populate_in_gui_thread(paludis::tr1::shared_ptr<const paludis::SetNameCollection> names);
+
+ public:
+ SetsListModel(MainWindow * const m, PackagesPage * const p);
+ ~SetsListModel();
+
+ void populate();
+
+ class Columns :
+ public Gtk::TreeModelColumnRecord
+ {
+ public:
+ Columns();
+ ~Columns();
+
+ Gtk::TreeModelColumn<Glib::ustring> col_set_name;
+ };
+
+ Columns & columns();
+ };
+}
+
+
+#endif