[vte/vte-next: 156/223] Move {move, resize}-window signals to VteBuffer
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-next: 156/223] Move {move, resize}-window signals to VteBuffer
- Date: Wed, 22 Jun 2011 21:01:42 +0000 (UTC)
commit 46b77e8cf939561fec89a5a0585b9ab6ded1f2cc
Author: Christian Persch <chpe gnome org>
Date: Sat Jun 11 21:51:02 2011 +0200
Move {move,resize}-window signals to VteBuffer
src/vte-private.h | 2 +
src/vte.c | 97 ++++++++++++++++++++++++++++++++--------------------
src/vte.h | 3 --
src/vteapp.c | 24 ++++++-------
src/vtebuffer.h | 6 +++
src/vteseq.c | 30 +++--------------
6 files changed, 84 insertions(+), 78 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 8f67245..00d2393 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -489,6 +489,8 @@ void _vte_buffer_emit_lower_window(VteBuffer *buffer);
void _vte_buffer_emit_refresh_window(VteBuffer *buffer);
void _vte_buffer_emit_restore_window(VteBuffer *buffer);
void _vte_buffer_emit_maximize_window(VteBuffer *buffer);
+void _vte_buffer_emit_resize_window(VteBuffer *buffer, guint w, guint h);
+void _vte_buffer_emit_move_window(VteBuffer *buffer, guint x, guint y);
/* private VteScreen methods */
void _vte_screen_set_default_attributes(VteScreen *screen);
diff --git a/src/vte.c b/src/vte.c
index f188be0..b17feb9 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -178,6 +178,8 @@ enum {
BUFFER_REFRESH_WINDOW,
BUFFER_RESTORE_WINDOW,
BUFFER_MAXIMIZE_WINDOW,
+ BUFFER_RESIZE_WINDOW,
+ BUFFER_MOVE_WINDOW,
LAST_BUFFER_SIGNAL,
};
@@ -1098,6 +1100,26 @@ _vte_buffer_emit_restore_window(VteBuffer *buffer)
g_signal_emit(buffer, buffer_signals[BUFFER_RESTORE_WINDOW], 0);
}
+/* Emit a "move-window" signal. (Pixels.) */
+void
+_vte_buffer_emit_move_window(VteBuffer *buffer, guint x, guint y)
+{
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `move-window'.\n");
+ g_signal_emit(buffer, buffer_signals[BUFFER_MOVE_WINDOW], 0, x, y);
+}
+
+/* Emit a "resize-window" signal. (Pixels.) */
+void
+_vte_buffer_emit_resize_window(VteBuffer *buffer,
+ guint width, guint height)
+{
+ _vte_debug_print(VTE_DEBUG_SIGNALS,
+ "Emitting `resize-window'.\n");
+ g_signal_emit(buffer, buffer_signals[BUFFER_RESIZE_WINDOW], 0,
+ width, height);
+}
+
/* Deselect anything which is selected and refresh the screen if needed. */
static void
vte_terminal_deselect_all(VteTerminal *terminal)
@@ -10896,9 +10918,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
klass->contents_changed = NULL;
klass->cursor_moved = NULL;
- klass->resize_window = NULL;
- klass->move_window = NULL;
-
klass->increase_font_size = NULL;
klass->decrease_font_size = NULL;
@@ -10986,40 +11005,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
G_TYPE_NONE, 0);
/**
- * VteTerminal::resize-window:
- * @vteterminal: the object which received the signal
- * @width: the desired width in pixels, including padding
- * @height: the desired height in pixels, including padding
- *
- * Emitted at the child application's request.
- */
- g_signal_new(I_("resize-window"),
- G_OBJECT_CLASS_TYPE(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(VteTerminalClass, resize_window),
- NULL,
- NULL,
- _vte_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
-
- /**
- * VteTerminal::move-window:
- * @vteterminal: the object which received the signal
- * @x: the terminal's desired location, X coordinate
- * @y: the terminal's desired location, Y coordinate
- *
- * Emitted at the child application's request.
- */
- g_signal_new(I_("move-window"),
- G_OBJECT_CLASS_TYPE(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET(VteTerminalClass, move_window),
- NULL,
- NULL,
- _vte_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
-
- /**
* VteTerminal::increase-font-size:
* @vteterminal: the object which received the signal
*
@@ -13539,6 +13524,8 @@ vte_buffer_class_init(VteBufferClass *klass)
klass->refresh_window = NULL;
klass->restore_window = NULL;
klass->maximize_window = NULL;
+ klass->resize_window = NULL;
+ klass->move_window = NULL;
/**
* VteBuffer::child-exited:
@@ -13794,6 +13781,42 @@ vte_buffer_class_init(VteBufferClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ * VteBuffer::resize-window:
+ * @vtebuffer: the object which received the signal
+ * @width: the desired width in pixels, including padding
+ * @height: the desired height in pixels, including padding
+ *
+ * Emitted at the child application's request.
+ */
+ buffer_signals[BUFFER_RESIZE_WINDOW] =
+ g_signal_new(I_("resize-window"),
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(VteBufferClass, resize_window),
+ NULL,
+ NULL,
+ _vte_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+ /**
+ * VteBuffer::move-window:
+ * @vtebuffer: the object which received the signal
+ * @x: the buffer's desired location, X coordinate
+ * @y: the buffer's desired location, Y coordinate
+ *
+ * Emitted at the child application's request.
+ */
+ buffer_signals[BUFFER_MOVE_WINDOW] =
+ g_signal_new(I_("move-window"),
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(VteBufferClass, move_window),
+ NULL,
+ NULL,
+ _vte_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
/* Properties */
/**
diff --git a/src/vte.h b/src/vte.h
index 52b00be..ab6d09f 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -79,9 +79,6 @@ struct _VteTerminalClass {
void (*contents_changed)(VteTerminal* terminal);
void (*cursor_moved)(VteTerminal* terminal);
- void (*resize_window)(VteTerminal* terminal, guint width, guint height);
- void (*move_window)(VteTerminal* terminal, guint x, guint y);
-
/* FIXMEchpe: should these return gboolean and have defaul thandlers
* settings the "scale" property?
*/
diff --git a/src/vteapp.c b/src/vteapp.c
index 8e5ce66..1b00747 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -298,19 +298,17 @@ refresh_window(VteBuffer *buffer, gpointer data)
}
static void
-resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
+resize_window(VteBuffer *buffer, guint width, guint height, VteTerminal *terminal)
{
- VteTerminal *terminal;
- VteBuffer *buffer;
+ GtkWidget *widget = &terminal->widget;
+ GtkWidget *window;
- if ((GTK_IS_WINDOW(data)) && (width >= 2) && (height >= 2)) {
+ window = gtk_widget_get_toplevel(GTK_WIDGET(terminal));
+ if (gtk_widget_is_toplevel(window) && (width >= 2) && (height >= 2)) {
gint owidth, oheight, char_width, char_height, column_count, row_count;
GtkBorder padding;
- terminal = VTE_TERMINAL(widget);
- buffer = vte_terminal_get_buffer(terminal);
-
- gtk_window_get_size(GTK_WINDOW(data), &owidth, &oheight);
+ gtk_window_get_size(GTK_WINDOW(window), &owidth, &oheight);
/* Take into account border overhead. */
char_width = vte_terminal_get_char_width (terminal);
@@ -323,13 +321,13 @@ resize_window(GtkWidget *widget, guint width, guint height, gpointer data)
owidth -= char_width * column_count + padding.left + padding.right;
oheight -= char_height * row_count + padding.top + padding.bottom;
- gtk_window_resize(GTK_WINDOW(data),
+ gtk_window_resize(GTK_WINDOW(window),
width + owidth, height + oheight);
}
}
static void
-move_window(GtkWidget *widget, guint x, guint y, gpointer data)
+move_window(VteBuffer *buffer, guint x, guint y, gpointer data)
{
GdkWindow *window;
@@ -995,9 +993,9 @@ main(int argc, char **argv)
G_CALLBACK(restore_window), window);
g_signal_connect(buffer, "refresh-window",
G_CALLBACK(refresh_window), window);
- g_signal_connect(widget, "resize-window",
- G_CALLBACK(resize_window), window);
- g_signal_connect(widget, "move-window",
+ g_signal_connect(buffer, "resize-window",
+ G_CALLBACK(resize_window), terminal);
+ g_signal_connect(buffer, "move-window",
G_CALLBACK(move_window), window);
/* Connect to font tweakage. */
diff --git a/src/vtebuffer.h b/src/vtebuffer.h
index 144740f..b3ebbb2 100644
--- a/src/vtebuffer.h
+++ b/src/vtebuffer.h
@@ -62,6 +62,12 @@ struct _VteBufferClass {
void (*refresh_window) (VteBuffer* buffer);
void (*restore_window) (VteBuffer* buffer);
void (*maximize_window) (VteBuffer* buffer);
+ void (*resize_window) (VteBuffer* buffer,
+ guint width,
+ guint height);
+ void (*move_window) (VteBuffer* buffer,
+ guint x,
+ guint y);
/*< private >*/
VteBufferClassPrivate *priv;
diff --git a/src/vteseq.c b/src/vteseq.c
index 7e6cd2b..893402b 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -179,26 +179,6 @@ vte_parse_color (const char *spec, GdkRGBA *rgba)
return TRUE;
}
-/* Emit a "move-window" signal. (Pixels.) */
-static void
-vte_terminal_emit_move_window(VteTerminal *terminal, guint x, guint y)
-{
- _vte_debug_print(VTE_DEBUG_SIGNALS,
- "Emitting `move-window'.\n");
- g_signal_emit_by_name(terminal, "move-window", x, y);
-}
-
-/* Emit a "resize-window" signal. (Pixels.) */
-static void
-vte_terminal_emit_resize_window(VteTerminal *terminal,
- guint width, guint height)
-{
- _vte_debug_print(VTE_DEBUG_SIGNALS,
- "Emitting `resize-window'.\n");
- g_signal_emit_by_name(terminal, "resize-window", width, height);
-}
-
-
/* Some common functions */
static void
@@ -764,7 +744,7 @@ vte_sequence_handler_decset_internal(VteTerminal *terminal,
break;
#if 0 /* 3: disallowed, window size is set by user. */
case 3:
- vte_terminal_emit_resize_window(terminal,
+ _vte_buffer_emit_resize_window(terminal->term_pvt->buffer,
(set ? 132 : 80) *
terminal->pvt->char_width +
terminal->pvt->padding.left +
@@ -3039,7 +3019,7 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
_vte_debug_print(VTE_DEBUG_PARSE,
"Moving window to "
"%ld,%ld.\n", arg1, arg2);
- vte_terminal_emit_move_window(terminal,
+ _vte_buffer_emit_move_window(terminal->term_pvt->buffer,
arg1, arg2);
i += 2;
}
@@ -3050,7 +3030,7 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
"Resizing window "
"(to %ldx%ld pixels).\n",
arg2, arg1);
- vte_terminal_emit_resize_window(terminal,
+ _vte_buffer_emit_resize_window(terminal->term_pvt->buffer,
arg2 +
terminal->pvt->padding.left +
terminal->pvt->padding.right,
@@ -3080,7 +3060,7 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
"Resizing window "
"(to %ld columns, %ld rows).\n",
arg2, arg1);
- vte_terminal_emit_resize_window(terminal,
+ _vte_buffer_emit_resize_window(terminal->term_pvt->buffer,
arg2 * terminal->pvt->char_width +
terminal->pvt->padding.left +
terminal->pvt->padding.right,
@@ -3205,7 +3185,7 @@ vte_sequence_handler_window_manipulation (VteTerminal *terminal, GValueArray *pa
param);
/* Resize to the specified number of
* rows. */
- vte_terminal_emit_resize_window(terminal,
+ _vte_buffer_emit_resize_window(terminal->term_pvt->buffer,
terminal->pvt->column_count * terminal->pvt->char_width +
terminal->pvt->padding.left +
terminal->pvt->padding.right,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]