aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-23 13:36:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-23 13:36:31 +0000
commit7229e804c53a2c824398c0a70a4d6b6adf9c4f98 (patch)
tree4ac7af65750b74f853239536f9bb3b8fad71bfe0
parent37bd5dcd1935f59865a05b1f46edd9e93aca4f21 (diff)
downloadpaludis-7229e804c53a2c824398c0a70a4d6b6adf9c4f98.tar.gz
paludis-7229e804c53a2c824398c0a70a4d6b6adf9c4f98.tar.xz
Sets page
-rw-r--r--src/gtkpaludis/Makefile.am3
-rw-r--r--src/gtkpaludis/main_window.cc4
-rw-r--r--src/gtkpaludis/set_overview.cc227
-rw-r--r--src/gtkpaludis/set_overview.hh41
-rw-r--r--src/gtkpaludis/sets_list.cc139
-rw-r--r--src/gtkpaludis/sets_list.hh42
-rw-r--r--src/gtkpaludis/sets_page.cc106
-rw-r--r--src/gtkpaludis/sets_page.hh44
8 files changed, 605 insertions, 1 deletions
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index e329c5e..26115a3 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -30,6 +30,9 @@ gtkpaludis_SOURCES = \
repositories_list.cc repositories_list.hh \
repositories_page.cc repositories_page.hh \
repository_overview.cc repository_overview.hh \
+ set_overview.hh set_overview.cc \
+ sets_list.hh sets_list.cc \
+ sets_page.hh sets_page.cc \
sync.cc sync.hh \
gtkpaludis.cc
diff --git a/src/gtkpaludis/main_window.cc b/src/gtkpaludis/main_window.cc
index e00a005..b835ec4 100644
--- a/src/gtkpaludis/main_window.cc
+++ b/src/gtkpaludis/main_window.cc
@@ -18,6 +18,7 @@
*/
#include "main_window.hh"
+#include "sets_page.hh"
#include "packages_page.hh"
#include "repositories_page.hh"
#include "messages.hh"
@@ -49,7 +50,7 @@ namespace paludis
Gtk::Notebook main_notebook;
PackagesPage packages_page;
- Gtk::Table sets_page;
+ SetsPage sets_page;
RepositoriesPage repositories_page;
Gtk::Table messages_page;
@@ -112,6 +113,7 @@ MainWindow::populate()
{
_imp->packages_page.populate();
_imp->repositories_page.populate();
+ _imp->sets_page.populate();
}
void
diff --git a/src/gtkpaludis/set_overview.cc b/src/gtkpaludis/set_overview.cc
new file mode 100644
index 0000000..671ec22
--- /dev/null
+++ b/src/gtkpaludis/set_overview.cc
@@ -0,0 +1,227 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "set_overview.hh"
+#include "paludis_thread.hh"
+#include "main_window.hh"
+
+#include <paludis/environment/default/default_environment.hh>
+#include <paludis/util/save.hh>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+namespace
+{
+ class Columns :
+ public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ Gtk::TreeModelColumn<Glib::ustring> col_atom;
+ Gtk::TreeModelColumn<Glib::ustring> col_tag;
+
+ Columns()
+ {
+ add(col_atom);
+ add(col_tag);
+ }
+ };
+
+ struct TagDecoder :
+ public DepTagVisitorTypes::ConstVisitor
+ {
+ std::string text;
+
+ void visit(const GLSADepTag * const tag)
+ {
+ text = tag->short_text() + ": " + tag->glsa_title();
+ }
+
+ void visit(const DependencyDepTag * const)
+ {
+ }
+
+ void visit(const GeneralSetDepTag * const tag)
+ {
+ text = tag->short_text() + ": " + tag->source();
+ }
+ };
+
+ class TreeFromDepAtom :
+ private InstantiationPolicy<TreeFromDepAtom, instantiation_method::NonCopyableTag>,
+ public DepAtomVisitorTypes::ConstVisitor
+ {
+ private:
+ Glib::RefPtr<Gtk::TreeStore> _model;
+ const Columns * const _columns;
+ Gtk::TreeModel::Row * _row;
+
+ public:
+ TreeFromDepAtom(Glib::RefPtr<Gtk::TreeStore> model, const Columns * const columns,
+ Gtk::TreeModel::Row * top_row) :
+ _model(model),
+ _columns(columns),
+ _row(top_row)
+ {
+ }
+
+ void visit(const AllDepAtom * atom)
+ {
+ if (atom->begin() != atom->end())
+ {
+ Gtk::TreeModel::Row new_row(*_model->append(_row->children()));
+ new_row[_columns->col_atom] = "all of";
+ Save<Gtk::TreeModel::Row *> save_row(&_row, &new_row);
+ std::for_each(atom->begin(), atom->end(), accept_visitor(this));
+ }
+ }
+
+ void visit(const AnyDepAtom * atom)
+ {
+ if (atom->begin() != atom->end())
+ {
+ Gtk::TreeModel::Row new_row(*_model->append(_row->children()));
+ new_row[_columns->col_atom] = "any of";
+ Save<Gtk::TreeModel::Row *> save_row(&_row, &new_row);
+ std::for_each(atom->begin(), atom->end(), accept_visitor(this));
+ }
+ }
+
+ void visit(const UseDepAtom * atom)
+ {
+ Gtk::TreeModel::Row new_row(*_model->append(_row->children()));
+ new_row[_columns->col_atom] = "if " + stringify(atom->inverse() ? "!" : "") + stringify(atom->flag());
+ Save<Gtk::TreeModel::Row *> save_row(&_row, &new_row);
+ std::for_each(atom->begin(), atom->end(), accept_visitor(this));
+ }
+
+ void visit(const PlainTextDepAtom * atom)
+ {
+ Gtk::TreeModel::Row new_row(*_model->append(_row->children()));
+ new_row[_columns->col_atom] = atom->text();
+ }
+
+ void visit(const PackageDepAtom * atom)
+ {
+ Gtk::TreeModel::Row new_row(*_model->append(_row->children()));
+ new_row[_columns->col_atom] = stringify(*atom);
+
+ if (atom->tag())
+ {
+ TagDecoder d;
+ atom->tag()->accept(&d);
+ new_row[_columns->col_tag] = d.text;
+ }
+ }
+
+ void visit(const BlockDepAtom * atom)
+ {
+ Gtk::TreeModel::Row new_row(*_model->append(_row->children()));
+ new_row[_columns->col_atom] = "!" + stringify(*atom->blocked_atom());
+ }
+ };
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<SetOverview> :
+ InternalCounted<Implementation<SetOverview> >
+ {
+ SetOverview * const info;
+ Columns columns;
+ Glib::RefPtr<Gtk::TreeStore> model;
+
+ Implementation(SetOverview * const o) :
+ info(o),
+ model(Gtk::TreeStore::create(columns))
+ {
+ }
+
+ void set_model(const Glib::RefPtr<Gtk::TreeStore> & m)
+ {
+ model = m;
+ info->set_model(model);
+ info->expand_all();
+ info->columns_autosize();
+ }
+ };
+}
+
+SetOverview::SetOverview() :
+ PrivateImplementationPattern<SetOverview>(new Implementation<SetOverview>(this))
+{
+ set_model(_imp->model);
+ append_column("Atom", _imp->columns.col_atom);
+ append_column("Tag", _imp->columns.col_tag);
+}
+
+SetOverview::~SetOverview()
+{
+}
+
+namespace
+{
+ class Populate :
+ public PaludisThread::Launchable
+ {
+ private:
+ Implementation<SetOverview> * const _imp;
+ std::string _set;
+
+ public:
+ Populate(Implementation<SetOverview> * const imp, const std::string & set) :
+ _imp(imp),
+ _set(set)
+ {
+ }
+
+ virtual void operator() ();
+ };
+
+ void
+ Populate::operator() ()
+ {
+ Glib::RefPtr<Gtk::TreeStore> model(Gtk::TreeStore::create(_imp->columns));
+
+ StatusBarMessage m1(this, "Querying set information...");
+
+ DepAtom::ConstPointer set_atom(DefaultEnvironment::get_instance()->package_set(_set));
+ Gtk::TreeModel::Row top_row = *model->append();
+ top_row[_imp->columns.col_atom] = _set;
+ TreeFromDepAtom v(model, &_imp->columns, &top_row);
+ set_atom->accept(&v);
+
+ dispatch(sigc::bind<1>(sigc::mem_fun(_imp, &Implementation<SetOverview>::set_model), model));
+ }
+}
+
+void
+SetOverview::populate(const std::string & name)
+{
+ if (name.empty())
+ _imp->set_model(Gtk::TreeStore::create(_imp->columns));
+ else
+ PaludisThread::get_instance()->launch(Populate::Pointer(new Populate(_imp.raw_pointer(), name)));
+}
+
+
+
diff --git a/src/gtkpaludis/set_overview.hh b/src/gtkpaludis/set_overview.hh
new file mode 100644
index 0000000..a494111
--- /dev/null
+++ b/src/gtkpaludis/set_overview.hh
@@ -0,0 +1,41 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_GTKPALUDIS_SET_OVERVIEW_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_SET_OVERVIEW_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+#include <gtkmm/treeview.h>
+
+namespace gtkpaludis
+{
+ class SetOverview :
+ public Gtk::TreeView,
+ private paludis::PrivateImplementationPattern<SetOverview>
+ {
+ public:
+ SetOverview();
+ virtual ~SetOverview();
+
+ void populate(const std::string &);
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/sets_list.cc b/src/gtkpaludis/sets_list.cc
new file mode 100644
index 0000000..f2d06a2
--- /dev/null
+++ b/src/gtkpaludis/sets_list.cc
@@ -0,0 +1,139 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "sets_list.hh"
+#include "paludis_thread.hh"
+#include "main_window.hh"
+#include <paludis/environment/default/default_environment.hh>
+
+#include <gtkmm/treeview.h>
+#include <gtkmm/liststore.h>
+#include <glibmm/dispatcher.h>
+#include <set>
+
+using namespace paludis;
+using namespace gtkpaludis;
+
+namespace
+{
+ class Columns :
+ public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ Gtk::TreeModelColumn<Glib::ustring> col_set;
+
+ Columns()
+ {
+ add(col_set);
+ }
+ };
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<SetsList> :
+ InternalCounted<Implementation<SetsList> >
+ {
+ Columns columns;
+ Glib::RefPtr<Gtk::ListStore> model;
+
+ Implementation() :
+ model(Gtk::ListStore::create(columns))
+ {
+ }
+
+ void add_sets(const std::set<std::string> & c)
+ {
+ for (std::set<std::string>::const_iterator n(c.begin()), n_end(c.end()) ; n != n_end ; ++n)
+ {
+ Gtk::TreeModel::Row row = *(model->append());
+ row[columns.col_set] = stringify(*n);
+ }
+ }
+ };
+}
+
+namespace
+{
+ class Populate :
+ public PaludisThread::Launchable
+ {
+ private:
+ Implementation<SetsList> * const _imp;
+
+ public:
+ Populate(Implementation<SetsList> * const list) :
+ _imp(list)
+ {
+ }
+
+ virtual void operator() ();
+ };
+
+ void
+ Populate::operator() ()
+ {
+ std::set<std::string> names;
+
+ StatusBarMessage m1(this, "Loading set names...");
+
+ for (PackageDatabase::RepositoryIterator r(DefaultEnvironment::get_instance()->package_database()->begin_repositories()),
+ r_end(DefaultEnvironment::get_instance()->package_database()->end_repositories()) ; r != r_end ; ++r)
+ {
+ if (! (*r)->sets_interface)
+ continue;
+
+ SetsCollection::ConstPointer sets((*r)->sets_interface->sets_list());
+ std::copy(sets->begin(), sets->end(), std::inserter(names, names.end()));
+ }
+
+ dispatch(sigc::bind<1>(sigc::mem_fun(_imp, &Implementation<SetsList>::add_sets), names));
+ }
+}
+
+SetsList::SetsList() :
+ PrivateImplementationPattern<SetsList>(new Implementation<SetsList>)
+{
+ set_model(_imp->model);
+ append_column("Set", _imp->columns.col_set);
+}
+
+SetsList::~SetsList()
+{
+}
+
+void
+SetsList::populate()
+{
+ _imp->model->clear();
+ PaludisThread::get_instance()->launch(Populate::Pointer(new Populate(_imp.raw_pointer())));
+}
+
+std::string
+SetsList::current_set()
+{
+ Gtk::TreeModel::iterator i(get_selection()->get_selected());
+ if (i)
+ return stringify((*i)[_imp->columns.col_set]);
+ else
+ return "";
+}
+
+
diff --git a/src/gtkpaludis/sets_list.hh b/src/gtkpaludis/sets_list.hh
new file mode 100644
index 0000000..5b8a0b7
--- /dev/null
+++ b/src/gtkpaludis/sets_list.hh
@@ -0,0 +1,42 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_GTKPALUDIS_SETS_LIST_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_SETS_LIST_HH 1
+
+#include <gtkmm/treeview.h>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+
+namespace gtkpaludis
+{
+ class SetsList :
+ public Gtk::TreeView,
+ private paludis::PrivateImplementationPattern<SetsList>
+ {
+ public:
+ SetsList();
+ virtual ~SetsList();
+
+ void populate();
+ std::string current_set();
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/sets_page.cc b/src/gtkpaludis/sets_page.cc
new file mode 100644
index 0000000..d9c5af5
--- /dev/null
+++ b/src/gtkpaludis/sets_page.cc
@@ -0,0 +1,106 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "sets_page.hh"
+#include "sets_list.hh"
+#include "set_overview.hh"
+
+#include <gtkmm/button.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/label.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/separator.h>
+#include <gtkmm/stock.h>
+#include <gtkmm/box.h>
+#include <gtkmm/buttonbox.h>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<SetsPage> :
+ InternalCounted<Implementation<SetsPage> >
+ {
+ Gtk::ScrolledWindow sets_list_scroll;
+ SetsList sets_list;
+
+ Gtk::ScrolledWindow sets_overview_scroll;
+ SetOverview set_overview;
+
+ Gtk::HButtonBox buttons_box;
+ Gtk::Button install_button;
+
+ Implementation() :
+ install_button("Install")
+ {
+ }
+ };
+}
+
+SetsPage::SetsPage() :
+ Gtk::Table(2, 2, false),
+ PrivateImplementationPattern<SetsPage>(new Implementation<SetsPage>)
+{
+ set_col_spacings(5);
+ set_row_spacings(5);
+ set_border_width(5);
+
+ _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, 0, 2, Gtk::SHRINK, Gtk::FILL | Gtk::EXPAND);
+
+ _imp->sets_overview_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ _imp->sets_overview_scroll.add(_imp->set_overview);
+ attach(_imp->sets_overview_scroll, 1, 2, 0, 1);
+
+ _imp->buttons_box.set_border_width(5);
+ _imp->buttons_box.set_spacing(5);
+ _imp->buttons_box.set_layout(Gtk::BUTTONBOX_END);
+ _imp->buttons_box.add(_imp->install_button);
+ attach(_imp->buttons_box, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(0));
+
+ _imp->install_button.signal_clicked().connect(sigc::mem_fun(this,
+ &SetsPage::_install_button_clicked));
+ _imp->sets_list.get_selection()->signal_changed().connect(sigc::mem_fun(this,
+ &SetsPage::_sets_list_selection_changed));
+}
+
+SetsPage::~SetsPage()
+{
+}
+
+void
+SetsPage::populate()
+{
+ _imp->sets_list.populate();
+}
+
+void
+SetsPage::_sets_list_selection_changed()
+{
+ _imp->set_overview.populate(_imp->sets_list.current_set());
+}
+
+void
+SetsPage::_install_button_clicked()
+{
+}
+
diff --git a/src/gtkpaludis/sets_page.hh b/src/gtkpaludis/sets_page.hh
new file mode 100644
index 0000000..408e016
--- /dev/null
+++ b/src/gtkpaludis/sets_page.hh
@@ -0,0 +1,44 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_GTKPALUDIS_SETS_PAGE_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_SETS_PAGE_HH 1
+
+#include <gtkmm/table.h>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace gtkpaludis
+{
+ class SetsPage :
+ public Gtk::Table,
+ private paludis::PrivateImplementationPattern<SetsPage>
+ {
+ private:
+ void _sets_list_selection_changed();
+ void _install_button_clicked();
+
+ public:
+ SetsPage();
+ virtual ~SetsPage();
+
+ void populate();
+ };
+}
+
+#endif