2005-06-22 11:20:32 -07:00
|
|
|
/*
|
2005-07-07 04:06:23 -07:00
|
|
|
* mooterm/mootermpt.c
|
2005-06-22 11:20:32 -07:00
|
|
|
*
|
2006-02-23 06:03:17 -08:00
|
|
|
* Copyright (C) 2004-2006 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
2005-06-22 11:20:32 -07:00
|
|
|
*
|
|
|
|
* This program 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.
|
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
2005-06-23 06:50:25 -07:00
|
|
|
#define MOOTERM_COMPILATION
|
2005-07-10 19:54:58 -07:00
|
|
|
#include "mooterm/mootermpt-private.h"
|
|
|
|
#include "mooterm/mooterm.h"
|
2005-06-22 15:13:12 -07:00
|
|
|
#include "mooutils/moomarshals.h"
|
|
|
|
#include "mooutils/moocompat.h"
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
static void moo_term_pt_finalize (GObject *object);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
/* MOO_TYPE_TERM_PT */
|
|
|
|
G_DEFINE_TYPE (MooTermPt, moo_term_pt, G_TYPE_OBJECT)
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
enum {
|
2005-06-22 15:13:12 -07:00
|
|
|
CHILD_DIED,
|
2005-06-22 11:20:32 -07:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2005-07-10 19:54:58 -07:00
|
|
|
PROP_0
|
2005-06-22 11:20:32 -07:00
|
|
|
};
|
|
|
|
|
2005-06-22 15:13:12 -07:00
|
|
|
static guint signals[LAST_SIGNAL];
|
2005-06-22 11:20:32 -07:00
|
|
|
|
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
static void moo_term_pt_class_init (MooTermPtClass *klass)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
gobject_class->finalize = moo_term_pt_finalize;
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-06-22 15:13:12 -07:00
|
|
|
signals[CHILD_DIED] =
|
|
|
|
g_signal_new ("child-died",
|
|
|
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
2005-07-07 04:06:23 -07:00
|
|
|
G_STRUCT_OFFSET (MooTermPtClass, child_died),
|
2005-06-22 15:13:12 -07:00
|
|
|
NULL, NULL,
|
|
|
|
_moo_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
static void moo_term_pt_init (MooTermPt *pt)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-07 04:06:23 -07:00
|
|
|
pt->priv = g_new0 (MooTermPtPrivate, 1);
|
|
|
|
pt->priv->pending_write = g_queue_new ();
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
static void moo_term_pt_finalize (GObject *object)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-07 04:06:23 -07:00
|
|
|
MooTermPt *pt = MOO_TERM_PT (object);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2006-04-03 00:56:05 -07:00
|
|
|
pt_discard_pending_write (pt);
|
2005-07-07 04:06:23 -07:00
|
|
|
g_queue_free (pt->priv->pending_write);
|
2005-06-23 06:50:25 -07:00
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
g_free (pt->priv);
|
2005-06-22 11:20:32 -07:00
|
|
|
|
2005-07-07 04:06:23 -07:00
|
|
|
G_OBJECT_CLASS (moo_term_pt_parent_class)->finalize (object);
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
MooTermPt*
|
|
|
|
_moo_term_pt_new (MooTerm *term)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-10 19:54:58 -07:00
|
|
|
MooTermPt *pt;
|
2005-06-22 15:13:12 -07:00
|
|
|
#ifdef __WIN32__
|
2006-04-06 14:23:00 -07:00
|
|
|
pt = g_object_new (MOO_TYPE_TERM_PT_CYG, NULL);
|
2005-06-22 15:13:12 -07:00
|
|
|
#else /* !__WIN32__ */
|
2005-07-10 19:54:58 -07:00
|
|
|
pt = g_object_new (MOO_TYPE_TERM_PT_UNIX, NULL);
|
2005-06-22 15:13:12 -07:00
|
|
|
#endif /* !__WIN32__ */
|
2005-07-10 19:54:58 -07:00
|
|
|
pt->priv->term = term;
|
|
|
|
return pt;
|
2005-06-22 15:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
void
|
|
|
|
_moo_term_pt_set_size (MooTermPt *pt,
|
|
|
|
guint width,
|
|
|
|
guint height)
|
2005-06-22 15:13:12 -07:00
|
|
|
{
|
2005-07-07 04:06:23 -07:00
|
|
|
g_return_if_fail (MOO_IS_TERM_PT (pt));
|
|
|
|
MOO_TERM_PT_GET_CLASS(pt)->set_size (pt, width, height);
|
2005-06-22 15:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
gboolean
|
|
|
|
_moo_term_pt_fork_command (MooTermPt *pt,
|
|
|
|
const MooTermCommand *cmd,
|
|
|
|
GError **error)
|
2005-06-22 15:13:12 -07:00
|
|
|
{
|
2005-07-07 04:06:23 -07:00
|
|
|
g_return_val_if_fail (MOO_IS_TERM_PT (pt), FALSE);
|
2006-07-31 22:54:24 -07:00
|
|
|
return MOO_TERM_PT_GET_CLASS(pt)->fork_command (pt, cmd, error);
|
2005-07-26 04:12:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-06 14:23:00 -07:00
|
|
|
char
|
2006-04-03 00:56:05 -07:00
|
|
|
_moo_term_pt_get_erase_char (MooTermPt *pt)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (MOO_IS_TERM_PT (pt), 0);
|
|
|
|
return MOO_TERM_PT_GET_CLASS(pt)->get_erase_char (pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-06 14:23:00 -07:00
|
|
|
void
|
2006-04-03 00:56:05 -07:00
|
|
|
_moo_term_pt_send_intr (MooTermPt *pt)
|
|
|
|
{
|
|
|
|
g_return_if_fail (MOO_IS_TERM_PT (pt));
|
|
|
|
MOO_TERM_PT_GET_CLASS(pt)->send_intr (pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
void
|
|
|
|
_moo_term_pt_kill_child (MooTermPt *pt)
|
2005-06-22 15:13:12 -07:00
|
|
|
{
|
2005-07-07 04:06:23 -07:00
|
|
|
g_return_if_fail (MOO_IS_TERM_PT (pt));
|
|
|
|
MOO_TERM_PT_GET_CLASS(pt)->kill_child (pt);
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
void
|
|
|
|
_moo_term_pt_write (MooTermPt *pt,
|
|
|
|
const char *data,
|
|
|
|
gssize len)
|
2005-06-22 11:20:32 -07:00
|
|
|
{
|
2005-07-07 04:06:23 -07:00
|
|
|
g_return_if_fail (MOO_IS_TERM_PT (pt));
|
|
|
|
MOO_TERM_PT_GET_CLASS(pt)->write (pt, data, len);
|
2005-06-22 11:20:32 -07:00
|
|
|
}
|
2005-07-14 23:37:09 -07:00
|
|
|
|
|
|
|
|
2005-10-13 07:08:18 -07:00
|
|
|
gboolean
|
|
|
|
_moo_term_pt_child_alive (MooTermPt *pt)
|
2005-07-14 23:37:09 -07:00
|
|
|
{
|
|
|
|
return pt->priv->child_alive;
|
|
|
|
}
|