aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-21 18:47:23 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-21 18:47:23 +0000
commit1d96c0791adb4da9158eaa793396e0d5dd9e6fdb (patch)
tree2084fe4c3424813956588dde6f0e58ed95d17bb3
parent75cc97e78f3c12a26e28846ff9a6c5839cce22aa (diff)
downloadpaludis-1d96c0791adb4da9158eaa793396e0d5dd9e6fdb.tar.gz
paludis-1d96c0791adb4da9158eaa793396e0d5dd9e6fdb.tar.xz
More gtkpaludis work
-rw-r--r--src/gtkpaludis/Makefile.am4
-rw-r--r--src/gtkpaludis/categories_list.cc1
-rw-r--r--src/gtkpaludis/main_window.cc86
-rw-r--r--src/gtkpaludis/main_window.hh4
-rw-r--r--src/gtkpaludis/messages.cc110
-rw-r--r--src/gtkpaludis/messages.hh38
-rw-r--r--src/gtkpaludis/packages_page.cc114
-rw-r--r--src/gtkpaludis/packages_page.hh44
-rw-r--r--src/gtkpaludis/paludis_thread.cc7
-rw-r--r--src/gtkpaludis/repositories_list.hh43
-rw-r--r--src/gtkpaludis/repositories_page.cc137
-rw-r--r--src/gtkpaludis/repositories_page.hh44
12 files changed, 563 insertions, 69 deletions
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 56e0288..08286e4 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -21,10 +21,14 @@ gtkpaludis_SOURCES = \
command_line.cc command_line.hh \
main_window.cc main_window.hh \
categories_list.cc categories_list.hh \
+ packages_page.cc packages_page.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 \
+ messages.cc messages.hh \
+ repositories_list.cc repositories_list.hh \
+ repositories_page.cc repositories_page.hh \
gtkpaludis.cc
gtkpaludis_LDADD = \
diff --git a/src/gtkpaludis/categories_list.cc b/src/gtkpaludis/categories_list.cc
index 6d38013..176c0ed 100644
--- a/src/gtkpaludis/categories_list.cc
+++ b/src/gtkpaludis/categories_list.cc
@@ -128,6 +128,7 @@ CategoriesList::~CategoriesList()
void
CategoriesList::populate()
{
+ _imp->model->clear();
PaludisThread::get_instance()->launch(Populate::Pointer(new Populate(_imp.raw_pointer())));
}
diff --git a/src/gtkpaludis/main_window.cc b/src/gtkpaludis/main_window.cc
index d774ed3..5811a25 100644
--- a/src/gtkpaludis/main_window.cc
+++ b/src/gtkpaludis/main_window.cc
@@ -18,20 +18,14 @@
*/
#include "main_window.hh"
-#include "categories_list.hh"
-#include "packages_list.hh"
-#include "package_info.hh"
+#include "packages_page.hh"
+#include "repositories_page.hh"
+#include "messages.hh"
#include <paludis/util/log.hh>
#include <gtkmm/box.h>
-#include <gtkmm/button.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/label.h>
#include <gtkmm/notebook.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/separator.h>
-#include <gtkmm/stock.h>
#include <gtkmm/table.h>
#include <list>
@@ -52,34 +46,25 @@ namespace paludis
Gtk::Table main_table;
Gtk::Notebook main_notebook;
- Gtk::Table packages_page;
+ PackagesPage packages_page;
Gtk::Table sets_page;
- Gtk::Table repositories_page;
+ RepositoriesPage repositories_page;
+ Gtk::Table messages_page;
Gtk::ScrolledWindow status_label_box;
Gtk::Label status_label;
- Gtk::HBox packages_search;
- Gtk::Entry packages_search_entry;
- Gtk::Button packages_search_button;
- Gtk::HSeparator packages_search_button_sep;
-
- Gtk::ScrolledWindow categories_list_scroll;
- CategoriesList categories_list;
-
- Gtk::ScrolledWindow packages_list_scroll;
- PackagesList packages_list;
-
- PackageInfo package_info;
+ Messages messages;
std::list<std::string> status;
+ int messages_page_id;
+
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)
+ messages_page(1, 1, false),
+ status_label("", Gtk::ALIGN_LEFT)
{
}
};
@@ -96,6 +81,7 @@ MainWindow::MainWindow() :
_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->messages_page_id = _imp->main_notebook.append_page(_imp->messages_page, "Messages");
add(_imp->main_table);
_imp->main_table.attach(_imp->main_notebook, 0, 1, 0, 1);
@@ -104,30 +90,7 @@ MainWindow::MainWindow() :
_imp->status_label_box.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_NEVER);
_imp->status_label_box.add(_imp->status_label);
- _imp->packages_page.set_col_spacings(5);
- _imp->packages_page.set_row_spacings(5);
- _imp->packages_page.set_border_width(5);
-
- _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->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->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->packages_page.attach(_imp->package_info, 0, 2, 2, 3);
-
- _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));
+ _imp->messages_page.attach(_imp->messages, 0, 1, 0, 1);
show_all_children();
}
@@ -145,21 +108,8 @@ MainWindow::~MainWindow()
void
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());
+ _imp->packages_page.populate();
+ _imp->repositories_page.populate();
}
void
@@ -199,3 +149,9 @@ MainWindow::_update_status()
_imp->status_label.set_label(_imp->status.back());
}
+void
+MainWindow::show_messages_page()
+{
+ _imp->main_notebook.set_current_page(_imp->messages_page_id);
+}
+
diff --git a/src/gtkpaludis/main_window.hh b/src/gtkpaludis/main_window.hh
index 0d8b9b9..7bdd76f 100644
--- a/src/gtkpaludis/main_window.hh
+++ b/src/gtkpaludis/main_window.hh
@@ -37,8 +37,6 @@ namespace gtkpaludis
MainWindow();
virtual ~MainWindow();
- void _category_list_selection_changed();
- void _package_list_selection_changed();
void _set_lock(bool value);
void _update_status();
@@ -50,6 +48,8 @@ namespace gtkpaludis
void push_status(const std::string &);
void pop_status();
+
+ void show_messages_page();
};
}
diff --git a/src/gtkpaludis/messages.cc b/src/gtkpaludis/messages.cc
new file mode 100644
index 0000000..f2e025b
--- /dev/null
+++ b/src/gtkpaludis/messages.cc
@@ -0,0 +1,110 @@
+/* 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 "messages.hh"
+#include <vtemm/terminal_widget.hh>
+#include <paludis/util/fd_output_stream.hh>
+#include <paludis/util/log.hh>
+#include <paludis/util/system.hh>
+#include <cstdlib>
+#include <fcntl.h>
+
+// for restoring Log's output stream
+#include <iostream>
+
+using namespace paludis;
+using namespace gtkpaludis;
+
+namespace
+{
+ class Pty
+ {
+ private:
+ int _master_fd, _slave_fd;
+
+ public:
+ Pty() :
+ _master_fd(posix_openpt(O_RDWR))
+ {
+ if (_master_fd < 1)
+ throw InternalError(PALUDIS_HERE, "posix_openpt failed");
+ if (-1 == grantpt(_master_fd))
+ throw InternalError(PALUDIS_HERE, "grantpt failed");
+ if (-1 == unlockpt(_master_fd))
+ throw InternalError(PALUDIS_HERE, "unlockpt failed");
+
+ _slave_fd = open(ptsname(_master_fd), O_RDWR);
+ if (-1 == _slave_fd)
+ throw InternalError(PALUDIS_HERE, "open _slave_fd failed");
+ }
+
+ ~Pty()
+ {
+ close(_master_fd);
+ close(_slave_fd);
+ }
+
+ int master_fd() const
+ {
+ return _master_fd;
+ }
+
+ int slave_fd() const
+ {
+ return _slave_fd;
+ }
+ };
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<Messages> :
+ InternalCounted<Implementation<Messages> >
+ {
+ Pty term_pty;
+ Vte::Terminal term;
+ FDOutputStream messages_stream;
+
+ Implementation() :
+ messages_stream(term_pty.slave_fd())
+ {
+ }
+ };
+}
+
+Messages::Messages() :
+ PrivateImplementationPattern<Messages>(new Implementation<Messages>)
+{
+ set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+ add(_imp->term);
+
+ _imp->term.set_pty(dup(_imp->term_pty.master_fd()));
+ _imp->term.set_scroll_on_output(true);
+
+ set_run_command_stdout_fds(_imp->term_pty.slave_fd(), _imp->term_pty.master_fd());
+ set_run_command_stderr_fds(_imp->term_pty.slave_fd(), _imp->term_pty.master_fd());
+ Log::get_instance()->set_log_stream(&_imp->messages_stream);
+}
+
+Messages::~Messages()
+{
+ Log::get_instance()->set_log_stream(&std::cerr);
+}
+
diff --git a/src/gtkpaludis/messages.hh b/src/gtkpaludis/messages.hh
new file mode 100644
index 0000000..0028be3
--- /dev/null
+++ b/src/gtkpaludis/messages.hh
@@ -0,0 +1,38 @@
+/* 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_MESSAGES_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_MESSAGES_HH 1
+
+#include <gtkmm/scrolledwindow.h>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace gtkpaludis
+{
+ class Messages :
+ private paludis::PrivateImplementationPattern<Messages>,
+ public Gtk::ScrolledWindow
+ {
+ public:
+ Messages();
+ virtual ~Messages();
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/packages_page.cc b/src/gtkpaludis/packages_page.cc
new file mode 100644
index 0000000..26f3eb7
--- /dev/null
+++ b/src/gtkpaludis/packages_page.cc
@@ -0,0 +1,114 @@
+/* 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_page.hh"
+#include "categories_list.hh"
+#include "packages_list.hh"
+#include "package_info.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>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<PackagesPage> :
+ InternalCounted<Implementation<PackagesPage> >
+ {
+ Gtk::HBox packages_search;
+ Gtk::Entry packages_search_entry;
+ Gtk::Button packages_search_button;
+ Gtk::HSeparator packages_search_button_sep;
+
+ Gtk::ScrolledWindow categories_list_scroll;
+ CategoriesList categories_list;
+
+ Gtk::ScrolledWindow packages_list_scroll;
+ PackagesList packages_list;
+
+ PackageInfo package_info;
+
+ Implementation() :
+ packages_search_button(Gtk::Stock::FIND)
+ {
+ }
+ };
+}
+
+PackagesPage::PackagesPage() :
+ Gtk::Table(2, 3, false),
+ PrivateImplementationPattern<PackagesPage>(new Implementation<PackagesPage>)
+{
+ set_col_spacings(5);
+ set_row_spacings(5);
+ set_border_width(5);
+
+ _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);
+ attach(_imp->packages_search, 0, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(0));
+
+ _imp->categories_list_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ _imp->categories_list_scroll.add(_imp->categories_list);
+ attach(_imp->categories_list_scroll, 0, 1, 1, 2, Gtk::SHRINK, Gtk::FILL | Gtk::EXPAND);
+
+ _imp->packages_list_scroll.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
+ _imp->packages_list_scroll.add(_imp->packages_list);
+ attach(_imp->packages_list_scroll, 1, 2, 1, 2);
+
+ attach(_imp->package_info, 0, 2, 2, 3);
+
+ _imp->categories_list.get_selection()->signal_changed().connect(sigc::mem_fun(this,
+ &PackagesPage::_category_list_selection_changed));
+ _imp->packages_list.get_selection()->signal_changed().connect(sigc::mem_fun(this,
+ &PackagesPage::_package_list_selection_changed));
+}
+
+PackagesPage::~PackagesPage()
+{
+}
+
+void
+PackagesPage::populate()
+{
+ _imp->categories_list.populate();
+}
+
+void
+PackagesPage::_category_list_selection_changed()
+{
+ _imp->packages_list.populate(_imp->categories_list.current_category());
+}
+
+void
+PackagesPage::_package_list_selection_changed()
+{
+ _imp->package_info.populate(_imp->packages_list.current_package());
+}
+
+
diff --git a/src/gtkpaludis/packages_page.hh b/src/gtkpaludis/packages_page.hh
new file mode 100644
index 0000000..8450da6
--- /dev/null
+++ b/src/gtkpaludis/packages_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_PACKAGES_PAGE_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_PACKAGES_PAGE_HH 1
+
+#include <gtkmm/table.h>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace gtkpaludis
+{
+ class PackagesPage :
+ public Gtk::Table,
+ private paludis::PrivateImplementationPattern<PackagesPage>
+ {
+ private:
+ void _package_list_selection_changed();
+ void _category_list_selection_changed();
+
+ public:
+ PackagesPage();
+ virtual ~PackagesPage();
+
+ void populate();
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/paludis_thread.cc b/src/gtkpaludis/paludis_thread.cc
index 6e2d2a4..6de4121 100644
--- a/src/gtkpaludis/paludis_thread.cc
+++ b/src/gtkpaludis/paludis_thread.cc
@@ -32,7 +32,7 @@ namespace paludis
InternalCounted<Implementation<PaludisThread> >
{
Glib::Dispatcher dispatcher;
- Glib::Mutex queue_mutex;
+ Glib::Mutex queue_mutex, single_mutex;
std::deque<sigc::slot<void> > * queue;
Implementation() :
@@ -105,7 +105,10 @@ PaludisThread::_queue_run()
void
PaludisThread::_thread_func(PaludisThread::Launchable::Pointer l)
{
- (*l)();
+ {
+ Glib::Mutex::Lock lock(_imp->single_mutex);
+ (*l)();
+ }
_queue_add(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::maybe_unlock_controls));
}
diff --git a/src/gtkpaludis/repositories_list.hh b/src/gtkpaludis/repositories_list.hh
new file mode 100644
index 0000000..8ddc3c4
--- /dev/null
+++ b/src/gtkpaludis/repositories_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_REPOSITORIES_LIST_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_REPOSITORIES_LIST_HH 1
+
+#include <gtkmm/treeview.h>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+
+namespace gtkpaludis
+{
+ class RepositoriesList :
+ public Gtk::TreeView,
+ private paludis::PrivateImplementationPattern<RepositoriesList>
+ {
+ public:
+ RepositoriesList();
+ virtual ~RepositoriesList();
+
+ void populate();
+ paludis::RepositoryName current_repository();
+ };
+}
+
+
+#endif
diff --git a/src/gtkpaludis/repositories_page.cc b/src/gtkpaludis/repositories_page.cc
new file mode 100644
index 0000000..6163cac
--- /dev/null
+++ b/src/gtkpaludis/repositories_page.cc
@@ -0,0 +1,137 @@
+/* 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 "repositories_page.hh"
+#include "repositories_list.hh"
+#include "paludis_thread.hh"
+#include "main_window.hh"
+
+#include <paludis/environment/default/default_environment.hh>
+#include <gtkmm/button.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/box.h>
+#include <gtkmm/buttonbox.h>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<RepositoriesPage> :
+ InternalCounted<Implementation<RepositoriesPage> >
+ {
+ Gtk::ScrolledWindow repositories_list_scroll;
+ RepositoriesList repositories_list;
+
+ Gtk::HButtonBox buttons_box;
+ Gtk::Button sync_button;
+
+ Implementation() :
+ sync_button("Sync")
+ {
+ }
+ };
+}
+
+RepositoriesPage::RepositoriesPage() :
+ Gtk::Table(2, 2, false),
+ PrivateImplementationPattern<RepositoriesPage>(new Implementation<RepositoriesPage>)
+{
+ set_col_spacings(5);
+ set_row_spacings(5);
+ set_border_width(5);
+
+ _imp->repositories_list_scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ _imp->repositories_list_scroll.add(_imp->repositories_list);
+ attach(_imp->repositories_list_scroll, 0, 1, 0, 2, Gtk::SHRINK, Gtk::FILL | Gtk::EXPAND);
+
+
+ _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->sync_button);
+ attach(_imp->buttons_box, 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::AttachOptions(0));
+
+ _imp->sync_button.signal_clicked().connect(sigc::mem_fun(this,
+ &RepositoriesPage::_sync_button_clicked));
+ _imp->repositories_list.get_selection()->signal_changed().connect(sigc::mem_fun(this,
+ &RepositoriesPage::_repository_list_selection_changed));
+}
+
+RepositoriesPage::~RepositoriesPage()
+{
+}
+
+void
+RepositoriesPage::populate()
+{
+ _imp->repositories_list.populate();
+}
+
+void
+RepositoriesPage::_repository_list_selection_changed()
+{
+}
+
+namespace
+{
+ class Sync :
+ public PaludisThread::Launchable
+ {
+ private:
+ RepositoryName _name;
+
+ public:
+ Sync(const RepositoryName & name) :
+ _name(name)
+ {
+ }
+
+ virtual void operator() ();
+ };
+
+ void
+ Sync::operator() ()
+ {
+ dispatch(sigc::bind<1>(sigc::mem_fun(MainWindow::get_instance(),
+ &MainWindow::push_status), "Syncing repository '" + stringify(_name) + "'..."));
+
+ Repository::ConstPointer repo(DefaultEnvironment::get_instance()->package_database()->fetch_repository(_name));
+ if (repo->syncable_interface)
+ {
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::show_messages_page));
+ repo->syncable_interface->sync();
+ }
+
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::pop_status));
+ dispatch(sigc::mem_fun(MainWindow::get_instance(), &MainWindow::populate));
+ }
+}
+
+void
+RepositoriesPage::_sync_button_clicked()
+{
+ RepositoryName current_repository(_imp->repositories_list.current_repository());
+ if (current_repository.data() == "no-repository")
+ return;
+
+ PaludisThread::get_instance()->launch(Sync::Pointer(new Sync(current_repository)));
+}
+
diff --git a/src/gtkpaludis/repositories_page.hh b/src/gtkpaludis/repositories_page.hh
new file mode 100644
index 0000000..f7ee480
--- /dev/null
+++ b/src/gtkpaludis/repositories_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_REPOSITORIES_PAGE_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_REPOSITORIES_PAGE_HH 1
+
+#include <gtkmm/table.h>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace gtkpaludis
+{
+ class RepositoriesPage :
+ public Gtk::Table,
+ private paludis::PrivateImplementationPattern<RepositoriesPage>
+ {
+ private:
+ void _repository_list_selection_changed();
+ void _sync_button_clicked();
+
+ public:
+ RepositoriesPage();
+ virtual ~RepositoriesPage();
+
+ void populate();
+ };
+}
+
+#endif