aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-21 16:53:09 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-21 16:53:09 +0000
commit75cc97e78f3c12a26e28846ff9a6c5839cce22aa (patch)
treec5dd1faa6f99d224de65b4885b01303e357227dc
parent5a75634a2260f3935b5d1e30f3217e3845f257ec (diff)
downloadpaludis-75cc97e78f3c12a26e28846ff9a6c5839cce22aa.tar.gz
paludis-75cc97e78f3c12a26e28846ff9a6c5839cce22aa.tar.xz
Start of the gtkpaludis rewrite
-rw-r--r--configure.ac2
-rw-r--r--src/gtkpaludis/Makefile.am9
-rw-r--r--src/gtkpaludis/browse_tree.cc450
-rw-r--r--src/gtkpaludis/categories_list.cc143
-rw-r--r--src/gtkpaludis/categories_list.hh42
-rw-r--r--src/gtkpaludis/command_line.cc2
-rw-r--r--src/gtkpaludis/command_line.hh95
-rw-r--r--src/gtkpaludis/gtkpaludis.cc20
-rw-r--r--src/gtkpaludis/information_tree.cc161
-rw-r--r--src/gtkpaludis/information_tree.hh58
-rw-r--r--src/gtkpaludis/main_window.cc204
-rw-r--r--src/gtkpaludis/main_window.hh25
-rw-r--r--src/gtkpaludis/message_window.cc0
-rw-r--r--src/gtkpaludis/message_window.hh0
-rw-r--r--src/gtkpaludis/package_info.cc83
-rw-r--r--src/gtkpaludis/package_info.hh41
-rw-r--r--src/gtkpaludis/package_overview.cc152
-rw-r--r--src/gtkpaludis/package_overview.hh (renamed from src/gtkpaludis/browse_tree.hh)26
-rw-r--r--src/gtkpaludis/packages_list.cc189
-rw-r--r--src/gtkpaludis/packages_list.hh43
-rw-r--r--src/gtkpaludis/paludis_thread.cc111
-rw-r--r--src/gtkpaludis/paludis_thread.hh70
-rw-r--r--src/gtkpaludis/sync.cc100
-rw-r--r--src/gtkpaludis/sync.hh50
-rw-r--r--src/gtkpaludis/vte_message_window.cc136
-rw-r--r--src/gtkpaludis/vte_message_window.hh82
26 files changed, 1106 insertions, 1188 deletions
diff --git a/configure.ac b/configure.ac
index 5b89a28..589c046 100644
--- a/configure.ac
+++ b/configure.ac
@@ -544,7 +544,7 @@ if test "x$enable_gtk" = "xyes"; then
AC_SUBST(GMMPROC_DIR)
GMMPROC=$GMMPROC_DIR/gmmproc
AC_SUBST(GMMPROC)
- PKG_CHECK_MODULES(GTKDEPS, [gtkmm-2.4 >= 2.6.0 glibmm-2.4 >= 2.6.0 pangomm-1.4 gdkmm-2.4 vte >= 0.12.1],
+ PKG_CHECK_MODULES(GTKDEPS, [gtkmm-2.4 >= 2.6.0 glibmm-2.4 >= 2.6.0 pangomm-1.4 gdkmm-2.4 gthread-2.0 >= 2.6.0 vte >= 0.12.1],
[], [AC_MSG_ERROR([gtkmm-2.4 and vte-0.12.1 or later are required if --enable-gtk is used])])
AC_SUBST(GTKDEPS_CFLAGS)
AC_SUBST(GTKDEPS_LIBS)
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index e64e956..56e0288 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -19,11 +19,12 @@ bin_PROGRAMS = gtkpaludis
gtkpaludis_SOURCES = \
command_line.cc command_line.hh \
- browse_tree.cc browse_tree.hh \
- information_tree.cc information_tree.hh \
- vte_message_window.hh vte_message_window.cc \
main_window.cc main_window.hh \
- sync.cc sync.hh \
+ categories_list.cc categories_list.hh \
+ packages_list.cc packages_list.hh \
+ package_info.cc package_info.hh \
+ package_overview.cc package_overview.hh \
+ paludis_thread.cc paludis_thread.hh \
gtkpaludis.cc
gtkpaludis_LDADD = \
diff --git a/src/gtkpaludis/browse_tree.cc b/src/gtkpaludis/browse_tree.cc
deleted file mode 100644
index fda7a3c..0000000
--- a/src/gtkpaludis/browse_tree.cc
+++ /dev/null
@@ -1,450 +0,0 @@
-/* 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 "browse_tree.hh"
-#include "information_tree.hh"
-#include "main_window.hh"
-#include "sync.hh"
-#include "vtemm/reaper.hh"
-
-#include <gtkmm/treestore.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/messagedialog.h>
-
-#include <paludis/environment/default/default_environment.hh>
-#include <paludis/util/log.hh>
-#include <paludis/syncer.hh>
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <iostream>
-
-using namespace paludis;
-
-namespace
-{
- class BrowseTreeColumns;
-
- class BrowseTreeDisplayData :
- public InternalCounted<BrowseTreeDisplayData>
- {
- private:
- bool _has_children;
-
- protected:
- BrowseTreeDisplayData();
-
- virtual void load_children(
- Glib::RefPtr<Gtk::TreeStore>,
- const BrowseTreeColumns & columns,
- Gtk::TreeModel::iterator) const = 0;
-
- public:
- virtual ~BrowseTreeDisplayData();
-
- virtual void display(InformationTree * const information_tree) const = 0;
-
- virtual void sync() const
- {
- }
-
- virtual void need_children(
- Glib::RefPtr<Gtk::TreeStore> model,
- const BrowseTreeColumns & columns,
- Gtk::TreeModel::iterator us)
- {
- if (! _has_children)
- {
- load_children(model, columns, us);
- _has_children = true;
- }
- }
-
- class DefaultablePointer :
- public Pointer
- {
- public:
- DefaultablePointer() :
- Pointer(0)
- {
- }
-
- template <typename T_>
- DefaultablePointer(T_ v) :
- Pointer(v)
- {
- }
- };
- };
-
- class BrowseTreeColumns :
- public Gtk::TreeModel::ColumnRecord
- {
- public:
- BrowseTreeColumns();
- ~BrowseTreeColumns();
-
- Gtk::TreeModelColumn<Glib::ustring> col_item;
- Gtk::TreeModelColumn<BrowseTreeDisplayData::DefaultablePointer> col_data;
- };
-
- class BrowseTreeDisplayTopData :
- public BrowseTreeDisplayData
- {
- protected:
- virtual void load_children(
- Glib::RefPtr<Gtk::TreeStore>,
- const BrowseTreeColumns &,
- Gtk::TreeModel::iterator) const
- {
- }
-
- public:
- virtual void display(InformationTree * const information_tree) const
- {
- information_tree->show_top();
- }
- };
-
- class BrowseTreeDisplayVersionData :
- public BrowseTreeDisplayData
- {
- private:
- RepositoryName _r;
- QualifiedPackageName _q;
- VersionSpec _v;
-
- protected:
- virtual void load_children(
- Glib::RefPtr<Gtk::TreeStore>,
- const BrowseTreeColumns &,
- Gtk::TreeModel::iterator) const
- {
- }
-
- public:
- BrowseTreeDisplayVersionData(const RepositoryName & r,
- const QualifiedPackageName q, const VersionSpec & v) :
- _r(r),
- _q(q),
- _v(v)
- {
- }
-
- virtual void display(InformationTree * const information_tree) const
- {
- information_tree->show_version(_r, _q, _v);
- }
- };
-
- class BrowseTreeDisplayPackageData :
- public BrowseTreeDisplayData
- {
- private:
- RepositoryName _r;
- QualifiedPackageName _q;
-
- protected:
- virtual void load_children(
- Glib::RefPtr<Gtk::TreeStore> model,
- const BrowseTreeColumns & columns,
- Gtk::TreeModel::iterator us) const
- {
- Repository::ConstPointer repo(
- DefaultEnvironment::get_instance()->package_database()->fetch_repository(_r));
-
- VersionSpecCollection::ConstPointer vers(repo->version_specs(_q));
- for (VersionSpecCollection::Iterator ver(vers->begin()), ver_end(vers->end()) ;
- ver != ver_end ; ++ver)
- {
- Gtk::TreeModel::Row ver_row = *(model->append(us->children()));
- ver_row[columns.col_item] = stringify(*ver);
- ver_row[columns.col_data] = BrowseTreeDisplayData::Pointer(
- new BrowseTreeDisplayVersionData(_r, _q, *ver));
- }
- }
-
- public:
- BrowseTreeDisplayPackageData(const RepositoryName & r,
- const QualifiedPackageName q) :
- _r(r),
- _q(q)
- {
- }
-
- virtual void display(InformationTree * const information_tree) const
- {
- information_tree->show_package(_r, _q);
- }
- };
-
- class BrowseTreeDisplayCategoryData :
- public BrowseTreeDisplayData
- {
- private:
- RepositoryName _r;
- CategoryNamePart _c;
-
- protected:
- virtual void load_children(
- Glib::RefPtr<Gtk::TreeStore> model,
- const BrowseTreeColumns & columns,
- Gtk::TreeModel::iterator us) const
- {
- Repository::ConstPointer repo(
- DefaultEnvironment::get_instance()->package_database()->fetch_repository(_r));
-
- QualifiedPackageNameCollection::ConstPointer pkgs(repo->package_names(_c));
- for (QualifiedPackageNameCollection::Iterator pkg(pkgs->begin()), pkg_end(pkgs->end()) ;
- pkg != pkg_end ; ++pkg)
- {
- Gtk::TreeModel::Row pkg_row = *(model->append(us->children()));
- pkg_row[columns.col_item] = stringify(pkg->package);
- pkg_row[columns.col_data] = BrowseTreeDisplayData::Pointer(
- new BrowseTreeDisplayPackageData(_r, *pkg));
- }
- }
-
- public:
- BrowseTreeDisplayCategoryData(const RepositoryName & r,
- const CategoryNamePart c) :
- _r(r),
- _c(c)
- {
- }
-
- virtual void display(InformationTree * const information_tree) const
- {
- information_tree->show_category(_r, _c);
- }
- };
-
- class BrowseTreeDisplayRepositoryData :
- public BrowseTreeDisplayData
- {
- private:
- RepositoryName _r;
-
- protected:
- virtual void load_children(
- Glib::RefPtr<Gtk::TreeStore> model,
- const BrowseTreeColumns & columns,
- Gtk::TreeModel::iterator us) const
- {
- Repository::ConstPointer repo(
- DefaultEnvironment::get_instance()->package_database()->fetch_repository(_r));
-
- CategoryNamePartCollection::ConstPointer cats(repo->category_names());
- for (CategoryNamePartCollection::Iterator cat(cats->begin()), cat_end(cats->end()) ;
- cat != cat_end ; ++cat)
- {
- Gtk::TreeModel::Row cat_row = *(model->append(us->children()));
- cat_row[columns.col_item] = stringify(*cat);
- cat_row[columns.col_data] = BrowseTreeDisplayData::Pointer(
- new BrowseTreeDisplayCategoryData(_r, *cat));
- }
- }
-
- public:
- BrowseTreeDisplayRepositoryData(const RepositoryName & r) :
- _r(r)
- {
- }
-
- virtual void display(InformationTree * const information_tree) const
- {
- information_tree->show_repository(_r);
- }
-
- virtual void sync() const
- {
- OurSyncTask task;
- task.add_target(stringify(_r));
- task.execute();
- }
-
- };
-}
-
-BrowseTreeDisplayData::BrowseTreeDisplayData() :
- _has_children(false)
-{
-}
-
-BrowseTreeDisplayData::~BrowseTreeDisplayData()
-{
-}
-
-
-BrowseTreeColumns::BrowseTreeColumns()
-{
- add(col_item);
- add(col_data);
-}
-
-BrowseTreeColumns::~BrowseTreeColumns()
-{
-}
-
-namespace paludis
-{
- template<>
- struct Implementation<BrowseTree> :
- InternalCounted<Implementation<BrowseTree> >
- {
- MainWindow * const main_window;
- InformationTree * const information_tree;
-
- BrowseTreeColumns columns;
- Glib::RefPtr<Gtk::TreeStore> model;
-
- Gtk::Menu popup_menu;
-
- pid_t paludis_child;
-
- Implementation(MainWindow * const m, InformationTree * const i) :
- main_window(m),
- information_tree(i),
- paludis_child(-1)
- {
- }
-
- virtual ~Implementation()
- {
- }
- };
-}
-
-BrowseTree::BrowseTree(MainWindow * const main_window,
- InformationTree * const information_tree) :
- PrivateImplementationPattern<BrowseTree>(new Implementation<BrowseTree>(
- main_window, information_tree))
-{
- _imp->model = Gtk::TreeStore::create(_imp->columns);
- set_model(_imp->model);
-
- Gtk::TreeModel::Row repositories_row = *(_imp->model->append());
- repositories_row[_imp->columns.col_item] = "Repositories";
- repositories_row[_imp->columns.col_data] = BrowseTreeDisplayData::DefaultablePointer(
- new BrowseTreeDisplayTopData);
-
- for (PackageDatabase::RepositoryIterator
- r(DefaultEnvironment::get_instance()->package_database()->begin_repositories()),
- r_end(DefaultEnvironment::get_instance()->package_database()->end_repositories()) ;
- r != r_end ; ++r)
- {
- Gtk::TreeModel::Row repository_row = *(_imp->model->append(repositories_row.children()));
- repository_row[_imp->columns.col_item] = stringify((*r)->name());
- repository_row[_imp->columns.col_data] = BrowseTreeDisplayData::Pointer(
- new BrowseTreeDisplayRepositoryData((*r)->name()));
- }
-
- append_column("Item", _imp->columns.col_item);
- get_selection()->signal_changed().connect(sigc::mem_fun(*this, &BrowseTree::on_changed));
- Vte::Reaper::get_instance()->signal_child_exited().connect(sigc::mem_fun(*this, &BrowseTree::on_child_process_exited));
-
- /* popup menu */
- _imp->popup_menu.items().push_back(Gtk::Menu_Helpers::MenuElem("_Sync",
- sigc::mem_fun(*this, &BrowseTree::on_menu_sync)));
- _imp->popup_menu.accelerate(*this);
-}
-
-BrowseTree::~BrowseTree()
-{
-}
-
-void
-BrowseTree::on_changed()
-{
- Gtk::TreeModel::iterator i(get_selection()->get_selected());
- if (i)
- {
- Gtk::TreeModel::Row row(*i);
- BrowseTreeDisplayData::Pointer(row[_imp->columns.col_data])->need_children(_imp->model,
- _imp->columns, i);
- BrowseTreeDisplayData::Pointer(row[_imp->columns.col_data])->display(
- _imp->information_tree);
- }
-}
-
-void
-BrowseTree::on_menu_sync()
-{
- Glib::RefPtr<Gtk::TreeView::Selection> selection(get_selection());
- if (selection)
- {
- Gtk::TreeModel::iterator i(selection->get_selected());
- if (i)
- {
- _imp->main_window->set_children_sensitive(false);
-
- pid_t child(fork());
- if (0 == child)
- {
- try
- {
- BrowseTreeDisplayData::Pointer((*i)[_imp->columns.col_data])->sync();
- _exit(0);
- }
- catch (const SyncFailedError & e)
- {
- _exit(1);
- }
- }
- else if (-1 == child)
- throw InternalError(PALUDIS_HERE, "fork failed");
- else
- {
- Log::get_instance()->message(ll_debug, lc_no_context,
- "Forked child process " + stringify(child));
- _imp->paludis_child = child;
- Vte::Reaper::get_instance()->add_child(child);
- }
- }
- }
-}
-
-bool
-BrowseTree::on_button_press_event(GdkEventButton * our_event)
-{
- bool result(TreeView::on_button_press_event(our_event));
-
- if (our_event->type == GDK_BUTTON_PRESS && our_event->button == 3)
- _imp->popup_menu.popup(our_event->button, our_event->time);
-
- return result;
-}
-
-void
-BrowseTree::on_child_process_exited(int, int status)
-{
- if (-1 == _imp->paludis_child)
- return;
-
- if (0 == status)
- Log::get_instance()->message(ll_debug, lc_no_context, "child " + stringify(_imp->paludis_child)
- + " exited with success");
- else
- Log::get_instance()->message(ll_debug, lc_no_context, "child " + stringify(_imp->paludis_child)
- + " exited with failure code " + stringify(status));
-
- _imp->paludis_child = -1;
- _imp->main_window->set_children_sensitive(true);
-}
-
diff --git a/src/gtkpaludis/categories_list.cc b/src/gtkpaludis/categories_list.cc
new file mode 100644
index 0000000..6d38013
--- /dev/null
+++ b/src/gtkpaludis/categories_list.cc
@@ -0,0 +1,143 @@
+/* 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 "categories_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_category;
+
+ Columns()
+ {
+ add(col_category);
+ }
+ };
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<CategoriesList> :
+ InternalCounted<Implementation<CategoriesList> >
+ {
+ Columns columns;
+ Glib::RefPtr<Gtk::ListStore> model;
+
+ Implementation() :
+ model(Gtk::ListStore::create(columns))
+ {
+ }
+
+ void add_categories(const std::set<CategoryNamePart> & c)
+ {
+ for (std::set<CategoryNamePart>::const_iterator n(c.begin()), n_end(c.end()) ; n != n_end ; ++n)
+ {
+ Gtk::TreeModel::Row row = *(model->append());
+ row[columns.col_category] = stringify(*n);
+ }
+ }
+ };
+}
+
+namespace
+{
+ class Populate :
+ public PaludisThread::Launchable
+ {
+ private:
+ Implementation<CategoriesList> * const _imp;
+
+ public:
+ Populate(Implementation<CategoriesList> * const list) :
+ _imp(list)
+ {
+ }
+
+ virtual void operator() ();
+ };
+
+ void
+ Populate::operator() ()
+ {
+ std::set<CategoryNamePart> names;
+
+ dispatch(sigc::bind<1>(sigc::mem_fun(MainWindow::get_instance(),
+ &MainWindow::push_status), "Loading category 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)
+ {
+ dispatch(sigc::bind<1>(sigc::mem_fun(MainWindow::get_instance(),
+ &MainWindow::push_status), "Loading category names from '" +
+ stringify((*r)->name()) + "'..."));
+
+ CategoryNamePartCollection::ConstPointer cats((*r)->category_names());
+ std::copy(cats->begin(), cats->end(), std::inserter(names, names.end()));
+
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
+ }
+
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
+ dispatch(sigc::bind<1>(sigc::mem_fun(_imp, &Implementation<CategoriesList>::add_categories), names));
+ }
+}
+
+CategoriesList::CategoriesList() :
+ PrivateImplementationPattern<CategoriesList>(new Implementation<CategoriesList>)
+{
+ set_model(_imp->model);
+ append_column("Category", _imp->columns.col_category);
+}
+
+CategoriesList::~CategoriesList()
+{
+}
+
+void
+CategoriesList::populate()
+{
+ PaludisThread::get_instance()->launch(Populate::Pointer(new Populate(_imp.raw_pointer())));
+}
+
+CategoryNamePart
+CategoriesList::current_category()
+{
+ Gtk::TreeModel::iterator i(get_selection()->get_selected());
+ if (i)
+ return CategoryNamePart(stringify((*i)[_imp->columns.col_category]));
+ else
+ return CategoryNamePart("no-category");
+}
+
diff --git a/src/gtkpaludis/categories_list.hh b/src/gtkpaludis/categories_list.hh
new file mode 100644
index 0000000..c20f875
--- /dev/null
+++ b/src/gtkpaludis/categories_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_CATEGORIES_LIST_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_CATEGORIES_LIST_HH 1
+
+#include <gtkmm/treeview.h>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+
+namespace gtkpaludis
+{
+ class CategoriesList :
+ public Gtk::TreeView,
+ private paludis::PrivateImplementationPattern<CategoriesList>
+ {
+ public:
+ CategoriesList();
+ virtual ~CategoriesList();
+
+ void populate();
+ paludis::CategoryNamePart current_category();
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/command_line.cc b/src/gtkpaludis/command_line.cc
index 61ae1b4..72582ea 100644
--- a/src/gtkpaludis/command_line.cc
+++ b/src/gtkpaludis/command_line.cc
@@ -19,6 +19,8 @@
#include "command_line.hh"
+using namespace gtkpaludis;
+
CommandLine::CommandLine() :
ArgsHandler(),
diff --git a/src/gtkpaludis/command_line.hh b/src/gtkpaludis/command_line.hh
index 399eb64..42422ab 100644
--- a/src/gtkpaludis/command_line.hh
+++ b/src/gtkpaludis/command_line.hh
@@ -30,69 +30,72 @@
/**
* Our command line.
*/
-class CommandLine :
- public paludis::args::ArgsHandler,
- public paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonAsNeededTag>
+namespace gtkpaludis
{
- friend class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonAsNeededTag>;
-
- private:
- /// Constructor.
- CommandLine();
+ class CommandLine :
+ public paludis::args::ArgsHandler,
+ public paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonAsNeededTag>
+ {
+ friend class paludis::InstantiationPolicy<CommandLine, paludis::instantiation_method::SingletonAsNeededTag>;
- /// Destructor.
- ~CommandLine();
+ private:
+ /// Constructor.
+ CommandLine();
- public:
- ///\name Program information
- ///\{
+ /// Destructor.
+ ~CommandLine();
- virtual std::string app_name() const;
- virtual std::string app_synopsis() const;
- virtual std::string app_description() const;
+ public:
+ ///\name Program information
+ ///\{
- ///\}
+ virtual std::string app_name() const;
+ virtual std::string app_synopsis() const;
+ virtual std::string app_description() const;
- /// \name Action arguments
- ///\{
+ ///\}
- /// Action arguments.
- paludis::args::ArgsGroup action_args;
+ /// \name Action arguments
+ ///\{
- /// --version
- paludis::args::SwitchArg a_version;
+ /// Action arguments.
+ paludis::args::ArgsGroup action_args;
- /// --help
- paludis::args::SwitchArg a_help;
+ /// --version
+ paludis::args::SwitchArg a_version;
- ///\}
+ /// --help
+ paludis::args::SwitchArg a_help;
- /// \name General arguments
- ///\{
+ ///\}
- /// General arguments.
- paludis::args::ArgsGroup general_args;
+ /// \name General arguments
+ ///\{
- /// --log-level
- paludis::args::EnumArg a_log_level;
+ /// General arguments.
+ paludis::args::ArgsGroup general_args;
- /// --config-suffix
- paludis::args::StringArg a_config_suffix;
+ /// --log-level
+ paludis::args::EnumArg a_log_level;
- ///\}
-};
+ /// --config-suffix
+ paludis::args::StringArg a_config_suffix;
-/**
- * Show the help message.
- */
-struct DoHelp
-{
- const std::string message;
+ ///\}
+ };
- DoHelp(const std::string & m = "") :
- message(m)
+ /**
+ * Show the help message.
+ */
+ struct DoHelp
{
- }
-};
+ const std::string message;
+
+ DoHelp(const std::string & m = "") :
+ message(m)
+ {
+ }
+ };
+}
#endif
diff --git a/src/gtkpaludis/gtkpaludis.cc b/src/gtkpaludis/gtkpaludis.cc
index f5e1f93..72d7644 100644
--- a/src/gtkpaludis/gtkpaludis.cc
+++ b/src/gtkpaludis/gtkpaludis.cc
@@ -35,6 +35,8 @@
#include "main_window.hh"
using namespace paludis;
+using namespace gtkpaludis;
+
using std::cout;
using std::cerr;
using std::endl;
@@ -58,7 +60,7 @@ namespace
static bool _gtkmm_initialized;
public:
- TryMain(int& argc, char**& argv) :
+ TryMain(int argc, char * argv[]) :
Gtk::Main()
{
_gtkmm_initialized = gtk_init_check(&argc, &argv);
@@ -73,7 +75,7 @@ namespace
{
if (! _gtkmm_initialized)
throw GtkInitFailed();
-
+
Gtk::Main::run(window);
}
@@ -81,7 +83,7 @@ namespace
{
if (! _gtkmm_initialized)
throw GtkInitFailed();
-
+
Gtk::Main::run();
}
};
@@ -170,6 +172,8 @@ main(int argc, char * argv[])
std::string::size_type last_slash(paludis_command.rfind('/'));
if (std::string::npos == last_slash)
last_slash = 0;
+ if (0 == paludis_command.compare(last_slash, 3, "lt-"))
+ paludis_command.erase(last_slash, 3);
if (0 == paludis_command.compare(last_slash, 3, "gtk"))
paludis_command.erase(last_slash, 3);
@@ -190,6 +194,9 @@ main(int argc, char * argv[])
if (! gui_kit.initialized())
throw GtkInitFailed();
+ Glib::thread_init();
+ Glib::signal_idle().connect(sigc::bind_return(sigc::mem_fun(*MainWindow::get_instance(),
+ &MainWindow::populate), false));
TryMain::run(*MainWindow::get_instance());
}
}
@@ -280,9 +287,10 @@ main(int argc, char * argv[])
dialog.run();
}
else
- { cout << endl;
- cerr << "Unhandled exception:" << endl
- << " * Unknown exception type. Ouch..." << endl;
+ {
+ cout << endl;
+ cerr << "Unhandled exception:" << endl
+ << " * Unknown exception type. Ouch..." << endl;
}
return EXIT_FAILURE;
}
diff --git a/src/gtkpaludis/information_tree.cc b/src/gtkpaludis/information_tree.cc
deleted file mode 100644
index 022be1c..0000000
--- a/src/gtkpaludis/information_tree.cc
+++ /dev/null
@@ -1,161 +0,0 @@
-/* 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 "information_tree.hh"
-#include <gtkmm/treestore.h>
-#include <paludis/environment/default/default_environment.hh>
-
-using namespace paludis;
-
-InformationTreeColumns::InformationTreeColumns()
-{
- add(col_key);
- add(col_value);
-}
-
-InformationTreeColumns::~InformationTreeColumns()
-{
-}
-
-namespace paludis
-{
- template<>
- struct Implementation<InformationTree> :
- InternalCounted<Implementation<InformationTree> >
- {
- InformationTreeColumns columns;
- Glib::RefPtr<Gtk::TreeStore> model;
- };
-}
-
-InformationTree::InformationTree() :
- PrivateImplementationPattern<InformationTree>(new Implementation<InformationTree>)
-{
- _imp->model = Gtk::TreeStore::create(_imp->columns);
- set_model(_imp->model);
-
- append_column("Key", _imp->columns.col_key);
- append_column("Value", _imp->columns.col_value);
-}
-
-InformationTree::~InformationTree()
-{
-}
-
-void
-InformationTree::show_top()
-{
- set_model(Glib::RefPtr<Gtk::TreeStore>(0));
- _imp->model = Gtk::TreeStore::create(_imp->columns);
-
- set_model(_imp->model);
-}
-
-void
-InformationTree::show_repository(const RepositoryName & r)
-{
- Repository::ConstPointer repo(DefaultEnvironment::get_instance()->package_database()->fetch_repository(r));
-
- set_model(Glib::RefPtr<Gtk::TreeStore>(0));
- _imp->model = Gtk::TreeStore::create(_imp->columns);
-
- Gtk::TreeModel::Row name_row(*(_imp->model->append()));
- name_row[_imp->columns.col_key] = "name";
- name_row[_imp->columns.col_value] = stringify(repo->name());
-
- RepositoryInfo::ConstPointer info(repo->info(false));
- for (RepositoryInfo::SectionIterator section(info->begin_sections()),
- section_end(info->end_sections()) ; section != section_end ; ++section)
- {
- Gtk::TreeModel::Row section_row(*(_imp->model->append()));
- section_row[_imp->columns.col_key] = (*section)->heading();
-
- for (RepositoryInfoSection::KeyValueIterator kv((*section)->begin_kvs()),
- kv_end((*section)->end_kvs()) ; kv != kv_end ; ++kv)
- {
- Gtk::TreeModel::Row kv_row(*(_imp->model->append(section_row.children())));
- kv_row[_imp->columns.col_key] = kv->first;
- kv_row[_imp->columns.col_value] = kv->second;
- }
- }
-
- set_model(_imp->model);
-}
-
-void
-InformationTree::show_category(const RepositoryName & r, const CategoryNamePart & c)
-{
- Repository::ConstPointer repo(DefaultEnvironment::get_instance()->package_database()->fetch_repository(r));
-
- set_model(Glib::RefPtr<Gtk::TreeStore>(0));
- _imp->model = Gtk::TreeStore::create(_imp->columns);
-
- Gtk::TreeModel::Row name_row(*(_imp->model->append()));
- name_row[_imp->columns.col_key] = "name";
- name_row[_imp->columns.col_value] = stringify(c);
-
- set_model(_imp->model);
-}
-
-void
-InformationTree::show_package(const RepositoryName & r, const QualifiedPackageName & q)
-{
- Repository::ConstPointer repo(DefaultEnvironment::get_instance()->package_database()->fetch_repository(r));
-
- set_model(Glib::RefPtr<Gtk::TreeStore>(0));
- _imp->model = Gtk::TreeStore::create(_imp->columns);
-
- Gtk::TreeModel::Row name_row(*(_imp->model->append()));
- name_row[_imp->columns.col_key] = "name";
- name_row[_imp->columns.col_value] = stringify(q);
-
- set_model(_imp->model);
-}
-
-
-void
-InformationTree::show_version(const RepositoryName & r, const QualifiedPackageName & q,
- const VersionSpec & v)
-{
- Repository::ConstPointer repo(DefaultEnvironment::get_instance()->package_database()->fetch_repository(r));
-
- set_model(Glib::RefPtr<Gtk::TreeStore>(0));
- _imp->model = Gtk::TreeStore::create(_imp->columns);
-
- Gtk::TreeModel::Row name_row(*(_imp->model->append()));
- name_row[_imp->columns.col_key] = "name";
- name_row[_imp->columns.col_value] = stringify(q);
-
- Gtk::TreeModel::Row version_row(*(_imp->model->append()));
- version_row[_imp->columns.col_key] = "version";
- version_row[_imp->columns.col_value] = stringify(v);
-
- VersionMetadata::ConstPointer metadata(repo->version_metadata(q, v));
-
- Gtk::TreeModel::Row description_row(*(_imp->model->append()));
- description_row[_imp->columns.col_key] = "description";
- description_row[_imp->columns.col_value] = metadata->description;
-
- Gtk::TreeModel::Row homepage_row(*(_imp->model->append()));
- description_row[_imp->columns.col_key] = "homepage";
- description_row[_imp->columns.col_value] = metadata->homepage;
-
- set_model(_imp->model);
-}
-
diff --git a/src/gtkpaludis/information_tree.hh b/src/gtkpaludis/information_tree.hh
deleted file mode 100644
index 224c24e..0000000
--- a/src/gtkpaludis/information_tree.hh
+++ /dev/null
@@ -1,58 +0,0 @@
-/* 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_INFORMATION_TREE_HH
-#define PALUDIS_GUARD_SRC_GTKPALUDIS_INFORMATION_TREE_HH 1
-
-#include <gtkmm/treeview.h>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/name.hh>
-#include <paludis/version_spec.hh>
-
-namespace paludis
-{
- class InformationTreeColumns :
- public Gtk::TreeModel::ColumnRecord
- {
- public:
- InformationTreeColumns();
- ~InformationTreeColumns();
-
- Gtk::TreeModelColumn<Glib::ustring> col_key;
- Gtk::TreeModelColumn<Glib::ustring> col_value;
- };
-
- class InformationTree :
- public Gtk::TreeView,
- private PrivateImplementationPattern<InformationTree>
- {
- public:
- InformationTree();
- ~InformationTree();
-
- void show_top();
- void show_repository(const RepositoryName &);
- void show_category(const RepositoryName &, const CategoryNamePart &);
- void show_package(const RepositoryName &, const QualifiedPackageName &);
- void show_version(const RepositoryName &, const QualifiedPackageName &,
- const VersionSpec &);
- };
-}
-
-#endif
diff --git a/src/gtkpaludis/main_window.cc b/src/gtkpaludis/main_window.cc
index 1506650..d774ed3 100644
--- a/src/gtkpaludis/main_window.cc
+++ b/src/gtkpaludis/main_window.cc
@@ -18,122 +18,184 @@
*/
#include "main_window.hh"
-#include "browse_tree.hh"
-#include "information_tree.hh"
-#include "vte_message_window.hh"
+#include "categories_list.hh"
+#include "packages_list.hh"
+#include "package_info.hh"
-#include <paludis/about.hh>
-#include <paludis/util/stringify.hh>
+#include <paludis/util/log.hh>
#include <gtkmm/box.h>
#include <gtkmm/button.h>
#include <gtkmm/entry.h>
-#include <gtkmm/frame.h>
#include <gtkmm/label.h>
-#include <gtkmm/paned.h>
+#include <gtkmm/notebook.h>
#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/separator.h>
#include <gtkmm/stock.h>
-#include <gtkmm/textview.h>
+#include <gtkmm/table.h>
+#include <list>
+
+using namespace gtkpaludis;
using namespace paludis;
namespace paludis
{
template<>
struct Implementation<MainWindow> :
- InternalCounted<MainWindow>
+ InternalCounted<Implementation<MainWindow> >
{
- Gtk::VBox main_container;
+ unsigned lock_count;
- Gtk::HBox search_container;
- Gtk::Label search_label;
- Gtk::Entry search_box;
- Gtk::Button search_button;
+ Glib::Dispatcher dispatcher;
- Gtk::VPaned browse_information_messages_pane;
- Gtk::HPaned browse_information_pane;
+ Gtk::Table main_table;
- Gtk::Frame information_frame;
- Gtk::ScrolledWindow information_window;
- InformationTree information_tree;
+ Gtk::Notebook main_notebook;
+ Gtk::Table packages_page;
+ Gtk::Table sets_page;
+ Gtk::Table repositories_page;
- Gtk::Frame browse_frame;
- Gtk::ScrolledWindow browse_window;
- BrowseTree browse_tree;
+ Gtk::ScrolledWindow status_label_box;
+ Gtk::Label status_label;
- Gtk::Frame messages_frame;
- Gtk::ScrolledWindow messages_window;
- VteMessageWindow vte_messages;
+ Gtk::HBox packages_search;
+ Gtk::Entry packages_search_entry;
+ Gtk::Button packages_search_button;
+ Gtk::HSeparator packages_search_button_sep;
- Implementation(MainWindow * const main_window);
- };
-}
+ Gtk::ScrolledWindow categories_list_scroll;
+ CategoriesList categories_list;
-Implementation<MainWindow>::Implementation(MainWindow * const main_window) :
- main_container(false, 5),
- search_container(false, 5),
- search_label(" Search: "),
- search_button(Gtk::Stock::FIND),
- information_frame(" Information: "),
- browse_frame(" Browse: "),
- browse_tree(main_window, &information_tree),
- messages_frame(" Messages: ")
-{
+ Gtk::ScrolledWindow packages_list_scroll;
+ PackagesList packages_list;
+
+ PackageInfo package_info;
+
+ std::list<std::string> status;
+
+ Implementation() :
+ lock_count(0),
+ main_table(1, 2, false),
+ packages_page(2, 3, false),
+ status_label("", Gtk::ALIGN_LEFT),
+ packages_search_button(Gtk::Stock::FIND)
+ {
+ }
+ };
}
MainWindow::MainWindow() :
- PrivateImplementationPattern<MainWindow>(new Implementation<MainWindow>(this))
+ PrivateImplementationPattern<MainWindow>(new Implementation<MainWindow>)
{
- set_title("gtkPaludis " + stringify(PALUDIS_VERSION_MAJOR) + "." +
- stringify(PALUDIS_VERSION_MINOR) + "." +
- stringify(PALUDIS_VERSION_MICRO));
-
+ set_title("gtkpaludis");
+ set_border_width(2);
set_default_size(600, 400);
- set_border_width(5);
- add(_imp->main_container);
+ _imp->main_notebook.set_border_width(5);
+ _imp->main_notebook.append_page(_imp->packages_page, "Packages");
+ _imp->main_notebook.append_page(_imp->sets_page, "Sets");
+ _imp->main_notebook.append_page(_imp->repositories_page, "Repositories");
- _imp->main_container.pack_start(_imp->search_container, Gtk::PACK_SHRINK);
- _imp->main_container.pack_end(_imp->browse_information_messages_pane, Gtk::PACK_EXPAND_WIDGET);
+ add(_imp->main_table);
+ _imp->main_table.attach(_imp->main_notebook, 0, 1, 0, 1);
+ _imp->main_table.attach(_imp->status_label_box, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(0));
+ _imp->status_label_box.set_border_width(5);
+ _imp->status_label_box.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_NEVER);
+ _imp->status_label_box.add(_imp->status_label);
- _imp->search_container.pack_start(_imp->search_label, Gtk::PACK_SHRINK);
- _imp->search_container.pack_start(_imp->search_box);
- _imp->search_container.pack_end(_imp->search_button, Gtk::PACK_SHRINK);
+ _imp->packages_page.set_col_spacings(5);
+ _imp->packages_page.set_row_spacings(5);
+ _imp->packages_page.set_border_width(5);
- _imp->browse_information_messages_pane.pack1(_imp->browse_information_pane);
- _imp->browse_information_messages_pane.pack2(_imp->messages_frame);
+ _imp->packages_search.pack_start(_imp->packages_search_entry, Gtk::PACK_EXPAND_WIDGET);
+ _imp->packages_search.pack_start(_imp->packages_search_button_sep, Gtk::PACK_SHRINK, 5);
+ _imp->packages_search.pack_end(_imp->packages_search_button, Gtk::PACK_SHRINK);
+ _imp->packages_search_entry.set_width_chars(30);
+ _imp->packages_page.attach(_imp->packages_search, 0, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(0));
- _imp->browse_information_pane.pack1(_imp->browse_frame);
- _imp->browse_information_pane.pack2(_imp->information_frame);
+ _imp->categories_list_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ _imp->categories_list_scroll.add(_imp->categories_list);
+ _imp->packages_page.attach(_imp->categories_list_scroll, 0, 1, 1, 2, Gtk::SHRINK, Gtk::FILL | Gtk::EXPAND);
- _imp->browse_frame.add(_imp->browse_window);
- _imp->browse_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- _imp->browse_window.set_border_width(5);
- _imp->browse_window.add(_imp->browse_tree);
+ _imp->packages_list_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
+ _imp->packages_list_scroll.add(_imp->packages_list);
+ _imp->packages_page.attach(_imp->packages_list_scroll, 1, 2, 1, 2);
- _imp->information_frame.add(_imp->information_window);
- _imp->information_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
- _imp->information_window.set_border_width(5);
- _imp->information_window.add(_imp->information_tree);
+ _imp->packages_page.attach(_imp->package_info, 0, 2, 2, 3);
- _imp->messages_frame.add(_imp->messages_window);
- _imp->messages_window.set_border_width(5);
- _imp->messages_window.add(_imp->vte_messages);
- _imp->messages_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ _imp->categories_list.get_selection()->signal_changed().connect(sigc::mem_fun(*this,
+ &MainWindow::_category_list_selection_changed));
+ _imp->packages_list.get_selection()->signal_changed().connect(sigc::mem_fun(*this,
+ &MainWindow::_package_list_selection_changed));
show_all_children();
}
+void
+MainWindow::_set_lock(bool value)
+{
+ set_sensitive(! value);
+}
+
MainWindow::~MainWindow()
{
}
void
-MainWindow::set_children_sensitive(bool value)
+MainWindow::populate()
+{
+ _imp->categories_list.populate();
+}
+
+void
+MainWindow::_category_list_selection_changed()
+{
+ CategoryNamePart c("dummy");
+ _imp->packages_list.populate(_imp->categories_list.current_category());
+}
+
+void
+MainWindow::_package_list_selection_changed()
+{
+ QualifiedPackageName c("dummy/dummy");
+ _imp->package_info.populate(_imp->packages_list.current_package());
+}
+
+void
+MainWindow::lock_controls()
+{
+ if (0 == _imp->lock_count++)
+ _set_lock(true);
+}
+
+void
+MainWindow::maybe_unlock_controls()
+{
+ if (0 == --_imp->lock_count)
+ _set_lock(false);
+}
+
+void
+MainWindow::push_status(const std::string & s)
+{
+ _imp->status.push_back(s);
+ _update_status();
+}
+
+void
+MainWindow::pop_status()
+{
+ _imp->status.pop_back();
+ _update_status();
+}
+
+void
+MainWindow::_update_status()
{
- _imp->browse_tree.set_sensitive(value);
- _imp->information_tree.set_sensitive(value);
- _imp->search_box.set_sensitive(value);
- _imp->search_button.set_sensitive(value);
+ if (_imp->status.empty())
+ _imp->status_label.set_label("");
+ else
+ _imp->status_label.set_label(_imp->status.back());
}
diff --git a/src/gtkpaludis/main_window.hh b/src/gtkpaludis/main_window.hh
index 6024075..0d8b9b9 100644
--- a/src/gtkpaludis/main_window.hh
+++ b/src/gtkpaludis/main_window.hh
@@ -21,24 +21,35 @@
#define PALUDIS_GUARD_SRC_GTKPALUDIS_MAIN_WINDOW_HH 1
#include <gtkmm/window.h>
-#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
-namespace paludis
+namespace gtkpaludis
{
class MainWindow :
- public Gtk::Window,
- private PrivateImplementationPattern<MainWindow>,
- public InstantiationPolicy<MainWindow, instantiation_method::SingletonAsNeededTag>
+ public paludis::InstantiationPolicy<MainWindow, paludis::instantiation_method::SingletonAsNeededTag>,
+ private paludis::PrivateImplementationPattern<MainWindow>,
+ public Gtk::Window
{
- friend class InstantiationPolicy<MainWindow, instantiation_method::SingletonAsNeededTag>;
+ friend class paludis::InstantiationPolicy<MainWindow, paludis::instantiation_method::SingletonAsNeededTag>;
private:
MainWindow();
virtual ~MainWindow();
+ void _category_list_selection_changed();
+ void _package_list_selection_changed();
+ void _set_lock(bool value);
+ void _update_status();
+
public:
- void set_children_sensitive(bool value);
+ virtual void populate();
+
+ void lock_controls();
+ void maybe_unlock_controls();
+
+ void push_status(const std::string &);
+ void pop_status();
};
}
diff --git a/src/gtkpaludis/message_window.cc b/src/gtkpaludis/message_window.cc
deleted file mode 100644
index e69de29..0000000
--- a/src/gtkpaludis/message_window.cc
+++ /dev/null
diff --git a/src/gtkpaludis/message_window.hh b/src/gtkpaludis/message_window.hh
deleted file mode 100644
index e69de29..0000000
--- a/src/gtkpaludis/message_window.hh
+++ /dev/null
diff --git a/src/gtkpaludis/package_info.cc b/src/gtkpaludis/package_info.cc
new file mode 100644
index 0000000..574ac7b
--- /dev/null
+++ b/src/gtkpaludis/package_info.cc
@@ -0,0 +1,83 @@
+/* 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 "package_info.hh"
+#include "package_overview.hh"
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/box.h>
+#include <gtkmm/button.h>
+#include <gtkmm/buttonbox.h>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PackageInfo> :
+ InternalCounted<Implementation<PackageInfo> >
+ {
+ Gtk::HBox overview_page;
+ Gtk::ScrolledWindow overview_page_main;
+ Gtk::VButtonBox overview_page_buttons;
+
+ Gtk::Button install_button;
+ Gtk::Button uninstall_button;
+
+ Gtk::ScrolledWindow metadata_page;
+
+ PackageOverview overview;
+
+ Implementation() :
+ install_button("Install"),
+ uninstall_button("Uninstall")
+ {
+ }
+ };
+}
+
+PackageInfo::PackageInfo() :
+ PrivateImplementationPattern<PackageInfo>(new Implementation<PackageInfo>)
+{
+ append_page(_imp->overview_page, "Overview");
+ append_page(_imp->metadata_page, "Metadata");
+
+ _imp->overview_page.pack_start(_imp->overview_page_main);
+ _imp->overview_page.pack_end(_imp->overview_page_buttons, Gtk::PACK_SHRINK);
+
+ _imp->overview_page_main.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ _imp->overview_page_main.add(_imp->overview);
+
+ _imp->overview_page_buttons.set_border_width(5);
+ _imp->overview_page_buttons.set_spacing(5);
+ _imp->overview_page_buttons.set_layout(Gtk::BUTTONBOX_START);
+ _imp->overview_page_buttons.add(_imp->install_button);
+ _imp->overview_page_buttons.add(_imp->uninstall_button);
+}
+
+PackageInfo::~PackageInfo()
+{
+}
+
+void
+PackageInfo::populate(const QualifiedPackageName & n)
+{
+ _imp->overview.populate(n);
+}
+
diff --git a/src/gtkpaludis/package_info.hh b/src/gtkpaludis/package_info.hh
new file mode 100644
index 0000000..51a439a
--- /dev/null
+++ b/src/gtkpaludis/package_info.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_PACKAGE_INFO_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_PACKAGE_INFO_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+#include <gtkmm/notebook.h>
+
+namespace gtkpaludis
+{
+ class PackageInfo :
+ private paludis::PrivateImplementationPattern<PackageInfo>,
+ public Gtk::Notebook
+ {
+ public:
+ PackageInfo();
+ virtual ~PackageInfo();
+
+ void populate(const paludis::QualifiedPackageName &);
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/package_overview.cc b/src/gtkpaludis/package_overview.cc
new file mode 100644
index 0000000..8fa2de6
--- /dev/null
+++ b/src/gtkpaludis/package_overview.cc
@@ -0,0 +1,152 @@
+/* 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 "package_overview.hh"
+#include "paludis_thread.hh"
+#include "main_window.hh"
+
+#include <paludis/environment/default/default_environment.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_left;
+ Gtk::TreeModelColumn<Glib::ustring> col_right;
+
+ Columns()
+ {
+ add(col_left);
+ add(col_right);
+ }
+ };
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PackageOverview> :
+ InternalCounted<Implementation<PackageOverview> >
+ {
+ PackageOverview * const overview;
+ Columns columns;
+ Glib::RefPtr<Gtk::TreeStore> model;
+
+ Implementation(PackageOverview * const o) :
+ overview(o),
+ model(Gtk::TreeStore::create(columns))
+ {
+ }
+
+ void set_model(const Glib::RefPtr<Gtk::TreeStore> & m)
+ {
+ model = m;
+ overview->set_model(model);
+ overview->expand_all();
+ }
+ };
+}
+
+PackageOverview::PackageOverview() :
+ PrivateImplementationPattern<PackageOverview>(new Implementation<PackageOverview>(this))
+{
+ set_headers_visible(false);
+ set_model(_imp->model);
+ append_column("Left", _imp->columns.col_left);
+ append_column("Right", _imp->columns.col_right);
+}
+
+PackageOverview::~PackageOverview()
+{
+}
+
+namespace
+{
+ class Populate :
+ public PaludisThread::Launchable
+ {
+ private:
+ Implementation<PackageOverview> * const _imp;
+ QualifiedPackageName _pkg;
+
+ public:
+ Populate(Implementation<PackageOverview> * const imp, const QualifiedPackageName & pkg) :
+ _imp(imp),
+ _pkg(pkg)
+ {
+ }
+
+ virtual void operator() ();
+ };
+
+ void
+ Populate::operator() ()
+ {
+ Glib::RefPtr<Gtk::TreeStore> model(Gtk::TreeStore::create(_imp->columns));
+ std::map<RepositoryName, Gtk::TreeModel::iterator> repository_rows;
+
+ Gtk::TreeModel::Row top_row = *model->append();
+ top_row[_imp->columns.col_left] = stringify(_pkg);
+ top_row[_imp->columns.col_right] = "";
+
+ dispatch(sigc::bind<1>(sigc::mem_fun(MainWindow::get_instance(),
+ &MainWindow::push_status), "Querying package versions..."));
+
+ PackageDatabaseEntryCollection::ConstPointer results(DefaultEnvironment::get_instance()->package_database()->query(
+ PackageDepAtom::Pointer(new PackageDepAtom(stringify(_pkg))), is_either));
+
+ 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)
+ {
+ r = repository_rows.insert(std::make_pair(i->repository, model->append(top_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;
+ }
+
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
+
+ dispatch(sigc::bind<1>(sigc::mem_fun(_imp, &Implementation<PackageOverview>::set_model), model));
+ }
+}
+
+void
+PackageOverview::populate(const QualifiedPackageName & name)
+{
+ if (name == QualifiedPackageName("no-category/no-package"))
+ _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/browse_tree.hh b/src/gtkpaludis/package_overview.hh
index e671792..3f569e8 100644
--- a/src/gtkpaludis/browse_tree.hh
+++ b/src/gtkpaludis/package_overview.hh
@@ -17,30 +17,24 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_SRC_GTKPALUDIS_BROWSE_TREE_HH
-#define PALUDIS_GUARD_SRC_GTKPALUDIS_BROWSE_TREE_HH 1
+#ifndef PALUDIS_GUARD_SRC_GTKPALUDIS_PACKAGE_OVERVIEW_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_PACKAGE_OVERVIEW_HH 1
-#include <gtkmm/treeview.h>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+#include <gtkmm/treeview.h>
-namespace paludis
+namespace gtkpaludis
{
- class InformationTree;
- class MainWindow;
-
- class BrowseTree :
+ class PackageOverview :
public Gtk::TreeView,
- private PrivateImplementationPattern<BrowseTree>
+ private paludis::PrivateImplementationPattern<PackageOverview>
{
public:
- BrowseTree(MainWindow * const, InformationTree * const);
- ~BrowseTree();
-
- virtual void on_changed();
- virtual void on_menu_sync();
+ PackageOverview();
+ virtual ~PackageOverview();
- virtual bool on_button_press_event(GdkEventButton *);
- virtual void on_child_process_exited(int, int);
+ void populate(const paludis::QualifiedPackageName &);
};
}
diff --git a/src/gtkpaludis/packages_list.cc b/src/gtkpaludis/packages_list.cc
new file mode 100644
index 0000000..de0c072
--- /dev/null
+++ b/src/gtkpaludis/packages_list.cc
@@ -0,0 +1,189 @@
+/* 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 "packages_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 <map>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+namespace
+{
+ class Columns :
+ public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+ Gtk::TreeModelColumn<Glib::ustring> col_package_display;
+ Gtk::TreeModelColumn<Glib::ustring> col_package_real;
+ Gtk::TreeModelColumn<Glib::ustring> col_description;
+
+ Columns()
+ {
+ add(col_package_display);
+ add(col_package_real);
+ add(col_description);
+ }
+ };
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PackagesList> :
+ InternalCounted<Implementation<PackagesList> >
+ {
+ Columns columns;
+ Glib::RefPtr<Gtk::ListStore> model;
+ PackagesList * const list;
+
+ Implementation(PackagesList * const l) :
+ model(Gtk::ListStore::create(columns)),
+ list(l)
+ {
+ }
+
+ void add_packages(const std::map<QualifiedPackageName, std::string> & s)
+ {
+ for (std::map<QualifiedPackageName, std::string>::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;
+ }
+
+ list->columns_autosize();
+ }
+ };
+}
+
+namespace
+{
+}
+
+PackagesList::PackagesList() :
+ PrivateImplementationPattern<PackagesList>(new Implementation<PackagesList>(this))
+{
+ set_model(_imp->model);
+ append_column("Package", _imp->columns.col_package_display);
+ append_column("Description", _imp->columns.col_description);
+}
+
+PackagesList::~PackagesList()
+{
+}
+
+namespace
+{
+ class Populate :
+ public PaludisThread::Launchable
+ {
+ private:
+ Implementation<PackagesList> * const _list;
+ CategoryNamePart _cat;
+
+ public:
+ Populate(Implementation<PackagesList> * const list, const CategoryNamePart & cat) :
+ _list(list),
+ _cat(cat)
+ {
+ }
+
+ virtual void operator() ();
+ };
+
+ void
+ Populate::operator() ()
+ {
+ std::map<QualifiedPackageName, std::string> names;
+
+ dispatch(sigc::bind<1>(sigc::mem_fun(MainWindow::get_instance(),
+ &MainWindow::push_status), "Loading package 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)
+ {
+ dispatch(sigc::bind<1>(sigc::mem_fun(MainWindow::get_instance(),
+ &MainWindow::push_status), "Loading package names from '" +
+ stringify((*r)->name()) + "'..."));
+
+ 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, ""));
+
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
+ }
+
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
+ dispatch(sigc::bind<1>(sigc::mem_fun(MainWindow::get_instance(),
+ &MainWindow::push_status), "Loading package descriptions..."));
+
+ for (std::map<QualifiedPackageName, std::string>::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));
+
+ if (results->empty())
+ continue;
+ i->second = DefaultEnvironment::get_instance()->package_database()->fetch_repository(
+ results->last()->repository)->version_metadata(results->last()->name,
+ results->last()->version)->description;
+ }
+
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
+ dispatch(sigc::bind<1>(sigc::mem_fun(_list, &Implementation<PackagesList>::add_packages), names));
+ }
+}
+
+void
+PackagesList::clear_packages()
+{
+ _imp->model->clear();
+}
+
+void
+PackagesList::populate(const CategoryNamePart & cat)
+{
+ clear_packages();
+ if (cat.data() != "no-category")
+ PaludisThread::get_instance()->launch(Populate::Pointer(new Populate(_imp.raw_pointer(), cat)));
+}
+
+QualifiedPackageName
+PackagesList::current_package()
+{
+ Gtk::TreeModel::iterator i(get_selection()->get_selected());
+ if (i)
+ return QualifiedPackageName(stringify((*i)[_imp->columns.col_package_real]));
+ else
+ return QualifiedPackageName("no-category/no-package");
+}
+
+
diff --git a/src/gtkpaludis/packages_list.hh b/src/gtkpaludis/packages_list.hh
new file mode 100644
index 0000000..1512994
--- /dev/null
+++ b/src/gtkpaludis/packages_list.hh
@@ -0,0 +1,43 @@
+/* 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_PACKAGES_LIST_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_PACKAGES_LIST_HH 1
+
+#include <gtkmm/treeview.h>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+
+namespace gtkpaludis
+{
+ class PackagesList :
+ public Gtk::TreeView,
+ private paludis::PrivateImplementationPattern<PackagesList>
+ {
+ public:
+ PackagesList();
+ virtual ~PackagesList();
+
+ void clear_packages();
+ void populate(const paludis::CategoryNamePart &);
+ paludis::QualifiedPackageName current_package();
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/paludis_thread.cc b/src/gtkpaludis/paludis_thread.cc
new file mode 100644
index 0000000..6e2d2a4
--- /dev/null
+++ b/src/gtkpaludis/paludis_thread.cc
@@ -0,0 +1,111 @@
+/* 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 "paludis_thread.hh"
+#include "main_window.hh"
+#include <paludis/util/log.hh>
+#include <glibmm/thread.h>
+
+using namespace paludis;
+using namespace gtkpaludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PaludisThread> :
+ InternalCounted<Implementation<PaludisThread> >
+ {
+ Glib::Dispatcher dispatcher;
+ Glib::Mutex queue_mutex;
+ std::deque<sigc::slot<void> > * queue;
+
+ Implementation() :
+ queue(new std::deque<sigc::slot<void> >)
+ {
+ }
+
+ ~Implementation()
+ {
+ delete queue;
+ }
+ };
+}
+
+PaludisThread::PaludisThread() :
+ PrivateImplementationPattern<PaludisThread>(new Implementation<PaludisThread>)
+{
+ _imp->dispatcher.connect(sigc::mem_fun(this, &PaludisThread::_queue_run));
+}
+
+PaludisThread::~PaludisThread()
+{
+}
+
+PaludisThread::Launchable::Launchable()
+{
+}
+
+PaludisThread::Launchable::~Launchable()
+{
+}
+
+void
+PaludisThread::launch(Launchable::Pointer l)
+{
+ MainWindow::get_instance()->lock_controls();
+ Glib::Thread::create(sigc::bind<1>(sigc::mem_fun(this, &PaludisThread::_thread_func), l), false);
+}
+
+void
+PaludisThread::Launchable::dispatch(const sigc::slot<void> & s)
+{
+ PaludisThread::get_instance()->_queue_add(s);
+}
+
+void
+PaludisThread::_queue_add(const sigc::slot<void> & s)
+{
+ {
+ Glib::Mutex::Lock lock(_imp->queue_mutex);
+ _imp->queue->push_back(s);
+ }
+ _imp->dispatcher();
+}
+
+void
+PaludisThread::_queue_run()
+{
+ std::deque<sigc::slot<void> > * d(new std::deque<sigc::slot<void> >);
+ {
+ /* do as little as possible inside the mutex lock */
+ Glib::Mutex::Lock lock(_imp->queue_mutex);
+ std::swap(d, _imp->queue);
+ }
+
+ std::for_each(d->begin(), d->end(), std::mem_fun_ref(&sigc::slot<void>::operator()));
+ delete d;
+}
+
+void
+PaludisThread::_thread_func(PaludisThread::Launchable::Pointer l)
+{
+ (*l)();
+ _queue_add(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::maybe_unlock_controls));
+}
+
diff --git a/src/gtkpaludis/paludis_thread.hh b/src/gtkpaludis/paludis_thread.hh
new file mode 100644
index 0000000..acbcbf8
--- /dev/null
+++ b/src/gtkpaludis/paludis_thread.hh
@@ -0,0 +1,70 @@
+/* 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_PALUDIS_THREAD_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_PALUDIS_THREAD_HH 1
+
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <glibmm/dispatcher.h>
+#include <sigc++/trackable.h>
+#include <sigc++/slot.h>
+
+namespace gtkpaludis
+{
+ class PaludisThread :
+ public paludis::InstantiationPolicy<PaludisThread, paludis::instantiation_method::SingletonAsNeededTag>,
+ private paludis::PrivateImplementationPattern<PaludisThread>,
+ public sigc::trackable
+ {
+ friend class paludis::InstantiationPolicy<PaludisThread, paludis::instantiation_method::SingletonAsNeededTag>;
+
+ public:
+ class Launchable :
+ private paludis::InstantiationPolicy<Launchable, paludis::instantiation_method::NonCopyableTag>,
+ public paludis::InternalCounted<Launchable>
+ {
+ friend class PaludisThread;
+
+ protected:
+ Launchable();
+
+ void dispatch(const sigc::slot<void> &);
+
+ public:
+ virtual ~Launchable();
+ virtual void operator() () = 0;
+ };
+
+ friend class Launchable;
+
+ private:
+ PaludisThread();
+ virtual ~PaludisThread();
+
+ void _queue_add(const sigc::slot<void> &);
+ void _queue_run();
+ void _thread_func(Launchable::Pointer);
+
+ public:
+ void launch(Launchable::Pointer);
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/sync.cc b/src/gtkpaludis/sync.cc
deleted file mode 100644
index ef2a133..0000000
--- a/src/gtkpaludis/sync.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-/* 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 "sync.hh"
-#include "main_window.hh"
-
-#include <paludis/environment/default/default_environment.hh>
-#include <paludis/util/log.hh>
-#include <paludis/syncer.hh>
-
-#include <list>
-
-using namespace paludis;
-
-namespace paludis
-{
- template<>
- struct Implementation<OurSyncTask> :
- InternalCounted<Implementation<OurSyncTask> >
- {
- std::list<std::string> failed_repositories;
- };
-}
-
-OurSyncTask::OurSyncTask() :
- SyncTask(DefaultEnvironment::get_instance()),
- PrivateImplementationPattern<OurSyncTask>(new Implementation<OurSyncTask>)
-{
-}
-
-OurSyncTask::~OurSyncTask()
-{
-}
-
-void
-OurSyncTask::on_sync_all_pre()
-{
-}
-
-void
-OurSyncTask::on_sync_pre(const RepositoryName &)
-{
-}
-
-void
-OurSyncTask::on_sync_post(const RepositoryName &)
-{
-}
-
-void
-OurSyncTask::on_sync_skip(const RepositoryName &)
-{
-}
-
-void
-OurSyncTask::on_sync_succeed(const RepositoryName &)
-{
-}
-
-void
-OurSyncTask::on_sync_fail(const RepositoryName & r, const SyncFailedError &)
-{
- Log::get_instance()->message(ll_warning, lc_no_context, "Sync of repository '"
- + stringify(r) + "' failed");
- PrivateImplementationPattern<OurSyncTask>::_imp->failed_repositories.push_back(stringify(r));
-}
-
-void
-OurSyncTask::on_sync_all_post()
-{
-}
-
-OurSyncTask::FailedIterator
-OurSyncTask::begin_failed() const
-{
- return FailedIterator(PrivateImplementationPattern<OurSyncTask>::_imp->failed_repositories.begin());
-}
-
-OurSyncTask::FailedIterator
-OurSyncTask::end_failed() const
-{
- return FailedIterator(PrivateImplementationPattern<OurSyncTask>::_imp->failed_repositories.end());
-}
-
diff --git a/src/gtkpaludis/sync.hh b/src/gtkpaludis/sync.hh
deleted file mode 100644
index 600b662..0000000
--- a/src/gtkpaludis/sync.hh
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 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_SYNC_HH
-#define PALUDIS_GUARD_SRC_GTKPALUDIS_SYNC_HH 1
-
-#include <paludis/tasks/sync_task.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-
-namespace paludis
-{
- class OurSyncTask :
- public SyncTask,
- private PrivateImplementationPattern<OurSyncTask>
- {
- public:
- OurSyncTask();
- ~OurSyncTask();
-
- virtual void on_sync_all_pre();
- virtual void on_sync_pre(const RepositoryName &);
- virtual void on_sync_post(const RepositoryName &);
- virtual void on_sync_skip(const RepositoryName &);
- virtual void on_sync_fail(const RepositoryName &, const SyncFailedError &);
- virtual void on_sync_succeed(const RepositoryName &);
- virtual void on_sync_all_post();
-
- typedef libwrapiter::ForwardIterator<OurSyncTask, const std::string> FailedIterator;
- FailedIterator begin_failed() const;
- FailedIterator end_failed() const;
- };
-}
-
-#endif
diff --git a/src/gtkpaludis/vte_message_window.cc b/src/gtkpaludis/vte_message_window.cc
deleted file mode 100644
index e6f8a52..0000000
--- a/src/gtkpaludis/vte_message_window.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- * Copyright (c) 2006 Piotr Rak <piotr.rak@gmail.com>
- *
- * 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 "vte_message_window.hh"
-#include <paludis/util/fd_output_stream.hh>
-#include <paludis/util/system.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/exception.hh>
-
-//#ifndef _XOPEN_SOURCE
-//#define _XOPEN_SOURCE don't know why vte.h has this defined
-//#endif
-
-#include <cstdlib>
-#include <fcntl.h>
-#include <iostream>
-
-namespace
-{
- class Pty /* this one should propably go to libpaludisutil */
- {
- int _master_fd;
- int _slave_fd;
- public:
- Pty(bool controlling_terminal);
- ~Pty();
-
- int master_fd() const;
- int slave_fd() const;
- };
-
- Pty::Pty(bool controlling_terminal) :
- _master_fd(posix_openpt(O_RDWR | (controlling_terminal ? 0 : O_NOCTTY)))
- {
- if (0 > _master_fd)
- throw paludis::InternalError(PALUDIS_HERE, "posix_openpt failed");
-
- char *slave_name(ptsname(_master_fd));
-
- try
- {
- if (0 == slave_name)
- throw paludis::InternalError(PALUDIS_HERE, "ptsname failed");
-
- if (0 > grantpt(_master_fd)) /* TODO: this one needs something special from user co */
- throw paludis::InternalError(PALUDIS_HERE, "grantpt failed");
-
- if (0 > unlockpt(_master_fd))
- throw paludis::InternalError(PALUDIS_HERE, "unlockpt failed");
-
- if (-1 == (_slave_fd = open(slave_name, O_RDWR)))
- throw paludis::InternalError(PALUDIS_HERE, "open slave terminal failed");
- }
- catch (...)
- {
- close(_master_fd);
- throw;
- }
- }
-
- Pty::~Pty()
- {
- close(_master_fd);
- close(_slave_fd);
- }
-
- int Pty::master_fd() const
- {
- return _master_fd;
- }
-
- int Pty::slave_fd() const
- {
- return _slave_fd;
- }
-
-} /* anonymous namespace */
-
-namespace paludis
-{
- template <>
- struct Implementation<VteMessageWindow> :
- public InternalCounted<Implementation<VteMessageWindow> >
- {
- VteMessageWindow * const owner;
- Pty pty;
- FDOutputStream stream;
-
- Implementation(VteMessageWindow *o);
-
- };
-
- Implementation<VteMessageWindow>::Implementation(VteMessageWindow* o) :
- InternalCounted<Implementation<VteMessageWindow> >(),
- owner(o),
- pty(false),
- stream(pty.slave_fd())
- {
- set_run_command_stdout_fds(pty.slave_fd(), pty.master_fd());
- set_run_command_stderr_fds(pty.slave_fd(), pty.master_fd());
-
- Log::get_instance()->set_log_stream(&stream);
- Log::get_instance()->message(ll_debug, lc_no_context, "Message window initialized");
- }
-
-
- VteMessageWindow::VteMessageWindow() :
- Vte::Terminal(),
- PrivateImplementationPattern<VteMessageWindow>(new Implementation<VteMessageWindow>(this))
- {
- set_pty(dup(_imp->pty.master_fd()));
- }
-
- VteMessageWindow::~VteMessageWindow()
- {
- Log::get_instance()->set_log_stream(&std::cerr);
- }
-
-} /* namespace paludis */
-
diff --git a/src/gtkpaludis/vte_message_window.hh b/src/gtkpaludis/vte_message_window.hh
deleted file mode 100644
index 35ee725..0000000
--- a/src/gtkpaludis/vte_message_window.hh
+++ /dev/null
@@ -1,82 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- * Copyright (c) 2006 Piotr Rak <piotr.rak@gmail.com>
- *
- * 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_VTE_MESSAGE_WINDOW
-#define PALUDIS_GUARD_SRC_GTKPALUDIS_VTE_MESSAGE_WINDOW 1
-
-#include "vtemm/terminal_widget.hh"
-#include <paludis/util/private_implementation_pattern.hh>
-
-namespace paludis
-{
-
- class VteMessageWindow :
- public Vte::Terminal,
- public paludis::PrivateImplementationPattern<VteMessageWindow>
- {
- public:
- VteMessageWindow();
- ~VteMessageWindow();
- };
-}
-
-#endif /* PALUDIS_GUARD_SRC_GTKPALUDIS_VTE_MESSAGE_WINDOW */
-
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
- * Copyright (c) 2006 Piotr Rak <piotr.rak@gmail.com>
- *
- * 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_VTE_MESSAGE_WINDOW
-#define PALUDIS_GUARD_SRC_GTKPALUDIS_VTE_MESSAGE_WINDOW 1
-
-#include "terminal_widget.hh"
-#include <paludis/util/private_implementation_pattern.hh>
-
-namespace paludis
-{
-
- class VteMessageWindow :
- public Vte::Terminal,
- public paludis::PrivateImplementationPattern<VteMessageWindow>
- {
- public:
- VteMessageWindow();
- ~VteMessageWindow();
- };
-}
-
-#endif /* PALUDIS_GUARD_SRC_GTKPALUDIS_VTE_MESSAGE_WINDOW */
-