[vte/vte-next: 201/223] Move contents-changed signal to VteBuffer
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 201/223] Move contents-changed signal to VteBuffer
- Date: Wed, 22 Jun 2011 21:05:29 +0000 (UTC)
commit d0aca10ebedebe3c406ded1807b8bb59d82c56fe
Author: Christian Persch <chpe gnome org>
Date: Sat Jun 18 22:54:12 2011 +0200
Move contents-changed signal to VteBuffer
src/vte-private.h | 4 +-
src/vte.c | 87 ++++++++++++++++++++++++++++++-----------------------
src/vte.h | 1 -
src/vtebuffer.h | 1 +
src/vteseq.c | 2 +-
5 files changed, 53 insertions(+), 42 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index d03a5dd..d9969eb 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -269,6 +269,7 @@ struct _VteBufferPrivate {
gboolean text_modified_flag;
gboolean text_inserted_flag;
gboolean text_deleted_flag;
+ gboolean contents_changed_pending;
GdkRGBA palette[VTE_PALETTE_SIZE];
guint32 palette_set[(VTE_PALETTE_SIZE + 31) / 32];
@@ -410,7 +411,6 @@ struct _VteTerminalPrivate {
/* Adjustment updates pending. */
gboolean adjustment_changed_pending;
gboolean adjustment_value_changed_pending;
- gboolean contents_changed_pending;
/* Background pattern */
cairo_pattern_t *bg_pattern;
@@ -454,7 +454,6 @@ void _vte_invalidate_cells(VteTerminal *terminal,
void _vte_invalidate_cell(VteTerminal *terminal, glong col, glong row);
void _vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic);
void _vte_terminal_adjust_adjustments(VteTerminal *terminal);
-void _vte_terminal_queue_contents_changed(VteTerminal *terminal);
void _vte_terminal_scroll_region(VteTerminal *terminal,
long row, glong count, glong delta);
@@ -504,6 +503,7 @@ void _vte_buffer_emit_move_window(VteBuffer *buffer, guint x, guint y);
void _vte_buffer_emit_text_deleted(VteBuffer *buffer);
void _vte_buffer_emit_text_inserted(VteBuffer *buffer);
void _vte_buffer_emit_bell(VteBuffer *buffer, VteBellType bell_type);
+void _vte_buffer_queue_contents_changed(VteBuffer *buffer);
void _vte_terminal_handle_sequence(VteBuffer *buffer,
const char *match_s,
GQuark match,
diff --git a/src/vte.c b/src/vte.c
index 231b6f1..2495f81 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -124,6 +124,8 @@ static void vte_terminal_set_cursor_blinks_internal(VteTerminal *terminal, gbool
static void _vte_check_cursor_blink(VteTerminal *terminal);
static void vte_terminal_set_font(VteTerminal *terminal, PangoFontDescription *desc /* adopted */);
static void vte_terminal_beep(VteTerminal *terminal, VteBellType bell_type);
+static void vte_terminal_buffer_contents_changed(VteTerminal *terminal);
+static void vte_terminal_process_incoming(VteTerminal *terminal);
static gboolean process_timeout (gpointer data);
static gboolean update_timeout (gpointer data);
@@ -188,6 +190,7 @@ enum {
BUFFER_TEXT_MODIFIED,
BUFFER_TEXT_INSERTED,
BUFFER_TEXT_DELETED,
+ BUFFER_CONTENTS_CHANGED,
BUFFER_BELL,
LAST_BUFFER_SIGNAL,
};
@@ -841,6 +844,18 @@ vte_invalidate_cursor_periodic (VteTerminal *terminal)
return FALSE;
}
+static void
+vte_terminal_buffer_contents_changed(VteTerminal *terminal)
+{
+ /* Update dingus match set. */
+ vte_terminal_match_contents_clear(terminal);
+ if (terminal->pvt->mouse_cursor_visible) {
+ vte_terminal_match_hilite_update(terminal,
+ terminal->pvt->mouse_last_x,
+ terminal->pvt->mouse_last_y);
+ }
+}
+
/* Emit a "selection_changed" signal. */
static void
vte_terminal_emit_selection_changed(VteTerminal *terminal)
@@ -908,29 +923,22 @@ vte_buffer_emit_child_exited(VteBuffer *buffer,
/* Emit a "contents_changed" signal. */
static void
-vte_terminal_emit_contents_changed(VteTerminal *terminal)
+vte_buffer_emit_contents_changed(VteBuffer *buffer)
{
- if (terminal->pvt->contents_changed_pending) {
- /* Update dingus match set. */
- vte_terminal_match_contents_clear(terminal);
- if (terminal->pvt->mouse_cursor_visible) {
- vte_terminal_match_hilite_update(terminal,
- terminal->pvt->mouse_last_x,
- terminal->pvt->mouse_last_y);
- }
-
+ if (buffer->pvt->contents_changed_pending) {
_vte_debug_print(VTE_DEBUG_SIGNALS,
"Emitting `contents-changed'.\n");
- g_signal_emit_by_name(terminal, "contents-changed");
- terminal->pvt->contents_changed_pending = FALSE;
+ g_signal_emit(buffer, buffer_signals[BUFFER_CONTENTS_CHANGED], 0);
+ buffer->pvt->contents_changed_pending = FALSE;
}
}
+
void
-_vte_terminal_queue_contents_changed(VteTerminal *terminal)
+_vte_buffer_queue_contents_changed(VteBuffer *buffer)
{
_vte_debug_print(VTE_DEBUG_SIGNALS,
"Queueing `contents-changed'.\n");
- terminal->pvt->contents_changed_pending = TRUE;
+ buffer->pvt->contents_changed_pending = TRUE;
}
/* Emit a "cursor_moved" signal. */
@@ -2450,6 +2458,7 @@ vte_terminal_set_buffer(VteTerminal *terminal,
old_buffer = pvt->buffer;
if (old_buffer) {
g_signal_handlers_disconnect_by_func(old_buffer, G_CALLBACK(vte_terminal_beep), terminal);
+ g_signal_handlers_disconnect_by_func(old_buffer, G_CALLBACK(vte_terminal_buffer_contents_changed), terminal);
/* defer unref until after "buffer-changed" signal emission */
}
@@ -2459,6 +2468,7 @@ vte_terminal_set_buffer(VteTerminal *terminal,
g_object_ref(buffer);
g_signal_connect_swapped(buffer, "bell", G_CALLBACK(vte_terminal_beep), terminal);
+ g_signal_connect_swapped(buffer, "contents-changed", G_CALLBACK(vte_terminal_buffer_contents_changed), terminal);
}
g_object_notify(object, "buffer");
@@ -3684,7 +3694,7 @@ next_match:
if (modified || (screen != buffer->pvt->screen)) {
/* Signal that the visible contents changed. */
- _vte_terminal_queue_contents_changed(terminal);
+ _vte_buffer_queue_contents_changed(buffer);
}
vte_terminal_emit_pending_signals (terminal);
@@ -7663,6 +7673,9 @@ vte_terminal_handle_scroll(VteTerminal *terminal)
VteScreen *screen;
buffer = terminal->pvt->buffer;
+ if (buffer == NULL)
+ return;
+
screen = buffer->pvt->screen;
/* Read the new adjustment value and save the difference. */
@@ -7684,7 +7697,7 @@ vte_terminal_handle_scroll(VteTerminal *terminal)
_vte_terminal_scroll_region(terminal, screen->scroll_delta,
buffer->pvt->row_count, -dy);
vte_terminal_emit_text_scrolled(terminal, dy);
- _vte_terminal_queue_contents_changed(terminal);
+ _vte_buffer_queue_contents_changed(buffer);
} else {
_vte_debug_print(VTE_DEBUG_ADJ, "Not scrolling\n");
}
@@ -8186,7 +8199,7 @@ vte_terminal_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
MAX (_vte_ring_delta (screen->row_data),
_vte_ring_next (screen->row_data) - 1));
/* Notify viewers that the contents have changed. */
- _vte_terminal_queue_contents_changed(terminal);
+ _vte_buffer_queue_contents_changed(buffer);
}
done_buffer:
@@ -8280,11 +8293,9 @@ vte_terminal_unrealize(GtkWidget *widget)
remove_update_timeout (terminal);
/* Cancel any pending signals */
- terminal->pvt->contents_changed_pending = FALSE;
-
if (buffer) {
+ buffer->pvt->contents_changed_pending = FALSE;
buffer->pvt->cursor_moved_pending = FALSE;
-
buffer->pvt->text_modified_flag = FALSE;
buffer->pvt->text_inserted_flag = FALSE;
buffer->pvt->text_deleted_flag = FALSE;
@@ -11058,7 +11069,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
/* Initialize default handlers. */
klass->char_size_changed = NULL;
klass->selection_changed = NULL;
- klass->contents_changed = NULL;
klass->increase_font_size = NULL;
klass->decrease_font_size = NULL;
@@ -11130,22 +11140,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
G_TYPE_NONE, 0);
/**
- * VteTerminal::contents-changed:
- * @vteterminal: the object which received the signal
- *
- * Emitted whenever the visible appearance of the terminal has changed.
- * Used primarily by #VteTerminalAccessible.
- */
- g_signal_new(I_("contents-changed"),
- G_OBJECT_CLASS_TYPE(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(VteTerminalClass, contents_changed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
* VteTerminal::increase-font-size:
* @vteterminal: the object which received the signal
*
@@ -12800,7 +12794,7 @@ vte_terminal_emit_pending_signals(VteTerminal *terminal)
/* Flush any pending "inserted" signals. */
vte_buffer_emit_cursor_moved(buffer);
vte_buffer_emit_pending_text_signals(buffer, 0);
- vte_terminal_emit_contents_changed (terminal);
+ vte_buffer_emit_contents_changed(buffer);
g_object_thaw_notify(buffer_object);
g_object_thaw_notify(object);
@@ -13844,6 +13838,7 @@ vte_buffer_class_init(VteBufferClass *klass)
klass->text_modified = NULL;
klass->text_inserted = NULL;
klass->text_deleted = NULL;
+ klass->contents_changed = NULL;
klass->bell = NULL;
/**
@@ -14208,6 +14203,22 @@ vte_buffer_class_init(VteBufferClass *klass)
G_TYPE_NONE, 0);
/**
+ * VteBuffer::contents-changed:
+ * @buffer: the object which received the signal
+ *
+ * Emitted whenever the visible appearance of the buffer has changed.
+ */
+ buffer_signals[BUFFER_CONTENTS_CHANGED] =
+ g_signal_new(I_("contents-changed"),
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(VteBufferClass, contents_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
* VteBuffer::bell:
* @vtebuffer: the object which received the signal
*
diff --git a/src/vte.h b/src/vte.h
index df94bcb..e75cb83 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -75,7 +75,6 @@ struct _VteTerminalClass {
void (*buffer_changed)(VteTerminal *terminal, VteBuffer *previous_buffer);
void (*char_size_changed)(VteTerminal* terminal, guint char_width, guint char_height);
void (*selection_changed)(VteTerminal* terminal);
- void (*contents_changed)(VteTerminal* terminal);
/* FIXMEchpe: should these return gboolean and have defaul thandlers
* settings the "scale" property?
diff --git a/src/vtebuffer.h b/src/vtebuffer.h
index 15559db..334d6a0 100644
--- a/src/vtebuffer.h
+++ b/src/vtebuffer.h
@@ -87,6 +87,7 @@ struct _VteBufferClass {
void (*text_modified) (VteBuffer* buffer);
void (*text_inserted) (VteBuffer* buffer);
void (*text_deleted) (VteBuffer* buffer);
+ void (*contents_changed) (VteBuffer* buffer);
void (*bell) (VteBuffer* buffer,
VteBellType bell_type);
diff --git a/src/vteseq.c b/src/vteseq.c
index 7065ed3..b7be0cd 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -782,7 +782,7 @@ vte_sequence_handler_decset_internal(VteBuffer *buffer,
buffer->pvt->screen->scroll_delta);
vte_buffer_set_scrollback_lines(buffer,
buffer->pvt->scrollback_lines);
- _vte_terminal_queue_contents_changed(buffer->pvt->terminal);
+ _vte_buffer_queue_contents_changed(buffer);
_vte_buffer_view_invalidate_all(buffer);
break;
case 9:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]