aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-31 19:41:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-31 19:41:52 +0000
commit8060b26e9aef92ef9c520966ef001d92d3a0cb81 (patch)
tree3fb4c029b17e11e140bb662299c6421d0d37fe80
parent07a5083d7e88a422a615d31681dba9eee93c648a (diff)
downloadpaludis-8060b26e9aef92ef9c520966ef001d92d3a0cb81.tar.gz
paludis-8060b26e9aef92ef9c520966ef001d92d3a0cb81.tar.xz
Add tasks window basics
-rw-r--r--configure.ac29
-rw-r--r--src/gtkpaludis/Makefile.am4
-rw-r--r--src/gtkpaludis/cellrendererbutton/Makefile.am32
-rw-r--r--src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc104
-rw-r--r--src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh59
-rw-r--r--src/gtkpaludis/main_window.cc34
-rw-r--r--src/gtkpaludis/main_window.hh1
-rw-r--r--src/gtkpaludis/tasks_page.cc118
-rw-r--r--src/gtkpaludis/tasks_page.hh40
9 files changed, 395 insertions, 26 deletions
diff --git a/configure.ac b/configure.ac
index 1c25493..0422ee1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -548,6 +548,34 @@ if test "x$enable_gtk" = "xyes"; then
[], [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)
+
+ AC_MSG_CHECKING([whether Gtk::TreeView::set_grid_lines is available])
+ old_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS $GTKDEPS_CFLAGS"
+ AC_COMPILE_IFELSE([
+#include <gtkmm/treeview.h>
+int main(int, char *[])
+{
+ Gtk::TreeViewGridLines g;
+ g = Gtk::TREE_VIEW_GRID_LINES_VERTICAL;
+}
+],
+ [have_tree_view_grid_lines=yes],
+ [have_tree_view_grid_lines=no])
+ CXXFLAGS="$old_CXXFLAGS"
+ AC_MSG_RESULT([$have_tree_view_grid_lines])
+ if test "x$have_tree_view_grid_lines" = "xyes" ; then
+ AC_MSG_CHECKING([whether Gtk::TreeView::set_grid_lines works])
+ PKG_CHECK_MODULES(GTKTREEVIEWDEPS, [gtk+-2.0 >= 2.11],
+ [have_tree_view_grid_lines=yes],
+ [have_tree_view_grid_lines=no])
+ AC_MSG_RESULT([$have_tree_view_grid_lines])
+ fi
+ HAVE_TREE_VIEW_GRID_LINES=$have_tree_view_grid_lines
+ if test "x$have_tree_view_grid_lines" = "xyes" ; then
+ AC_DEFINE_UNQUOTED([HAVE_TREE_VIEW_GRID_LINES], 1, [Do we have Gtk::TreeView::set_grid_lines?])
+ fi
+ AC_SUBST([HAVE_TREE_VIEW_GRID_LINES])
fi
AM_CONDITIONAL([ENABLE_GTK], test "x$enable_gtk" = "xyes")
@@ -682,6 +710,7 @@ AC_OUTPUT(
src/Makefile
src/paludis/Makefile
src/gtkpaludis/Makefile
+ src/gtkpaludis/cellrendererbutton/Makefile
src/gtkpaludis/vtemm/Makefile
src/gtkpaludis/vtemm/converts/Makefile
src/gtkpaludis/vtemm/defs/Makefile
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 2997b56..68c9b80 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -9,7 +9,7 @@ DEFS = \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DGLIBMM_EXCEPTIONS_ENABLED=1
-SUBDIRS = vtemm .
+SUBDIRS = cellrendererbutton vtemm .
INCLUDES = $(GTKDEPS_CFLAGS)
@@ -34,10 +34,12 @@ gtkpaludis_SOURCES = \
sets_list.hh sets_list.cc \
sets_page.hh sets_page.cc \
sync.cc sync.hh \
+ tasks_page.cc tasks_page.hh \
gtkpaludis.cc
gtkpaludis_LDADD = \
$(top_builddir)/src/gtkpaludis/vtemm/libvtemm.a \
+ $(top_builddir)/src/gtkpaludis/cellrendererbutton/libcellrendererbutton.a \
$(top_builddir)/paludis/tasks/libpaludistasks.a \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
diff --git a/src/gtkpaludis/cellrendererbutton/Makefile.am b/src/gtkpaludis/cellrendererbutton/Makefile.am
new file mode 100644
index 0000000..14778c7
--- /dev/null
+++ b/src/gtkpaludis/cellrendererbutton/Makefile.am
@@ -0,0 +1,32 @@
+AM_CXXFLAGS = -I$(top_srcdir) \
+ @PALUDIS_CXXFLAGS@ \
+ @PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST@ \
+ @PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS@ \
+ @PALUDIS_CXXFLAGS_NO_WSHADOW@
+
+DEFS = \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DGLIBMM_EXCEPTIONS_ENABLED=1
+
+SUBDIRS = .
+
+INCLUDES = $(GTKDEPS_CFLAGS)
+
+if ENABLE_GTK
+
+noinst_LIBRARIES = libcellrendererbutton.a
+
+libcellrendererbutton_a_SOURCES = \
+ cellrendererbutton.cc cellrendererbutton.hh
+
+endif
+
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
+MAINTAINERCLEANFILES = Makefile.in
+
+built-sources : $(BUILT_SOURCES)
+ for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
+
+
+
diff --git a/src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc
new file mode 100644
index 0000000..2650616
--- /dev/null
+++ b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.cc
@@ -0,0 +1,104 @@
+/* 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 "cellrendererbutton.hh"
+#include <gtkmm/enums.h>
+
+using namespace gtkpaludis;
+
+CellRendererButton::CellRendererButton() :
+ Glib::ObjectBase(typeid(CellRendererButton)),
+ Gtk::CellRendererText()
+{
+ property_alignment() = Pango::ALIGN_CENTER;
+}
+
+CellRendererButton::~CellRendererButton()
+{
+}
+
+void
+CellRendererButton::get_size_vfunc(Gtk::Widget &, const Gdk::Rectangle * cell_area,
+ int * x_offset, int * y_offset, int * width, int * height) const
+{
+ const unsigned int x_pad = property_xpad();
+ const unsigned int y_pad = property_ypad();
+ const unsigned int x_align = property_xalign();
+ const unsigned int y_align = property_yalign();
+
+ const int calculated_width = 2 * x_pad + _button_width;
+ const int calculated_height = 2 * y_pad + _button_height;
+
+ if (width)
+ *width = calculated_width;
+ if (height)
+ *height = calculated_height;
+
+ if (cell_area)
+ {
+ if (x_offset)
+ *x_offset = std::max<int>(0, x_align * (cell_area->get_width() - calculated_width));
+ if (y_offset)
+ *y_offset = std::max<int>(0, y_align * (cell_area->get_height() - calculated_height));
+ }
+}
+
+void
+CellRendererButton::render_vfunc(const Glib::RefPtr<Gdk::Drawable> & window,
+ Gtk::Widget & widget, const Gdk::Rectangle & r,
+ const Gdk::Rectangle & cell_area, const Gdk::Rectangle & rr,
+ Gtk::CellRendererState flags)
+{
+ const unsigned int cell_x_pad = property_xpad();
+ const unsigned int cell_y_pad = property_ypad();
+
+ int x_offset = 0, y_offset = 0, width = 0, height = 0;
+ get_size(widget, cell_area, x_offset, y_offset, width, height);
+
+ width -= 2 * cell_x_pad;
+ height -= 2 * cell_y_pad;
+
+ if (width <= 0 || height <= 0)
+ return;
+
+ Gtk::StateType state = Gtk::STATE_INSENSITIVE;
+ if (flags & Gtk::CELL_RENDERER_SELECTED)
+ state = widget.has_focus() ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
+
+ const Gtk::ShadowType shadow = Gtk::SHADOW_OUT;
+
+ Glib::RefPtr<Gdk::Window> window_casted = Glib::RefPtr<Gdk::Window>::cast_dynamic<>(window);
+ if (window_casted)
+ {
+ widget.get_style()->paint_box(window_casted, state, shadow, cell_area,
+ widget, "button", cell_area.get_x() + x_offset + cell_x_pad,
+ cell_area.get_y() + y_offset + cell_y_pad, width - 1, height - 1);
+
+ CellRendererText::render_vfunc(window, widget, r, cell_area, rr, flags);
+ }
+}
+
+bool
+CellRendererButton::activate_vfunc(GdkEvent *, Gtk::Widget &,
+ const Glib::ustring &, const Gdk::Rectangle &,
+ const Gdk::Rectangle &, Gtk::CellRendererState)
+{
+ return false;
+}
+
diff --git a/src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh
new file mode 100644
index 0000000..12254e7
--- /dev/null
+++ b/src/gtkpaludis/cellrendererbutton/cellrendererbutton.hh
@@ -0,0 +1,59 @@
+/* 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_CELLRENDERERBUTTON_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_CELLRENDERERBUTTON_HH 1
+
+#include <gtkmm/cellrenderertext.h>
+
+namespace gtkpaludis
+{
+ /**
+ * A cell renderer for a Gtk::TreeView that displays a button.
+ *
+ * Based upon gtkmm/examples/cellrenderercustom/cellrenderertoggle.cc
+ */
+ class CellRendererButton :
+ public Gtk::CellRendererText
+ {
+ private:
+ static const unsigned int _button_width = 80;
+ static const unsigned int _button_height = 30;
+
+
+ protected:
+ virtual void get_size_vfunc(Gtk::Widget & widget, const Gdk::Rectangle * cell_area,
+ int * x_offset, int * y_offset, int * width, int * height) const;
+
+ virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable> & window,
+ Gtk::Widget & widget, const Gdk::Rectangle & background_area,
+ const Gdk::Rectangle & cell_area, const Gdk::Rectangle & expose_area,
+ Gtk::CellRendererState flags);
+
+ virtual bool activate_vfunc(GdkEvent * event, Gtk::Widget & widget,
+ const Glib::ustring & path, const Gdk::Rectangle & background_area,
+ const Gdk::Rectangle & cell_area, Gtk::CellRendererState flags);
+
+ public:
+ CellRendererButton();
+ virtual ~CellRendererButton();
+ };
+}
+
+#endif
diff --git a/src/gtkpaludis/main_window.cc b/src/gtkpaludis/main_window.cc
index b835ec4..0a95d10 100644
--- a/src/gtkpaludis/main_window.cc
+++ b/src/gtkpaludis/main_window.cc
@@ -22,6 +22,7 @@
#include "packages_page.hh"
#include "repositories_page.hh"
#include "messages.hh"
+#include "tasks_page.hh"
#include <paludis/util/log.hh>
@@ -30,6 +31,7 @@
#include <gtkmm/table.h>
#include <gtkmm/messagedialog.h>
#include <gtkmm/main.h>
+#include <gtkmm/statusbar.h>
#include <list>
@@ -49,25 +51,21 @@ namespace paludis
Gtk::Table main_table;
Gtk::Notebook main_notebook;
+ TasksPage tasks_page;
PackagesPage packages_page;
SetsPage sets_page;
RepositoriesPage repositories_page;
Gtk::Table messages_page;
-
- Gtk::ScrolledWindow status_label_box;
- Gtk::Label status_label;
-
Messages messages;
- std::list<std::string> status;
+ Gtk::Statusbar status_bar;
int messages_page_id;
Implementation() :
lock_count(0),
main_table(1, 2, false),
- messages_page(1, 1, false),
- status_label("", Gtk::ALIGN_LEFT)
+ messages_page(1, 1, false)
{
}
};
@@ -81,6 +79,7 @@ MainWindow::MainWindow() :
set_default_size(600, 400);
_imp->main_notebook.set_border_width(5);
+// _imp->main_notebook.append_page(_imp->tasks_page, "Common Tasks");
_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");
@@ -88,10 +87,8 @@ MainWindow::MainWindow() :
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->status_bar.set_has_resize_grip(true);
+ _imp->main_table.attach(_imp->status_bar, 0, 1, 1, 2, Gtk::FILL, Gtk::AttachOptions(0));
_imp->messages_page.attach(_imp->messages, 0, 1, 0, 1);
@@ -133,24 +130,13 @@ MainWindow::maybe_unlock_controls()
void
MainWindow::push_status(const std::string & s)
{
- _imp->status.push_back(s);
- _update_status();
+ _imp->status_bar.push(s);
}
void
MainWindow::pop_status()
{
- _imp->status.pop_back();
- _update_status();
-}
-
-void
-MainWindow::_update_status()
-{
- if (_imp->status.empty())
- _imp->status_label.set_label("");
- else
- _imp->status_label.set_label(_imp->status.back());
+ _imp->status_bar.pop();
}
void
diff --git a/src/gtkpaludis/main_window.hh b/src/gtkpaludis/main_window.hh
index b255e47..b0c7d20 100644
--- a/src/gtkpaludis/main_window.hh
+++ b/src/gtkpaludis/main_window.hh
@@ -38,7 +38,6 @@ namespace gtkpaludis
virtual ~MainWindow();
void _set_lock(bool value);
- void _update_status();
public:
virtual void populate();
diff --git a/src/gtkpaludis/tasks_page.cc b/src/gtkpaludis/tasks_page.cc
new file mode 100644
index 0000000..f66b630
--- /dev/null
+++ b/src/gtkpaludis/tasks_page.cc
@@ -0,0 +1,118 @@
+/* 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 "tasks_page.hh"
+#include <gtkmm/box.h>
+#include <gtkmm/image.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+#include <gtkmm/textview.h>
+#include <gtkmm/table.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/stock.h>
+#include <cellrendererbutton/cellrendererbutton.hh>
+#include <limits>
+
+#include "config.h"
+
+using namespace paludis;
+using namespace gtkpaludis;
+
+namespace
+{
+ struct Columns :
+ Gtk::TreeModel::ColumnRecord
+ {
+ Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > col_icon;
+ Gtk::TreeModelColumn<Glib::ustring> col_text;
+ Gtk::TreeModelColumn<Glib::ustring> col_button;
+
+ Columns()
+ {
+ add(col_icon);
+ add(col_text);
+ add(col_button);
+ }
+ };
+
+ struct TasksList :
+ Gtk::TreeView
+ {
+ Columns columns;
+ Glib::RefPtr<Gtk::ListStore> model;
+
+ TasksList() :
+ model(Gtk::ListStore::create(columns))
+ {
+ set_model(model);
+ set_headers_visible(false);
+#ifdef HAVE_TREE_VIEW_GRID_LINES
+ set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_VERTICAL);
+#endif
+
+ {
+ append_column("Icon", columns.col_icon);
+ get_column(append_column("Text", columns.col_text) - 1)->set_expand(true);
+ CellRendererButton * const renderer = new CellRendererButton;
+ Gtk::TreeViewColumn * const column = new Gtk::TreeViewColumn("Button",
+ *Gtk::manage(renderer));
+ column->add_attribute(renderer->property_text(), columns.col_button);
+ append_column(*column);
+ }
+
+ Gtk::TreeModel::Row row = *(model->append());
+ row[columns.col_icon] = render_icon(Gtk::Stock::MISSING_IMAGE, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ row[columns.col_text] = "Sync all repositories";
+ row[columns.col_button] = "Sync";
+
+ row = *(model->append());
+ row[columns.col_icon] = render_icon(Gtk::Stock::MISSING_IMAGE, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ row[columns.col_text] = "Show security updates";
+ row[columns.col_button] = "Preview";
+
+ row = *(model->append());
+ row[columns.col_icon] = render_icon(Gtk::Stock::MISSING_IMAGE, Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ row[columns.col_text] = "Show world updates";
+ row[columns.col_button] = "Preview";
+ }
+ };
+}
+
+namespace paludis
+{
+ template<>
+ struct Implementation<TasksPage> :
+ InternalCounted<Implementation<TasksPage> >
+ {
+ TasksList tasks_list;
+ };
+}
+
+TasksPage::TasksPage() :
+ PrivateImplementationPattern<TasksPage>(new Implementation<TasksPage>)
+{
+ set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_ALWAYS);
+ add(_imp->tasks_list);
+}
+
+TasksPage::~TasksPage()
+{
+}
+
diff --git a/src/gtkpaludis/tasks_page.hh b/src/gtkpaludis/tasks_page.hh
new file mode 100644
index 0000000..84cd60a
--- /dev/null
+++ b/src/gtkpaludis/tasks_page.hh
@@ -0,0 +1,40 @@
+/* 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_TASKS_PAGE_HH
+#define PALUDIS_GUARD_SRC_GTKPALUDIS_TASKS_PAGE_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/name.hh>
+#include <gtkmm/scrolledwindow.h>
+
+namespace gtkpaludis
+{
+ class TasksPage :
+ public Gtk::ScrolledWindow,
+ private paludis::PrivateImplementationPattern<TasksPage>
+ {
+ public:
+ TasksPage();
+ virtual ~TasksPage();
+ };
+}
+
+
+#endif