MooTermBuffer::set_window_title, MooTermBuffer::set_icon_name signals

This commit is contained in:
Yevgen Muntyan 2005-07-01 10:26:55 +00:00
parent fde725f6ab
commit b1737bf29d
6 changed files with 52 additions and 29 deletions

View File

@ -225,6 +225,12 @@ inline static void buf_thaw_cursor_notify (MooTermBuffer *buf)
}
void moo_term_buffer_set_window_title (MooTermBuffer *buf,
const char *title);
void moo_term_buffer_set_icon_name (MooTermBuffer *buf,
const char *icon);
/***************************************************************************/
typedef enum {
@ -826,18 +832,6 @@ inline static void buf_esc_m (G_GNUC_UNUSED MooTermBuffer *b
g_warning ("%s: implement me", G_STRLOC);
}
inline static void buf_set_window_title (G_GNUC_UNUSED MooTermBuffer *buf,
G_GNUC_UNUSED const char *title)
{
g_warning ("%s: implement me", G_STRLOC);
}
inline static void buf_set_icon_name (G_GNUC_UNUSED MooTermBuffer *buf,
G_GNUC_UNUSED const char *name)
{
g_warning ("%s: implement me", G_STRLOC);
}
G_END_DECLS

View File

@ -43,6 +43,8 @@ enum {
BELL,
FLASH_SCREEN,
SCREEN_SIZE_CHANGED,
SET_WINDOW_TITLE,
SET_ICON_NAME,
LAST_SIGNAL
};
@ -122,6 +124,26 @@ static void moo_term_buffer_class_init (MooTermBufferClass *klass)
G_TYPE_NONE, 2,
G_TYPE_ULONG, G_TYPE_ULONG);
signals[SET_WINDOW_TITLE] =
g_signal_new ("set-window-title",
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (MooTermBufferClass, set_window_title),
NULL, NULL,
_moo_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
signals[SET_ICON_NAME] =
g_signal_new ("set-icon-name",
G_OBJECT_CLASS_TYPE (gobject_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (MooTermBufferClass, set_icon_name),
NULL, NULL,
_moo_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
g_object_class_install_property (gobject_class,
PROP_SCREEN_WIDTH,
g_param_spec_ulong ("screen-width",
@ -609,3 +631,16 @@ MooTermBuffer *moo_term_buffer_new (gulong width,
"screen-height", height,
NULL));
}
void moo_term_buffer_set_window_title (MooTermBuffer *buf,
const char *title)
{
g_signal_emit (buf, signals[SET_WINDOW_TITLE], 0, title);
}
void moo_term_buffer_set_icon_name (MooTermBuffer *buf,
const char *icon)
{
g_signal_emit (buf, signals[SET_ICON_NAME], 0, icon);
}

View File

@ -83,6 +83,10 @@ struct _MooTermBufferClass {
void (*bell) (MooTermBuffer *buf);
void (*flash_screen) (MooTermBuffer *buf);
void (*set_window_title) (MooTermBuffer *buf,
const char *title);
void (*set_icon_name) (MooTermBuffer *buf,
const char *icon);
};

View File

@ -462,10 +462,10 @@ static ParseCharResult parse_char (MooTermParser *p, const char *c)
{
case BEL:
p->state = CLEAN;
p->title_len = p->buffer_len - 3;
p->title_len = p->buffer_len > 3 ? p->buffer_len - 4 : 0;
if (p->title_len)
memcpy (p->title, p->buffer + 3, p->title_len);
memcpy (p->title, p->buffer + 4, p->title_len);
else
DEBUG_PRINT ("got \E]^G", NULL, 0);
@ -1526,9 +1526,9 @@ static void exec_command (MooTermParser *parser)
title = g_strndup (parser->title, parser->title_len);
if (set_title)
buf_set_window_title (parser->parent, title);
moo_term_buffer_set_window_title (parser->parent, title);
if (set_icon)
buf_set_icon_name (parser->parent, title);
moo_term_buffer_set_icon_name (parser->parent, title);
g_free (title);
}

View File

@ -34,7 +34,6 @@
#include <sys/poll.h>
#endif
#define TERM_EMULATION "xterm"
#define READ_BUFSIZE 4096
#define POLL_TIME 5
@ -341,18 +340,6 @@ static gboolean read_child_out (G_GNUC_UNUSED GIOChannel *source,
break;
default:
{
int i;
g_print ("got >>>");
for (i = 0; i < r; ++i)
{
if (32 <= buf[i] && buf[i] <= 126)
g_print ("%c", buf[i]);
else
g_print ("<%d>", buf[i]);
}
g_print ("<<<\n");
}
feed_buffer (vt, buf, r);
break;
}

View File

@ -57,6 +57,9 @@ int main (int argc, char *argv[])
"cursor-visible", TRUE,
NULL);
g_signal_connect_swapped (buf, "set-window-title",
G_CALLBACK (gtk_window_set_title), win);
moo_term_fork_command (MOO_TERM (term), cmd, NULL, NULL);
g_signal_connect (G_OBJECT (win), "destroy", gtk_main_quit, NULL);