MooTermBuffer::set_window_title, MooTermBuffer::set_icon_name signals
This commit is contained in:
parent
fde725f6ab
commit
b1737bf29d
@ -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 {
|
typedef enum {
|
||||||
@ -826,18 +832,6 @@ inline static void buf_esc_m (G_GNUC_UNUSED MooTermBuffer *b
|
|||||||
g_warning ("%s: implement me", G_STRLOC);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -43,6 +43,8 @@ enum {
|
|||||||
BELL,
|
BELL,
|
||||||
FLASH_SCREEN,
|
FLASH_SCREEN,
|
||||||
SCREEN_SIZE_CHANGED,
|
SCREEN_SIZE_CHANGED,
|
||||||
|
SET_WINDOW_TITLE,
|
||||||
|
SET_ICON_NAME,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -122,6 +124,26 @@ static void moo_term_buffer_class_init (MooTermBufferClass *klass)
|
|||||||
G_TYPE_NONE, 2,
|
G_TYPE_NONE, 2,
|
||||||
G_TYPE_ULONG, G_TYPE_ULONG);
|
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,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_SCREEN_WIDTH,
|
PROP_SCREEN_WIDTH,
|
||||||
g_param_spec_ulong ("screen-width",
|
g_param_spec_ulong ("screen-width",
|
||||||
@ -609,3 +631,16 @@ MooTermBuffer *moo_term_buffer_new (gulong width,
|
|||||||
"screen-height", height,
|
"screen-height", height,
|
||||||
NULL));
|
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);
|
||||||
|
}
|
||||||
|
@ -83,6 +83,10 @@ struct _MooTermBufferClass {
|
|||||||
|
|
||||||
void (*bell) (MooTermBuffer *buf);
|
void (*bell) (MooTermBuffer *buf);
|
||||||
void (*flash_screen) (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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -462,10 +462,10 @@ static ParseCharResult parse_char (MooTermParser *p, const char *c)
|
|||||||
{
|
{
|
||||||
case BEL:
|
case BEL:
|
||||||
p->state = CLEAN;
|
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)
|
if (p->title_len)
|
||||||
memcpy (p->title, p->buffer + 3, p->title_len);
|
memcpy (p->title, p->buffer + 4, p->title_len);
|
||||||
else
|
else
|
||||||
DEBUG_PRINT ("got \E]^G", NULL, 0);
|
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);
|
title = g_strndup (parser->title, parser->title_len);
|
||||||
|
|
||||||
if (set_title)
|
if (set_title)
|
||||||
buf_set_window_title (parser->parent, title);
|
moo_term_buffer_set_window_title (parser->parent, title);
|
||||||
if (set_icon)
|
if (set_icon)
|
||||||
buf_set_icon_name (parser->parent, title);
|
moo_term_buffer_set_icon_name (parser->parent, title);
|
||||||
|
|
||||||
g_free (title);
|
g_free (title);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define TERM_EMULATION "xterm"
|
#define TERM_EMULATION "xterm"
|
||||||
#define READ_BUFSIZE 4096
|
#define READ_BUFSIZE 4096
|
||||||
#define POLL_TIME 5
|
#define POLL_TIME 5
|
||||||
@ -341,18 +340,6 @@ static gboolean read_child_out (G_GNUC_UNUSED GIOChannel *source,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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);
|
feed_buffer (vt, buf, r);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,9 @@ int main (int argc, char *argv[])
|
|||||||
"cursor-visible", TRUE,
|
"cursor-visible", TRUE,
|
||||||
NULL);
|
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);
|
moo_term_fork_command (MOO_TERM (term), cmd, NULL, NULL);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (win), "destroy", gtk_main_quit, NULL);
|
g_signal_connect (G_OBJECT (win), "destroy", gtk_main_quit, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user