[vte/vte-next: 189/223] Add dummy set_buffer
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 189/223] Add dummy set_buffer
- Date: Wed, 22 Jun 2011 21:04:28 +0000 (UTC)
commit 89834ca008cba9ffd809e61ef73ec08a1403d581
Author: Christian Persch <chpe gnome org>
Date: Tue Jun 14 19:23:09 2011 +0200
Add dummy set_buffer
doc/reference/vte-sections.txt | 1 +
src/vte.c | 69 +++++++++++++++++++++++++++++++++++++++-
src/vte.h | 2 +
3 files changed, 71 insertions(+), 1 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index af20e8d..cc754ec 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -9,6 +9,7 @@ VteEraseBinding
VteWriteFlags
VteSelectionFunc
vte_terminal_new
+vte_terminal_set_buffer
vte_terminal_get_buffer
vte_terminal_im_append_menuitems
vte_terminal_select_all
diff --git a/src/vte.c b/src/vte.c
index b37e762..67565c6 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -132,6 +132,7 @@ enum {
TERMINAL_PASTE_CLIPBOARD,
TERMINAL_COPY_PRIMARY,
TERMINAL_PASTE_PRIMARY,
+ TERMINAL_BUFFER_CHANGED,
LAST_TERMINAL_SIGNAL
};
static guint signals[LAST_TERMINAL_SIGNAL];
@@ -2384,6 +2385,52 @@ vte_terminal_new(void)
}
/**
+ * vte_terminal_set_buffer:
+ * @terminal: a #VteTerminal
+ * @buffer: (allow-none): a #VteBuffer, or %NULL
+ *
+ * Sets @buffer as @terminal's buffer.
+ */
+void
+vte_terminal_set_buffer(VteTerminal *terminal,
+ VteBuffer *buffer)
+{
+ VteTerminalRealPrivate *pvt;
+ VteBuffer *old_buffer;
+ GObject *object;
+
+ g_return_if_fail(VTE_IS_TERMINAL(terminal));
+ g_return_if_fail(buffer == NULL || VTE_IS_BUFFER(buffer));
+
+ pvt = terminal->term_pvt;
+ if (pvt->buffer == buffer)
+ return;
+
+ object = G_OBJECT(terminal);
+
+ g_object_freeze_notify(object);
+
+ old_buffer = pvt->buffer;
+ if (old_buffer) {
+ /* defer unref until after "buffer-changed" signal emission */
+ }
+
+ pvt->buffer = buffer;
+ if (buffer) {
+ g_object_ref(buffer);
+ }
+
+ g_object_notify(object, "buffer");
+
+ g_signal_emit(terminal, signals[TERMINAL_BUFFER_CHANGED], 0, old_buffer);
+ if (old_buffer) {
+ g_object_unref(old_buffer);
+ }
+
+ g_object_thaw_notify(object);
+}
+
+/**
* vte_terminal_get_buffer:
* @terminal: a #VteTerminal
*
@@ -7793,7 +7840,9 @@ vte_terminal_init(VteTerminal *terminal)
/* Initialize private data. */
term_pvt = terminal->term_pvt = G_TYPE_INSTANCE_GET_PRIVATE (terminal, VTE_TYPE_TERMINAL, VteTerminalRealPrivate);
- buffer = term_pvt->buffer = vte_buffer_new();
+ buffer = vte_buffer_new();
+ vte_terminal_set_buffer(terminal, buffer);
+ g_object_unref(buffer);
term_pvt->buffer_pvt = term_pvt->buffer->pvt;
pvt = terminal->pvt = term_pvt->buffer_pvt;
@@ -11041,6 +11090,24 @@ vte_terminal_class_init(VteTerminalClass *klass)
/* Register some signals of our own. */
/**
+ * VteTerminal::buffer-changed:
+ * @terminal: the object which received the signal
+ * @previous_buffer: the previous buffer, or %NULL if there was none
+ *
+ * Emitted whenever the #VteBuffer of @terminal changes.
+ */
+ signals[TERMINAL_BUFFER_CHANGED] =
+ g_signal_new(I_("buffer-changed"),
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(VteTerminalClass, buffer_changed),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1, G_TYPE_OBJECT);
+
+ /**
* VteTerminal::char-size-changed:
* @vteterminal: the object which received the signal
* @width: the new character cell width
diff --git a/src/vte.h b/src/vte.h
index 7de9b52..9d6a449 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -74,6 +74,7 @@ struct _VteTerminalClass {
GtkWidgetClass parent_class;
/*< protected > */
+ 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);
@@ -111,6 +112,7 @@ GType vte_terminal_get_type(void);
GtkWidget *vte_terminal_new(void);
+void vte_terminal_set_buffer(VteTerminal *terminal, VteBuffer *buffer);
VteBuffer *vte_terminal_get_buffer(VteTerminal *terminal);
/* Copy currently-selected text to the clipboard, or from the clipboard to
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]