aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-08-02 23:01:00 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-08-02 23:01:00 +0000
commit4835c2838b30510745208192d844eb5f0b7949c4 (patch)
tree633f993ec8685b7a1b2beeed5d1c04ecb825e5b0
parentca4ad42b96902ed894cb34a627e0539310635e34 (diff)
downloadpaludis-4835c2838b30510745208192d844eb5f0b7949c4.tar.gz
paludis-4835c2838b30510745208192d844eb5f0b7949c4.tar.xz
Use VTE for the message window. From Piotr Rak.
-rw-r--r--AUTHORS3
-rw-r--r--configure.ac22
-rw-r--r--src/gtkpaludis/Makefile.am22
-rw-r--r--src/gtkpaludis/browse_tree.cc40
-rw-r--r--src/gtkpaludis/browse_tree.hh2
-rw-r--r--src/gtkpaludis/main_window.cc6
-rw-r--r--src/gtkpaludis/message_window.cc134
-rw-r--r--src/gtkpaludis/message_window.hh43
-rw-r--r--src/gtkpaludis/vte_message_window.cc136
-rw-r--r--src/gtkpaludis/vte_message_window.hh82
-rw-r--r--src/gtkpaludis/vtemm/Makefile.am67
-rw-r--r--src/gtkpaludis/vtemm/converts/Makefile.am6
-rw-r--r--src/gtkpaludis/vtemm/converts/convert.m430
-rw-r--r--src/gtkpaludis/vtemm/converts/convert_base.m469
-rw-r--r--src/gtkpaludis/vtemm/defs/Makefile.am51
-rw-r--r--src/gtkpaludis/vtemm/defs/enum.pl230
-rw-r--r--src/gtkpaludis/vtemm/defs/generate_defs_vte.cc36
-rw-r--r--src/gtkpaludis/vtemm/reaper.ccg65
-rw-r--r--src/gtkpaludis/vtemm/reaper.hg50
-rw-r--r--src/gtkpaludis/vtemm/terminal_widget.ccg159
-rw-r--r--src/gtkpaludis/vtemm/terminal_widget.hg181
21 files changed, 1213 insertions, 221 deletions
diff --git a/AUTHORS b/AUTHORS
index 67c4dfd..ae195ab 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -30,3 +30,6 @@ David Morgan <david.morgan@wadham.oxford.ac.uk>
Mike Kelly <pioto@pioto.org>
Contributor
+
+Piotr Rak <piotr.rak@gmail.com>
+ Contributor
diff --git a/configure.ac b/configure.ac
index f1141c7..14cc984 100644
--- a/configure.ac
+++ b/configure.ac
@@ -225,10 +225,14 @@ dnl }}}
dnl {{{ check for various misc functions.
dnl It's probably possible to make many of these optional rather than
dnl hard requirements. If any of these fail for you, send patches.
-AC_CHECK_FUNCS([alarm], [], [AC_MSG_ERROR([I need alarm])])
-AC_CHECK_FUNCS([strerror], [], [AC_MSG_ERROR([I need strerror])])
-AC_CHECK_FUNCS([signal], [], [AC_MSG_ERROR([I need signal])])
-AC_CHECK_FUNCS([popen], [], [AC_MSG_ERROR([I need popen])])
+AC_CHECK_FUNCS([alarm], [], [AC_MSG_ERROR([I need alarm])])
+AC_CHECK_FUNCS([strerror], [], [AC_MSG_ERROR([I need strerror])])
+AC_CHECK_FUNCS([signal], [], [AC_MSG_ERROR([I need signal])])
+AC_CHECK_FUNCS([popen], [], [AC_MSG_ERROR([I need popen])])
+AC_CHECK_FUNCS([posix_openpt], [], [AC_MSG_ERROR([I need posix_openpt])])
+AC_CHECK_FUNCS([ptsname], [], [AC_MSG_ERROR([I need ptsname])])
+AC_CHECK_FUNCS([grantpt], [], [AC_MSG_ERROR([I need grantpt])])
+AC_CHECK_FUNCS([unlockpt], [], [AC_MSG_ERROR([I need unlockpt])])
dnl }}}
dnl {{{ check for cxxflags
@@ -432,7 +436,12 @@ AC_ARG_ENABLE([gtk],
AC_MSG_RESULT($enable_gtk)
if test "x$enable_gtk" = "xyes"; then
- PKG_CHECK_MODULES(DEPS, [gtkmm-2.4 >= 2.6.0])
+ GLIBMM_LIBDIR=`pkg-config --variable=libdir glibmm-2.4`
+ GMMPROC_DIR=$GLIBMM_LIBDIR/glibmm-2.4/proc
+ AC_SUBST(GMMPROC_DIR)
+ GMMPROC=$GMMPROC_DIR/gmmproc
+ AC_SUBST(GMMPROC)
+ PKG_CHECK_MODULES(DEPS, [gtkmm-2.4 >= 2.6.0 glibmm-2.4 >= 2.6.0 pangomm-1.4 gdkmm-2.4 vte >= 0.12.1])
AC_SUBST(DEPS_CFLAGS)
AC_SUBST(DEPS_LIBS)
fi
@@ -503,6 +512,9 @@ AC_OUTPUT(
src/Makefile
src/paludis/Makefile
src/gtkpaludis/Makefile
+ src/gtkpaludis/vtemm/Makefile
+ src/gtkpaludis/vtemm/converts/Makefile
+ src/gtkpaludis/vtemm/defs/Makefile
src/qualudis/Makefile
test/Makefile
)
diff --git a/src/gtkpaludis/Makefile.am b/src/gtkpaludis/Makefile.am
index 3607d60..5c1c9b3 100644
--- a/src/gtkpaludis/Makefile.am
+++ b/src/gtkpaludis/Makefile.am
@@ -3,24 +3,26 @@ AM_CXXFLAGS = -I$(top_srcdir) \
@PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST@ \
@PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS@
-DEFS= \
+DEFS = \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
-DGLIBMM_EXCEPTIONS_ENABLED=1
-SUBDIRS = .
+SUBDIRS = vtemm .
+
+INCLUDES = $(DEPS_CFLAGS)
if ENABLE_GTK
bin_PROGRAMS = gtkpaludis
gtkpaludis_SOURCES = \
- command_line.cc command_line.hh \
- browse_tree.cc browse_tree.hh \
- information_tree.cc information_tree.hh \
- message_window.cc message_window.hh \
- main_window.cc main_window.hh \
- sync.cc sync.hh \
+ 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 \
gtkpaludis.cc
gtkpaludis_LDADD = \
@@ -28,13 +30,13 @@ gtkpaludis_LDADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/args/libpaludisargs.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
+ $(top_builddir)/src/gtkpaludis/vtemm/libvtemm.a \
$(DEPS_LIBS) \
$(DYNAMIC_LD_LIBS)
-INCLUDES = $(DEPS_CFLAGS)
+endif
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
MAINTAINERCLEANFILES = Makefile.in
-endif
diff --git a/src/gtkpaludis/browse_tree.cc b/src/gtkpaludis/browse_tree.cc
index b124efa..b7888e2 100644
--- a/src/gtkpaludis/browse_tree.cc
+++ b/src/gtkpaludis/browse_tree.cc
@@ -21,6 +21,7 @@
#include "information_tree.hh"
#include "main_window.hh"
#include "sync.hh"
+#include "vtemm/reaper.hh"
#include <gtkmm/treestore.h>
#include <gtkmm/menu.h>
@@ -32,6 +33,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <iostream>
using namespace paludis;
@@ -355,6 +357,7 @@ BrowseTree::BrowseTree(MainWindow * const main_window,
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",
@@ -411,8 +414,7 @@ BrowseTree::on_menu_sync()
Log::get_instance()->message(ll_debug, lc_no_context,
"Forked child process " + stringify(child));
_imp->paludis_child = child;
- Glib::signal_timeout().connect(sigc::mem_fun(*this,
- &BrowseTree::on_child_process_timer), 50);
+ Vte::Reaper::get_instance()->add_child(child);
}
}
}
@@ -429,32 +431,20 @@ BrowseTree::on_button_press_event(GdkEventButton * event)
return result;
}
-bool
-BrowseTree::on_child_process_timer()
+void
+BrowseTree::on_child_process_exited(int, int status)
{
if (-1 == _imp->paludis_child)
- return false;
-
- int status(-1);
- switch (waitpid(_imp->paludis_child, &status, WNOHANG))
- {
- case 0:
- return true;
+ return;
- case -1:
- throw InternalError(PALUDIS_HERE, "bad value -1 from waitpid");
+ 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));
- default:
- 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);
- return false;
- }
+ _imp->paludis_child = -1;
+ _imp->main_window->set_children_sensitive(true);
}
diff --git a/src/gtkpaludis/browse_tree.hh b/src/gtkpaludis/browse_tree.hh
index c735227..21e6e98 100644
--- a/src/gtkpaludis/browse_tree.hh
+++ b/src/gtkpaludis/browse_tree.hh
@@ -40,7 +40,7 @@ namespace paludis
virtual void on_menu_sync();
virtual bool on_button_press_event(GdkEventButton *);
- virtual bool on_child_process_timer();
+ virtual void on_child_process_exited(int, int);
};
}
diff --git a/src/gtkpaludis/main_window.cc b/src/gtkpaludis/main_window.cc
index d6a4a15..3cb784b 100644
--- a/src/gtkpaludis/main_window.cc
+++ b/src/gtkpaludis/main_window.cc
@@ -20,7 +20,7 @@
#include "main_window.hh"
#include "browse_tree.hh"
#include "information_tree.hh"
-#include "message_window.hh"
+#include "vte_message_window.hh"
#include <paludis/about.hh>
#include <paludis/util/stringify.hh>
@@ -63,7 +63,7 @@ namespace paludis
Gtk::Frame messages_frame;
Gtk::ScrolledWindow messages_window;
- MessageWindow messages;
+ VteMessageWindow vte_messages;
Implementation(MainWindow * const main_window);
};
@@ -118,7 +118,7 @@ MainWindow::MainWindow() :
_imp->messages_frame.add(_imp->messages_window);
_imp->messages_window.set_border_width(5);
- _imp->messages_window.add(_imp->messages);
+ _imp->messages_window.add(_imp->vte_messages);
_imp->messages_window.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
show_all_children();
diff --git a/src/gtkpaludis/message_window.cc b/src/gtkpaludis/message_window.cc
index 5971a83..e69de29 100644
--- a/src/gtkpaludis/message_window.cc
+++ b/src/gtkpaludis/message_window.cc
@@ -1,134 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * 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 "message_window.hh"
-#include <gtkmm/main.h>
-#include <paludis/util/fd_output_stream.hh>
-#include <paludis/util/iterator.hh>
-#include <paludis/util/log.hh>
-#include <paludis/util/pstream.hh>
-#include <paludis/util/pipe.hh>
-#include <paludis/util/system.hh>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/utsname.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <errno.h>
-
-using namespace paludis;
-
-namespace paludis
-{
- template<>
- struct Implementation<MessageWindow> :
- InternalCounted<Implementation<MessageWindow> >
- {
- Pipe log_pipe;
- Pipe command_stdout_pipe;
- Pipe command_stderr_pipe;
-
- MessageWindow * const owner;
- Glib::RefPtr<Glib::IOChannel> log_connection;
- Glib::RefPtr<Glib::IOChannel> command_stdout_connection;
- Glib::RefPtr<Glib::IOChannel> command_stderr_connection;
- FDOutputStream stream;
-
- Implementation(MessageWindow * const o);
- };
-
- Implementation<MessageWindow>::Implementation(MessageWindow * const o) :
- owner(o),
- log_connection(Glib::IOChannel::create_from_fd(log_pipe.read_fd())),
- command_stdout_connection(Glib::IOChannel::create_from_fd(command_stdout_pipe.read_fd())),
- command_stderr_connection(Glib::IOChannel::create_from_fd(command_stderr_pipe.read_fd())),
- stream(log_pipe.write_fd())
- {
- Glib::signal_io().connect(sigc::mem_fun(*owner, &MessageWindow::on_log_read),
- log_pipe.read_fd(), Glib::IO_IN);
-
- Glib::signal_io().connect(sigc::mem_fun(*owner, &MessageWindow::on_command_stdout_read),
- command_stdout_pipe.read_fd(), Glib::IO_IN);
- Glib::signal_io().connect(sigc::mem_fun(*owner, &MessageWindow::on_command_stderr_read),
- command_stderr_pipe.read_fd(), Glib::IO_IN);
-
- PStream::set_stderr_fd(command_stderr_pipe.write_fd(), command_stderr_pipe.read_fd());
- set_run_command_stdout_fds(command_stdout_pipe.write_fd(), command_stdout_pipe.read_fd());
- set_run_command_stderr_fds(command_stderr_pipe.write_fd(), command_stderr_pipe.read_fd());
-
- Log::get_instance()->set_log_stream(&stream);
- Log::get_instance()->message(ll_debug, lc_no_context, "Message window initialised");
- }
-}
-
-MessageWindow::MessageWindow() :
- PrivateImplementationPattern<MessageWindow>(new Implementation<MessageWindow>(this))
-{
- set_editable(false);
-}
-
-MessageWindow::~MessageWindow()
-{
-}
-
-bool
-MessageWindow::on_log_read(Glib::IOCondition io_condition)
-{
- if (0 == io_condition & Glib::IO_IN)
- return false;
-
- Glib::ustring buf;
- _imp->log_connection->read_line(buf);
-
- get_buffer()->insert(get_buffer()->end(), buf);
- scroll_to(get_buffer()->create_mark(get_buffer()->end()), 0.0, 0.0, 1.0);
-
- return true;
-}
-
-bool
-MessageWindow::on_command_stdout_read(Glib::IOCondition io_condition)
-{
- if (0 == io_condition & Glib::IO_IN)
- return false;
-
- Glib::ustring buf;
- _imp->command_stdout_connection->read_line(buf);
-
- get_buffer()->insert(get_buffer()->end(), buf);
- scroll_to(get_buffer()->create_mark(get_buffer()->end()), 0.0, 0.0, 1.0);
-
- return true;
-}
-
-bool
-MessageWindow::on_command_stderr_read(Glib::IOCondition io_condition)
-{
- if (0 == io_condition & Glib::IO_IN)
- return false;
-
- Glib::ustring buf;
- _imp->command_stderr_connection->read_line(buf);
-
- get_buffer()->insert(get_buffer()->end(), buf);
- scroll_to(get_buffer()->create_mark(get_buffer()->end()), 0.0, 0.0, 1.0);
-
- return true;
-}
-
diff --git a/src/gtkpaludis/message_window.hh b/src/gtkpaludis/message_window.hh
index 7a5e5c7..e69de29 100644
--- a/src/gtkpaludis/message_window.hh
+++ b/src/gtkpaludis/message_window.hh
@@ -1,43 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
- *
- * 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_MESSAGE_WINDOW_HH
-#define PALUDIS_GUARD_SRC_GTKPALUDIS_MESSAGE_WINDOW_HH 1
-
-#include <gtkmm/textview.h>
-#include <gtkmm/main.h>
-#include <paludis/util/private_implementation_pattern.hh>
-
-namespace paludis
-{
- class MessageWindow :
- public Gtk::TextView,
- private PrivateImplementationPattern<MessageWindow>
- {
- public:
- MessageWindow();
- virtual ~MessageWindow();
-
- bool on_log_read(Glib::IOCondition);
- bool on_command_stdout_read(Glib::IOCondition);
- bool on_command_stderr_read(Glib::IOCondition);
- };
-}
-
-#endif
diff --git a/src/gtkpaludis/vte_message_window.cc b/src/gtkpaludis/vte_message_window.cc
new file mode 100644
index 0000000..34df8ec
--- /dev/null
+++ b/src/gtkpaludis/vte_message_window.cc
@@ -0,0 +1,136 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ * 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
new file mode 100644
index 0000000..5c30aa1
--- /dev/null
+++ b/src/gtkpaludis/vte_message_window.hh
@@ -0,0 +1,82 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Ciaran McCreesh <ciaran.mccreesh@blueyonder.co.uk>
+ * 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 <ciaran.mccreesh@blueyonder.co.uk>
+ * 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 */
+
diff --git a/src/gtkpaludis/vtemm/Makefile.am b/src/gtkpaludis/vtemm/Makefile.am
new file mode 100644
index 0000000..fc050b9
--- /dev/null
+++ b/src/gtkpaludis/vtemm/Makefile.am
@@ -0,0 +1,67 @@
+EXTRA_DIST = \
+ terminal_widget.hg terminal_widget.ccg \
+ reaper.hg reaper.ccg
+
+AM_CXXFLAGS = -I$(top_srcdir) \
+ @PALUDIS_CXXFLAGS@ \
+ @PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST@ \
+ @PALUDIS_CXXFLAGS_NO_WREDUNDANT_DECLS@
+
+DEFS = \
+ -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DLIBEXECDIR=\"$(libexecdir)\" \
+ -DGLIBMM_EXCEPTIONS_ENABLED=1
+
+vte_generated_sources = \
+ terminal_widget.cc terminal_widget.hh private/terminal_widget_p.hh \
+ reaper.cc reaper.hh private/reaper_p.hh
+
+SUBDIRS = defs converts .
+
+if ENABLE_GTK
+
+BUILT_SOURCES = terminal_widget.hh reaper.hh $(vte_generated_sources)
+
+terminal_widget.hh terminal_widget.cc : terminal_widget.hg terminal_widget.ccg
+ mkdir -p private
+ @GMMPROC@ --unwrapped -I converts --defs defs terminal_widget . .
+ sed -e 's@/\* vim: set @/* vim: set ro @' < ./terminal_widget.h > ./terminal_widget.hh
+ rm terminal_widget.h
+ mv ./terminal_widget.cc ./terminal_widget.cc.tmp
+ sed \
+ -e 's@#include <vtemm/terminal_widget.h>@#include "terminal_widget.hh"@' \
+ -e 's@#include <vtemm/private/terminal_widget_p.h>@#include "private/terminal_widget_p.hh"@' \
+ -e 's@/\* vim: set @/* vim: set ro @' \
+ < ./terminal_widget.cc.tmp > ./terminal_widget.cc
+ rm ./terminal_widget.cc.tmp
+ mv ./private/terminal_widget_p.h ./private/terminal_widget_p.hh
+
+reaper.hh reaper.cc : reaper.hg reaper.ccg
+ mkdir -p private
+ @GMMPROC@ --unwrapped -I converts --defs defs reaper . .
+ sed -e 's@/\* vim: set @/* vim: set ro @' < ./reaper.h > ./reaper.hh
+ rm reaper.h
+ mv ./reaper.cc ./reaper.cc.tmp
+ sed \
+ -e 's@#include <vtemm/reaper.h>@#include "reaper.hh"@' \
+ -e 's@#include <vtemm/private/reaper_p.h>@#include "private/reaper_p.hh"@' \
+ -e 's@/\* vim: set @/* vim: set ro @' \
+ < ./reaper.cc.tmp > ./reaper.cc
+ rm ./reaper.cc.tmp
+ mv ./private/reaper_p.h ./private/reaper_p.hh
+
+noinst_LIBRARIES = libvtemm.a
+
+nodist_libvtemm_a_SOURCES = \
+ $(vte_generated_sources)
+
+INCLUDES = $(DEPS_CFLAGS)
+
+clean-local :
+ rm -fr private || true
+
+endif
+
+CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda $(vte_generated_sources)
+MAINTAINERCLEANFILES = Makefile.in
+
diff --git a/src/gtkpaludis/vtemm/converts/Makefile.am b/src/gtkpaludis/vtemm/converts/Makefile.am
new file mode 100644
index 0000000..d9fa379
--- /dev/null
+++ b/src/gtkpaludis/vtemm/converts/Makefile.am
@@ -0,0 +1,6 @@
+noinst_DATA = convert.m4 convert_base.m4
+CLEANFILES = *~
+MAINTAINERCLEANFILES = Makefile.in
+EXTRA_DIST = $(noinst_DATA)
+
+
diff --git a/src/gtkpaludis/vtemm/converts/convert.m4 b/src/gtkpaludis/vtemm/converts/convert.m4
new file mode 100644
index 0000000..319807e
--- /dev/null
+++ b/src/gtkpaludis/vtemm/converts/convert.m4
@@ -0,0 +1,30 @@
+dnl $Id: convert.m4,v 1.1.1.1 2003/01/21 13:41:24 murrayc Exp $
+
+# Other libraries, such as libgnomeuimm, can provide their own convert.m4 files,
+# Maybe choosing to include the same files as this one.
+
+include(convert_gtkmm.m4)
+
+_CONV_ENUM(Vte,TerminalEraseBinding)
+_CONV_ENUM(Vte,TerminalAntiAlias)
+
+_EQUAL(glong, long)
+_EQUAL(guint, unsigned)
+
+_CONVERSION(int&, int*, &($3))
+_CONVERSION(long&, glong*, &($3))
+_CONVERSION(return-char*, char*, ($3))
+
+# Gtk conversions
+_CONVERSION(const Gtk::MenuShell&, GtkMenuShell*, (const_cast<Gtk::MenuShell&>($3)).gobj())
+
+# Gdk conversions
+_CONVERSION(const Gdk::Color&, const GdkColor*, ($3).gobj())
+_CONVERSION(Gdk::Color&, GdkColor*, ($3).gobj())
+_CONVERSION(Gdk::Cursor&, GdkCursor*, ($3).gobj())
+
+# Pango conversions
+_CONVERSION(const Pango::FontDescription&, const PangoFontDescription*, ($3).gobj())
+_CONVERSION(const PangoFontDescription*, const Pango::FontDescription, Glib::wrap(const_cast<PangoFontDescription*>(($3)), true))
+
+
diff --git a/src/gtkpaludis/vtemm/converts/convert_base.m4 b/src/gtkpaludis/vtemm/converts/convert_base.m4
new file mode 100644
index 0000000..feaf583
--- /dev/null
+++ b/src/gtkpaludis/vtemm/converts/convert_base.m4
@@ -0,0 +1,69 @@
+dnl $Id: convert_base.m4,v 1.1.1.1 2003/01/21 13:41:24 murrayc Exp $
+
+#
+# Define a hashing for names
+#
+define(`__HASH',`__`'m4_translit(`$*',`ABCDEFGHIJKLMNOPQRSTUVWXYZ<>[]&*, ',`abcdefghijklmnopqrstuvwxyzVBNMRSC_')`'')
+define(`__EQUIV',`m4_ifdef(EV`'__HASH(`$1'),EV`'__HASH(`$1'),`$1')')
+
+define(`__HASH2',`dnl
+pushdef(`__E1',__EQUIV(`$1'))pushdef(`__E2',__EQUIV(`$2'))dnl
+m4_ifelse(__E1,__E2,`__EQ',__HASH(__E1)`'__HASH(__E2))`'dnl
+popdef(`__E1')popdef(`__E2')`'')
+
+define(`CF__EQ',`$3')
+
+#
+# _CONVERT(ctype, cpptype, name, wrap_line)
+# Print the conversion from ctype to cpptype
+define(`_CONVERT',`dnl
+pushdef(`__COV',`CF`'__HASH2(`$1',`$2')')dnl
+m4_ifdef(__COV,`m4_indir(__COV,`$1',`$2',`$3')',`
+m4_errprint(`No conversion from $1 to $2 defined (line: $4, parameter name: $3)
+')
+m4_m4exit(1)
+')`'dnl
+')
+
+
+#
+# Functions for populating the tables.
+#
+define(`_CONVERSION',`
+m4_ifelse(`$3',,,`define(CF`'__HASH2(`$1',`$2'),`$3')')
+')
+
+define(`_EQUAL',`define(EV`'__HASH(`$1'),`$2')')
+
+/*******************************************************************/
+
+
+define(`__ARG3__',`$`'3')
+define(`_CONV_ENUM',`dnl
+_CONVERSION(`$1$2', `$2', (($2)(__ARG3__)))
+_CONVERSION(`$1$2', `$1::$2', (($1::$2)(__ARG3__)))
+_CONVERSION(`$2', `$1$2', (($1$2)(__ARG3__)))
+_CONVERSION(`$1::$2', `$1$2', (($1$2)(__ARG3__)))
+')dnl
+
+# e.g. Glib::RefPtr<Gdk::Something> to GdkSomething*
+define(`__CONVERT_REFPTR_TO_P',`Glib::unwrap($`'3)')
+
+# e.g. Glib::RefPtr<const Gdk::Something> to GdkSomething*
+#define(`__CONVERT_CONST_REFPTR_TO_P',`const_cast<$`'2>($`'3->gobj())')
+define(`__CONVERT_CONST_REFPTR_TO_P',`const_cast<$`'2>(Glib::unwrap($`'3))')
+
+# The Sun Forte compiler doesn't seem to be able to handle these, so we are using the altlernative, __CONVERT_CONST_REFPTR_TO_P_SUN.
+# The Sun compiler gives this error, for instance:
+#  "widget.cc", line 4463: Error: Overloading ambiguity between "Glib::unwrap<Gdk::Window>(const Glib::RefPtr<const Gdk::Window>&)" and
+# "Glib::unwrap<const Gdk::Window>(const Glib::RefPtr<const Gdk::Window>&)".
+#
+define(`__CONVERT_CONST_REFPTR_TO_P_SUN',`const_cast<$`'2>(Glib::unwrap<$1>($`'3))')
+
+
+include(convert_gtk.m4)
+include(convert_pango.m4)
+include(convert_gdk.m4)
+include(convert_atk.m4)
+include(convert_glib.m4)
+
diff --git a/src/gtkpaludis/vtemm/defs/Makefile.am b/src/gtkpaludis/vtemm/defs/Makefile.am
new file mode 100644
index 0000000..11d25a7
--- /dev/null
+++ b/src/gtkpaludis/vtemm/defs/Makefile.am
@@ -0,0 +1,51 @@
+vte_defs_included = \
+ vte_methods.defs \
+ vte_vfuncs.defs \
+ vte_enums.defs \
+ vte_signals.defs
+
+vte_defs = \
+ $(vte_defs_included) \
+ vte.defs
+
+if ENABLE_GTK
+
+noinst_DATA = $(vte_defs)
+noinst_PROGRAMS = force_automake_to_include_cxxcompile
+
+endif
+
+INCLUDES = $(DEPS_CFLAGS)
+
+force_automake_to_include_cxxcompile_SOURCES = force_automake_to_include_cxxcompile.cc
+
+force_automake_to_include_cxxcompile.cc :
+ echo 'int main(int, char *[]) { }' > $@
+
+generate_defs_vte : generate_defs_vte.cc
+ $(CXXCOMPILE) $(DEPS_LIBS) -lglibmm_generate_extra_defs-2.4 -o $@ $<
+
+CLEANFILES = *~ force_automake_to_include_cxxcompile.cc generate_defs_vte
+MAINTAINERCLEANFILES = Makefile.in $(vte_defs)
+
+vte_methods.defs :
+ if ! python `pkg-config --variable=datadir pygtk-2.0`/pygtk/2.0/codegen/h2def.py \
+ `pkg-config --variable=includedir vte`/vte/*.h \
+ > $@ ; then rm $@ ; false ; fi
+
+vte_enums.defs :
+ if ! perl $(srcdir)/enum.pl `pkg-config --variable=includedir vte`/vte/*.h > $@ ; \
+ then rm $@ ; false ; fi
+
+vte_signals.defs : generate_defs_vte
+ ./generate_defs_vte | sed -e 's~const-gchar\*~gchar*~' > $@
+
+vte.defs :
+ echo > $@
+ for a in $(vte_defs_included) ; do echo "(include $${a})" >> $@ ; done
+
+vte_vfuncs.defs :
+ touch $@
+
+EXTRA_DIST = enum.pl generate_defs_vte.cc
+
diff --git a/src/gtkpaludis/vtemm/defs/enum.pl b/src/gtkpaludis/vtemm/defs/enum.pl
new file mode 100644
index 0000000..df41545
--- /dev/null
+++ b/src/gtkpaludis/vtemm/defs/enum.pl
@@ -0,0 +1,230 @@
+#! /usr/bin/perl
+
+# The lisp definitions for flags does not include order.
+# thus we must extract it ourselves.
+# Usage: ./enum.pl /gnome/head/cvs/gconf/gconf/*.h > gconf_enums.defs
+
+
+my %token;
+$module="none";
+
+while ($ARGV[0] =~ /^--(\S+)/)
+{
+ shift @ARGV;
+ $module=shift @ARGV if ($1 eq "module");
+ if ($1 eq "help")
+ {
+ print "enum.pl [--module modname] header_files ....\n";
+ exit 0;
+ }
+}
+
+foreach $file (@ARGV)
+{
+ &parse($file);
+}
+
+exit;
+
+
+
+# parse enums from C
+sub parse
+{
+ my ($file)=@_;
+
+ $from=0;
+ open(FILE,$file);
+
+ $enum=0;
+ $deprecated=0;
+ $comment=0;
+
+ while(<FILE>)
+ {
+ if($comment)
+ {
+ # end of multiline comment
+ $comment = 0 if(/\*\//);
+ next;
+ }
+
+ $deprecated = 1 if(s/^#ifndef [A-Z_]+_DISABLE_DEPRECATED//);
+
+ ++$deprecated if($deprecated > 0 && /^#\s*if/);
+ --$deprecated if($deprecated > 0 && /^#\s*endif/);
+
+ next if($deprecated > 0);
+
+ # filter single-line comments
+ s/\/\*.*\*\///g;
+
+ # begin of multiline comment
+ if(/\/\*/)
+ {
+ $comment = 1;
+ next;
+ }
+
+ s/','/\%\%COMMA\%\%/;
+ s/'}'/\%\%RBRACE\%\%/;
+ if (/^typedef enum/ )
+ {
+ print ";; From $file\n\n" if (!$from);
+ $from=1;
+ $enum=1;
+ next;
+ }
+
+ if ($enum && /\}/)
+ {
+ $enum=0;
+ &process($line,$_);
+ $line="";
+ }
+ $line.=$_ if ($enum);
+ }
+}
+
+
+# convert enums to lisp
+sub process
+{
+ my ($line,$def)=@_;
+
+ $def=~s/\s*\}\s*//g;
+ $def=~s/\s*;\s*$//;
+ my $c_name=$def;
+
+ $line=~s/\s+/ /g;
+ $line=~s/\/\*.*\*\///g;
+ $line=~s/\s*{\s*//;
+
+ my $entity = "enum";
+ $c_name =~ /^([A-Z][a-z]*)/;
+ $module = $1;
+ $def =~ s/$module//;
+
+ @c_name=();
+ @name=();
+ @number=();
+
+ $val=0;
+ foreach $i (split(/,/,$line))
+ {
+ $i=~s/^\s+//;
+ $i=~s/\s+$//;
+ if ($i =~ /^\S+$/)
+ {
+ push(@c_name,$i);
+ push(@number,sprintf("%d",$val));
+ $token{$i}=$val;
+ }
+ elsif ($i =~ /^(\S+)\s*=\s*(0x[0-9a-fA-F]+)$/ ||
+ $i =~ /^(\S+)\s*=\s*(-?[0-9]+)$/ ||
+ $i =~ /^(\S+)\s*=\s*(1\s*<<\s*[0-9]+)$/
+ )
+ {
+ my ($tmp1, $tmp2) = ($1, $2);
+ push(@c_name, $tmp1);
+ eval("\$val = $tmp2;");
+ $entity = "flags" if($tmp2 =~ /^1\s*<</ || $tmp2 =~ /^0x/);
+ push(@number, $tmp2);
+ $token{$tmp1} = $tmp2;
+ }
+ elsif ($i =~ /^(\S+)\s*=\s*([ _x0-9a-fA-Z|()~]+)$/)
+ {
+ my ($tmp1, $tmp2) = ($1, $2);
+ push(@c_name, $tmp1);
+ $tmp2 =~ s/([A-Z_]+)/($token{$1})/;
+ eval("\$val = $tmp2;");
+ $val = "#error" if(!$val);
+ $val = sprintf("0x%X", $val) if($entity eq "flags");
+ push(@number, $val);
+ $token{$tmp1} = $val;
+ }
+ elsif ($i =~ /^(\S+)\s*=\s*'(.)'$/)
+ {
+ push(@c_name,$1);
+ push(@number,"\'$2\'");
+ $val=ord($2);
+ $token{$1}=$val;
+ }
+ elsif ($i =~ /^(\S+)\s*=\s*(\%\%[A-Z]+\%\%)$/)
+ {
+ $tmp=$1;
+ $_=$2;
+ s/\%\%COMMA\%\%/,/;
+ s/\%\%RBRACE\%\%/]/;
+ push(@c_name,$tmp);
+ push(@number,"\'$_\'");
+ $val=ord($_);
+ $token{$tmp}=$val;
+ }
+ else
+ {
+ #print STDERR "$i\n";
+ }
+ $val++;
+ }
+
+ # remove the prefix to form names
+ &form_names(\@name,\@c_name);
+
+ my $format = "%d";
+ $format = "0x%X" if($entity eq "flags");
+
+ # evaluate any unevaluated values
+ my $j;
+ for ($j=0;$j<$#number+1;$j++)
+ {
+ if ($number[$j]=~/\$/)
+ {
+ $number[$j]=sprintf($format, eval($number[$j]));
+ }
+ }
+
+ #print ";; Enum $def\n\n";
+ print "(define-$entity-extended $def\n";
+ print " (in-module \"$module\")\n";
+ print " (c-name \"$c_name\")\n";
+
+ print " (values\n";
+ for ($j=0;$j<$#c_name+1;$j++)
+ {
+ print " \'(\"$name[$j]\" \"$c_name[$j]\"";
+ print " \"$number[$j]\"" if ($number[$j] ne "");
+ print ")\n";
+ }
+ print " )\n";
+ print ")\n\n";
+}
+
+
+sub form_names
+{
+ my ($name,$c_name)=@_;
+
+ my $len=length($$c_name[0]) - 1;
+ my $j;
+ for ($j=0;$j<$#c_name;$j++)
+ {
+ while (substr($$c_name[$j],$len-1,1) ne "_" ||
+ substr($$c_name[$j],0,$len) ne substr($$c_name[$j+1],0,$len))
+ {
+ $len--;
+ }
+ #print substr($$c_name[$j],0,$len),"\n";
+ }
+
+ my $prefix=substr($$c_name[0],0,$len);
+
+ for ($j=0;$j<$#c_name+1;$j++)
+ {
+ $_=$$c_name[$j];
+ s/^$prefix//;
+ tr/A-Z_/a-z-/;
+ push(@$name,$_);
+ }
+
+}
diff --git a/src/gtkpaludis/vtemm/defs/generate_defs_vte.cc b/src/gtkpaludis/vtemm/defs/generate_defs_vte.cc
new file mode 100644
index 0000000..20c9b5c
--- /dev/null
+++ b/src/gtkpaludis/vtemm/defs/generate_defs_vte.cc
@@ -0,0 +1,36 @@
+/* $Id: generate_defs_gtk.cc,v 1.22 2006/05/16 18:03:21 murrayc Exp $ */
+
+/* generate_defs_gtk.cc
+ *
+ * Copyright (C) 2001 The Free Software Foundation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "glibmm_generate_extra_defs/generate_extra_defs.h"
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+#include <vte/vte.h>
+#include <vte/reaper.h>
+
+int main (int argc, char *argv[])
+{
+ gtk_init(&argc, &argv);
+
+std::cout << get_defs(VTE_TYPE_TERMINAL)
+ << get_defs(VTE_TYPE_REAPER);
+
+ return 0;
+}
diff --git a/src/gtkpaludis/vtemm/reaper.ccg b/src/gtkpaludis/vtemm/reaper.ccg
new file mode 100644
index 0000000..e2f1164
--- /dev/null
+++ b/src/gtkpaludis/vtemm/reaper.ccg
@@ -0,0 +1,65 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * 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/reaper.h>
+#include <paludis/util/exception.hh>
+
+namespace
+{
+
+ void Reaper_proxy_signal_child_exited(GObject*, int pid, int status, gpointer data)
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ if (Vte::Reaper::get_instance() == data) //ignore signals connected using c api
+ Vte::Reaper::get_instance()->signal_child_exited().emit(pid, status);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ }
+} /* anonymous namspace */
+
+namespace Vte
+{
+
+ Reaper::Reaper() :
+ Glib::Object(reinterpret_cast<GObject*>(::vte_reaper_get()))
+ {
+ //TODO: looks like vte-0.13.3 has child-exited renamed abi/api breakage??
+ //propably shoud be also unregistred if Reaper will stop be singleton
+ g_signal_connect(G_OBJECT(gobj()), "child-exited", G_CALLBACK(Reaper_proxy_signal_child_exited) , this);
+ }
+
+ int Reaper::add_child(GPid pid)
+ {
+ return vte_reaper_add_child(pid);
+ }
+
+ sigc::signal<void, int, int>& Reaper::signal_child_exited()
+ {
+ return _signal_child_exited;
+ }
+}
+
diff --git a/src/gtkpaludis/vtemm/reaper.hg b/src/gtkpaludis/vtemm/reaper.hg
new file mode 100644
index 0000000..3447636
--- /dev/null
+++ b/src/gtkpaludis/vtemm/reaper.hg
@@ -0,0 +1,50 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * 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 <sys/types.h>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <glibmm/object.h>
+#include <sigc++/sigc++.h>
+
+_DEFS(vtemm,vte)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Vte
+{
+ class Reaper :
+ public Glib::Object,
+ public paludis::InstantiationPolicy<Reaper, paludis::instantiation_method::SingletonAsNeededTag>
+
+ {
+ friend class paludis::InstantiationPolicy<Reaper, paludis::instantiation_method::SingletonAsNeededTag>;
+
+ sigc::signal<void, int, int> _signal_child_exited;
+
+ _CLASS_GOBJECT(Reaper,VteReaper,VTE_REAPER,Glib::Object,GObject)
+
+ Reaper();
+
+ public:
+
+ int add_child(GPid pid);
+ sigc::signal<void, int, int>& signal_child_exited();
+
+ };
+}
diff --git a/src/gtkpaludis/vtemm/terminal_widget.ccg b/src/gtkpaludis/vtemm/terminal_widget.ccg
new file mode 100644
index 0000000..74ff4a9
--- /dev/null
+++ b/src/gtkpaludis/vtemm/terminal_widget.ccg
@@ -0,0 +1,159 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * 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/vte.h>
+
+namespace
+{
+
+gboolean proxy_slot_selected_callback(VteTerminal * /* term */ , glong column, glong row, gpointer data)
+{
+ typedef Vte::Terminal::SlotIsSelected SlotType;
+ SlotType& slot(*static_cast<SlotType*>(data));
+
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ return slot(column, row);
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ return 0;
+}
+
+} /* anonymous namespace */
+
+
+namespace Vte
+{
+
+CharAttributes::CharAttributes(VteCharAttributes* obj) :
+ _gobject(new VteCharAttributes(*obj))
+{
+}
+
+CharAttributes::~CharAttributes()
+{
+ delete _gobject;
+}
+
+CharAttributes::CharAttributes(const CharAttributes& rhs) :
+ _gobject(new VteCharAttributes(*rhs._gobject))
+{
+}
+
+CharAttributes& CharAttributes::operator= (const CharAttributes& rhs)
+{
+ if (this != &rhs)
+ {
+ delete _gobject;
+ _gobject = new VteCharAttributes(*rhs._gobject);
+ }
+ return *this;
+}
+
+int CharAttributes::row() const
+{
+ return _gobject->row;
+}
+
+int CharAttributes::column() const
+{
+ return _gobject->column;
+}
+
+Gdk::Color CharAttributes::foreground() const
+{
+ return Gdk::Color(&_gobject->fore, true);
+}
+
+Gdk::Color CharAttributes::background() const
+{
+ return Gdk::Color(&_gobject->back, true);
+}
+
+bool CharAttributes::underline() const
+{
+ return _gobject->underline;
+}
+
+bool CharAttributes::strikethrough() const
+{
+ return _gobject->strikethrough;
+}
+
+char* Terminal::get_text(const Terminal::SlotIsSelected& slot, std::vector<CharAttributes>& attributes)
+{
+ GArray* garray(g_array_new(false, true, sizeof(VteCharAttributes)));
+ Terminal::SlotIsSelected slot_copy(slot);
+
+ char * result(vte_terminal_get_text(gobj(), &proxy_slot_selected_callback, &slot_copy, garray));
+
+ for (size_t i=0; i< garray->len; ++i)
+ {
+ attributes.push_back(new VteCharAttributes(g_array_index(garray, VteCharAttributes, i))); //TODO suboptimal deep copy
+ }
+
+ g_array_free(garray, false);
+
+ return result;
+}
+
+char* Terminal::get_text_include_trailing_spaces(const Terminal::SlotIsSelected& slot, std::vector<CharAttributes>& attributes)
+{
+ GArray* garray(g_array_new(false, true, sizeof(VteCharAttributes)));
+ Terminal::SlotIsSelected slot_copy(slot);
+
+ char * result(vte_terminal_get_text_include_trailing_spaces(gobj(),
+ &proxy_slot_selected_callback, &slot_copy, garray));
+
+ for (size_t i=0; i< garray->len; ++i)
+ {
+ attributes.push_back(new VteCharAttributes(g_array_index(garray, VteCharAttributes, i))); //TODO suboptimal deep copy
+ }
+
+ g_array_free(garray, true);
+
+ return result;
+}
+
+char* Terminal::get_text_range(long start_row, long start_col, long end_row, long end_col, const SlotIsSelected& slot, std::vector<CharAttributes>& attributes)
+{
+ GArray* garray(g_array_new(false, true, sizeof(VteCharAttributes)));
+ Terminal::SlotIsSelected slot_copy(slot);
+
+ char * result(vte_terminal_get_text_range(gobj(),start_row, start_col, end_row, end_col,
+ &proxy_slot_selected_callback, &slot_copy, garray));
+
+ for (size_t i=0; i< garray->len; ++i)
+ {
+ attributes.push_back(new VteCharAttributes(g_array_index(garray, VteCharAttributes, i))); //TODO suboptimal deep copy
+ }
+
+ g_array_free(garray, true);
+
+ return result;
+}
+
+} /* namespace Vte */
diff --git a/src/gtkpaludis/vtemm/terminal_widget.hg b/src/gtkpaludis/vtemm/terminal_widget.hg
new file mode 100644
index 0000000..956a293
--- /dev/null
+++ b/src/gtkpaludis/vtemm/terminal_widget.hg
@@ -0,0 +1,181 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * 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 <gtkmm/widget.h>
+#include <gtkmm/menushell.h>
+#include <gtkmm/adjustment.h>
+#include <gdkmm/cursor.h>
+#include <pangomm/fontdescription.h>
+
+#include <vector>
+
+_DEFS(vtemm,vte)
+_PINCLUDE(gtkmm/private/widget_p.h)
+
+/* we don't want whole vte.h in this file */
+typedef struct _VteCharAttributes VteCharAttributes;
+
+namespace Vte
+{
+
+
+class CharAttributes
+{
+private:
+ VteCharAttributes * _gobject;
+
+public:
+ CharAttributes(VteCharAttributes *obj);
+ CharAttributes(const CharAttributes&);
+
+ ~CharAttributes();
+
+ CharAttributes& operator= (const CharAttributes&);
+
+ int row() const;
+ int column() const;
+ Gdk::Color foreground() const;
+ Gdk::Color background() const;
+ bool underline() const;
+ bool strikethrough() const;
+};
+
+_WRAP_ENUM(TerminalEraseBinding, VteTerminalEraseBinding)
+_WRAP_ENUM(TerminalAntiAlias, VteTerminalAntiAlias)
+
+class Terminal :
+ public Gtk::Widget
+{
+
+_CLASS_GTKOBJECT(Terminal,VteTerminal,VTE_TERMINAL,Gtk::Widget,GtkWidget)
+public:
+
+typedef sigc::slot<bool, long, long> SlotIsSelected;
+
+_CTOR_DEFAULT
+
+_WRAP_METHOD(void im_append_menuitems(const Gtk::MenuShell& menushell), vte_terminal_im_append_menuitems)
+_WRAP_METHOD(pid_t fork_command(const char* command, char** argv, char** envv, const char* directory, bool lastlog, bool utmp, bool wtmp), vte_terminal_fork_command)
+_WRAP_METHOD(pid_t forkpty(char** env, const char* directory, bool lastlog, bool utmp, bool wtmp), vte_terminal_forkpty)
+_WRAP_METHOD(void set_pty(int pty_master), vte_terminal_set_pty)
+_WRAP_METHOD(void feed(const char* data, glong length), vte_terminal_feed)
+_WRAP_METHOD(void feed_child(const char* text, glong length), vte_terminal_feed_child)
+_WRAP_METHOD(void feed_child_binary(const char* data, glong length), vte_terminal_feed_child_binary)
+_WRAP_METHOD(void copy_clipboard(), vte_terminal_copy_clipboard)
+_WRAP_METHOD(void paste_clipboard(), vte_terminal_paste_clipboard)
+_WRAP_METHOD(void copy_primary(), vte_terminal_copy_primary)
+_WRAP_METHOD(void paste_primary(), vte_terminal_paste_primary)
+_WRAP_METHOD(void set_size(glong columns, glong rows), vte_terminal_set_size)
+_WRAP_METHOD(void set_audible_bell(bool is_audible), vte_terminal_set_audible_bell)
+_WRAP_METHOD(bool get_audible_bell(), vte_terminal_get_audible_bell)
+_WRAP_METHOD(void set_visible_bell(bool is_visible), vte_terminal_set_visible_bell)
+_WRAP_METHOD(bool get_visible_bell(), vte_terminal_get_visible_bell)
+_WRAP_METHOD(void set_allow_bold(bool allow_bold), vte_terminal_set_allow_bold)
+_WRAP_METHOD(bool get_allow_bold(), vte_terminal_get_allow_bold)
+_WRAP_METHOD(void set_scroll_on_output(bool scroll), vte_terminal_set_scroll_on_output)
+_WRAP_METHOD(void set_scroll_on_keystroke(bool scroll), vte_terminal_set_scroll_on_keystroke)
+_WRAP_METHOD(void set_color_bold(const Gdk::Color& bold), vte_terminal_set_color_bold )
+_WRAP_METHOD(void set_color_foreground(const Gdk::Color& foreground), vte_terminal_set_color_foreground)
+_WRAP_METHOD(void set_color_background(const Gdk::Color& background), vte_terminal_set_color_background)
+_WRAP_METHOD(void set_color_dim(const Gdk::Color& dim), vte_terminal_set_color_dim)
+_WRAP_METHOD(void set_color_cursor(const Gdk::Color& cursor), vte_terminal_set_color_cursor)
+_WRAP_METHOD(void set_color_highlight(const Gdk::Color& highlight), vte_terminal_set_color_highlight)
+_WRAP_METHOD(void set_colors(const Gdk::Color& foreground, const Gdk::Color& background, const Gdk::Color& palete_size, glong palette_size), vte_terminal_set_colors)
+_WRAP_METHOD(void set_default_colors(), vte_terminal_set_default_colors)
+_WRAP_METHOD(void set_background_image(Glib::RefPtr<Gdk::Pixbuf> pixbuf), vte_terminal_set_background_image)
+_WRAP_METHOD(void set_background_image_file(const char* path), vte_terminal_set_background_image_file)
+_WRAP_METHOD(void set_background_saturation(double saturation), vte_terminal_set_background_saturation)
+_WRAP_METHOD(void set_background_transparent(bool transparent), vte_terminal_set_background_transparent)
+_WRAP_METHOD(void set_background_tint_color(const Gdk::Color& color), vte_terminal_set_background_tint_color)
+_WRAP_METHOD(void set_scroll_background(bool scroll), vte_terminal_set_scroll_background)
+_WRAP_METHOD(void set_cursor_blinks(bool blink), vte_terminal_set_cursor_blinks)
+_WRAP_METHOD(void set_scrollback_lines(long lines), vte_terminal_set_scrollback_lines)
+_WRAP_METHOD(void set_font(const Pango::FontDescription& font_desc), vte_terminal_set_font)
+_WRAP_METHOD(void set_font_from_string(const char* name), vte_terminal_set_font_from_string)
+_WRAP_METHOD(void set_font_from_string_full(const char* name, TerminalAntiAlias antialas), vte_terminal_set_font_from_string_full)
+_WRAP_METHOD(void set_font_full(const Pango::FontDescription& font_desc, TerminalAntiAlias antialas), vte_terminal_set_font_full)
+_WRAP_METHOD(const Pango::FontDescription get_font(), vte_terminal_get_font)
+_WRAP_METHOD(bool get_using_xft(), vte_terminal_get_using_xft)
+_WRAP_METHOD(bool get_has_selection(), vte_terminal_get_has_selection)
+_WRAP_METHOD(void set_word_chars(const char* spec), vte_terminal_set_word_chars)
+_WRAP_METHOD(bool is_word_char(gunichar), vte_terminal_is_word_char)
+_WRAP_METHOD(void set_backspace_binding(TerminalEraseBinding binding), vte_terminal_set_backspace_binding)
+_WRAP_METHOD(void set_delete_binding(TerminalEraseBinding binding), vte_terminal_set_delete_binding)
+_WRAP_METHOD(void set_mouse_autohide(bool setting), vte_terminal_set_mouse_autohide)
+_WRAP_METHOD(bool get_mouse_autohide(), vte_terminal_get_mouse_autohide)
+_WRAP_METHOD(void reset(bool full, bool clear_history), vte_terminal_reset)
+//_WRAP_METHOD(char* get_text(bool (*is_selected) (glong column,glong row,gpointer data), gpointer data, GArray *attributes), vte_terminal_get_text) //Manualy wrapped below
+//_WRAP_METHOD(char* get_text_range(glong start_row, glong start_col, glong end_row, glong end_col, gboolean (*is_selected) (glong column,glong row,gpointer data), gpointer data, GArray *attributes), vte_terminal_get_text_range) //Manualy wrapped bellow
+_WRAP_METHOD(void get_cursor_position(long& column, long& row), vte_terminal_get_cursor_position)
+_WRAP_METHOD(void match_clear_all(), vte_terminal_match_clear_all)
+_WRAP_METHOD(int match_add(const char* match), vte_terminal_match_add)
+_WRAP_METHOD(void match_remove(int tag), vte_terminal_match_remove)
+_WRAP_METHOD(char* match_check(glong column, glong row, int& tag), vte_terminal_match_check)
+_WRAP_METHOD(void match_set_cursor(int tag, Gdk::Cursor& ), vte_terminal_match_set_cursor)
+_WRAP_METHOD(void match_set_cursor_type(int tag, Gdk::CursorType), vte_terminal_match_set_cursor_type)
+_WRAP_METHOD(void set_emulation(const char* emulation), vte_terminal_set_emulation)
+_WRAP_METHOD(const char* get_emulation(), vte_terminal_get_emulation)
+_WRAP_METHOD(const char* get_default_emulation(), vte_terminal_get_default_emulation)
+_WRAP_METHOD(void set_encoding(const char* codeset), vte_terminal_set_encoding)
+_WRAP_METHOD(const char* get_encoding(), vte_terminal_get_encoding)
+_WRAP_METHOD(const char* get_status_line(), vte_terminal_get_status_line)
+_WRAP_METHOD(void get_padding(int& xpad, int& ypad), vte_terminal_get_padding)
+_WRAP_METHOD(Gtk::Adjustment* get_adjustment(), vte_terminal_get_adjustment)
+_WRAP_METHOD(glong get_char_ascent(), vte_terminal_get_char_ascent)
+_WRAP_METHOD(glong get_char_descent(), vte_terminal_get_char_descent)
+_WRAP_METHOD(glong get_char_height(), vte_terminal_get_char_height)
+_WRAP_METHOD(glong get_char_width(), vte_terminal_get_char_width)
+_WRAP_METHOD(glong get_column_count(), vte_terminal_get_column_count)
+_WRAP_METHOD(const char* get_icon_title(), vte_terminal_get_icon_title)
+_WRAP_METHOD(glong get_row_count(), vte_terminal_get_row_count)
+_WRAP_METHOD(const char* get_window_title(), vte_terminal_get_window_title)
+
+_WRAP_SIGNAL(void char_size_changed(unsigned w, unsigned h), "char-size-changed")
+_WRAP_SIGNAL(void child_exited(), "child-exited")
+_WRAP_SIGNAL(void commit(gchar* text, unsigned length), "commit")
+_WRAP_SIGNAL(void contents_changed(), "contents-changed")
+_WRAP_SIGNAL(void cursor_moved(), "cursor-moved")
+_WRAP_SIGNAL(void decrease_font_size(), "decrease-font-size")
+_WRAP_SIGNAL(void deiconify_window(), "deiconify-window")
+_WRAP_SIGNAL(void emulation_changed(), "emulation-changed")
+_WRAP_SIGNAL(void encoding_changed(), "encoding-changed")
+_WRAP_SIGNAL(void eof(), "eof")
+_WRAP_SIGNAL(void icon_title_changed(), "icon-title-changed")
+_WRAP_SIGNAL(void iconify_window(), "iconify-window")
+_WRAP_SIGNAL(void increase_font_size(), "increase-font-size")
+_WRAP_SIGNAL(void lower_window(), "lower-window")
+_WRAP_SIGNAL(void maximize_window(), "maximize-window")
+_WRAP_SIGNAL(void move_window(unsigned x, unsigned y), "move-window")
+_WRAP_SIGNAL(void raise_window(), "raise-window")
+_WRAP_SIGNAL(void refresh_window(), "refresh-window")
+_WRAP_SIGNAL(void resize_window(unsigned w, unsigned h), "resize-window")
+_WRAP_SIGNAL(void restore_window(), "restore-window")
+_WRAP_SIGNAL(void selection_changed(), "selection-changed")
+_WRAP_SIGNAL(void status_line_changed(), "status-line-changed")
+_WRAP_SIGNAL(void text_deleted(), "text-deleted")
+_WRAP_SIGNAL(void text_inserted(), "text-inserted")
+_WRAP_SIGNAL(void text_modified(), "text-modified")
+_WRAP_SIGNAL(void text_scrolled(int arg), "text-scrolled")
+_WRAP_SIGNAL(void window_title_changed(), "window-title-changed")
+ char* get_text(const SlotIsSelected& slot, std::vector<CharAttributes>& attributes);
+ char* get_text_include_trailing_spaces(const SlotIsSelected& slot, std::vector<CharAttributes>& attributes);
+ char* get_text_range(long start_row, long start_col, long end_row, long end_col, const SlotIsSelected& slot, std::vector<CharAttributes>& attributes);
+};
+
+} /* namespace Vte */