[vte/vte-next: 179/223] Move bell signal to VteBuffer
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 179/223] Move bell signal to VteBuffer
- Date: Wed, 22 Jun 2011 21:03:38 +0000 (UTC)
commit f3c7a483691f8d74b66e38483ae55d86275b3b96
Author: Christian Persch <chpe gnome org>
Date: Sun Jun 12 21:29:50 2011 +0200
Move bell signal to VteBuffer
src/vte-private.h | 4 +--
src/vte.c | 75 +++++++++++++++++++++++++++++++---------------------
src/vte.h | 2 -
src/vtebuffer.h | 2 +
src/vteenums.h | 10 +++++++
src/vteseq.c | 6 ++--
6 files changed, 61 insertions(+), 38 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 8eb073e..feacaff 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -436,9 +436,6 @@ 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);
-void _vte_terminal_audible_beep(VteTerminal *terminal);
-void _vte_terminal_visible_beep(VteTerminal *terminal);
-void _vte_terminal_beep(VteTerminal *terminal);
void _vte_terminal_inline_error_message(VteTerminal *terminal, const char *format, ...) G_GNUC_PRINTF(2,3);
@@ -487,6 +484,7 @@ void _vte_buffer_emit_resize_window(VteBuffer *buffer, guint w, guint h);
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_terminal_handle_sequence(VteBuffer *buffer,
const char *match_s,
GQuark match,
diff --git a/src/vte.c b/src/vte.c
index aa4d56b..0efa065 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -183,6 +183,7 @@ enum {
BUFFER_TEXT_MODIFIED,
BUFFER_TEXT_INSERTED,
BUFFER_TEXT_DELETED,
+ BUFFER_BELL,
LAST_BUFFER_SIGNAL,
};
@@ -1029,6 +1030,14 @@ vte_buffer_emit_text_modified(VteBuffer *buffer)
g_signal_emit(buffer, buffer_signals[BUFFER_TEXT_MODIFIED], 0);
}
+void
+_vte_buffer_emit_bell(VteBuffer *buffer, VteBellType bell_type)
+{
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `bell'.\n");
+ g_signal_emit(buffer, buffer_signals[BUFFER_BELL], 0, bell_type);
+}
+
/* Emit a "text-scrolled" signal. */
static void
vte_terminal_emit_text_scrolled(VteTerminal *terminal, gint delta)
@@ -4479,8 +4488,8 @@ _vte_check_cursor_blink(VteTerminal *terminal)
remove_cursor_timeout(terminal);
}
-void
-_vte_terminal_audible_beep(VteTerminal *terminal)
+static void
+vte_terminal_audible_beep(VteTerminal *terminal)
{
GdkDisplay *display;
@@ -4489,8 +4498,8 @@ _vte_terminal_audible_beep(VteTerminal *terminal)
gdk_display_beep(display);
}
-void
-_vte_terminal_visible_beep(VteTerminal *terminal)
+static void
+vte_terminal_visible_beep(VteTerminal *terminal)
{
GtkWidget *widget = &terminal->widget;
GtkAllocation allocation;
@@ -4521,18 +4530,18 @@ _vte_terminal_visible_beep(VteTerminal *terminal)
}
}
-void
-_vte_terminal_beep(VteTerminal *terminal)
+static void
+vte_terminal_beep(VteTerminal *terminal,
+ VteBellType bell_type)
{
- if (terminal->pvt->audible_bell) {
- _vte_terminal_audible_beep (terminal);
+ if (bell_type == VTE_BELL_AUDIBLE && terminal->pvt->audible_bell) {
+ vte_terminal_audible_beep (terminal);
}
- if (terminal->pvt->visible_bell) {
- _vte_terminal_visible_beep (terminal);
+ if (bell_type == VTE_BELL_VISUAL && terminal->pvt->visible_bell) {
+ vte_terminal_visible_beep (terminal);
}
}
-
static guint
vte_translate_ctrlkey (GdkEventKey *event)
{
@@ -4622,7 +4631,7 @@ vte_terminal_key_press(GtkWidget *widget, GdkEventKey *event)
if ((terminal->pvt->screen->cursor_current.col +
(glong) terminal->pvt->bell_margin) ==
terminal->pvt->column_count) {
- _vte_terminal_beep (terminal);
+ _vte_buffer_emit_bell(terminal->term_pvt->buffer, VTE_BELL_AUDIBLE);
}
}
@@ -7747,6 +7756,11 @@ vte_terminal_init(VteTerminal *terminal)
pvt = terminal->pvt = term_pvt->buffer_pvt;
pvt->terminal = terminal;
+ /* buffer signals */
+ g_signal_connect_swapped(buffer, "bell", G_CALLBACK(vte_terminal_beep), terminal);
+
+ /* --- */
+
gtk_widget_set_can_focus(&terminal->widget, TRUE);
gtk_widget_set_app_paintable (&terminal->widget, TRUE);
@@ -10943,8 +10957,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
klass->copy_clipboard = vte_terminal_real_copy_clipboard;
klass->paste_clipboard = vte_terminal_real_paste_clipboard;
- klass->beep = NULL;
-
/* GtkScrollable interface properties */
g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
@@ -11083,22 +11095,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
G_TYPE_NONE, 0);
/**
- * VteTerminal::beep:
- * @vteterminal: the object which received the signal
- *
- * This signal is emitted when the a child sends a beep request to the
- * terminal.
- */
- g_signal_new(I_("beep"),
- G_OBJECT_CLASS_TYPE(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(VteTerminalClass, beep),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- /**
* VteTerminal:buffer:
*
* The terminal's buffer.
@@ -13477,6 +13473,7 @@ vte_buffer_class_init(VteBufferClass *klass)
klass->text_modified = NULL;
klass->text_inserted = NULL;
klass->text_deleted = NULL;
+ klass->bell = NULL;
/**
* VteBuffer::child-exited:
@@ -13839,6 +13836,24 @@ vte_buffer_class_init(VteBufferClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ * VteBuffer::bell:
+ * @vtebuffer: the object which received the signal
+ *
+ * This signal is emitted when the a child sends a bell request to the
+ * buffer.
+ */
+ buffer_signals[BUFFER_BELL] =
+ g_signal_new(I_("bell"),
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(VteBufferClass, bell),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE,
+ 1, VTE_TYPE_BELL_TYPE);
+
/* Properties */
/**
diff --git a/src/vte.h b/src/vte.h
index 7fd46fb..6f0d6f2 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -88,8 +88,6 @@ struct _VteTerminalClass {
void (*copy_clipboard)(VteTerminal* terminal);
void (*paste_clipboard)(VteTerminal* terminal);
- void (*beep)(VteTerminal* terminal);
-
/* Padding for future expansion. */
gpointer padding[16];
diff --git a/src/vtebuffer.h b/src/vtebuffer.h
index 7d202ee..8af3672 100644
--- a/src/vtebuffer.h
+++ b/src/vtebuffer.h
@@ -72,6 +72,8 @@ struct _VteBufferClass {
void (*text_modified) (VteBuffer* buffer);
void (*text_inserted) (VteBuffer* buffer);
void (*text_deleted) (VteBuffer* buffer);
+ void (*bell) (VteBuffer* buffer,
+ VteBellType bell_type);
/*< private >*/
VteBufferClassPrivate *priv;
diff --git a/src/vteenums.h b/src/vteenums.h
index 9ee001d..5cbf1dc 100644
--- a/src/vteenums.h
+++ b/src/vteenums.h
@@ -88,6 +88,16 @@ typedef enum {
/**
+ * VteBell:
+ * @VTE_BELL_AUDIBLE:
+ * @VTE_BELL_VISUAL:
+ */
+typedef enum {
+ VTE_BELL_AUDIBLE,
+ VTE_BELL_VISUAL
+} VteBellType;
+
+/**
* VteWriteFlags:
* @VTE_TERMINAL_WRITE_DEFAULT: Write contents as UTF-8 text. This is the default.
*
diff --git a/src/vteseq.c b/src/vteseq.c
index 032ec35..99acada 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -881,8 +881,8 @@ vte_sequence_handler_as (VteBuffer *buffer, GValueArray *params)
static void
vte_sequence_handler_bl (VteBuffer *buffer, GValueArray *params)
{
- _vte_terminal_beep (buffer->pvt->terminal);
- g_signal_emit_by_name(buffer->pvt->terminal, "beep");
+ _vte_buffer_emit_bell(buffer, VTE_BELL_AUDIBLE);
+ /* FIXMEchpe: also emit visual bell here?? */
}
/* Backtab. */
@@ -2127,7 +2127,7 @@ vte_sequence_handler_us (VteBuffer *buffer, GValueArray *params)
static void
vte_sequence_handler_vb (VteBuffer *buffer, GValueArray *params)
{
- _vte_terminal_visible_beep (buffer->pvt->terminal);
+ _vte_buffer_emit_bell(buffer, VTE_BELL_VISUAL);
}
/* Cursor visible. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]