[vte] Implement GtkScrollable interface on gtk3
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] Implement GtkScrollable interface on gtk3
- Date: Sun, 24 Oct 2010 18:12:26 +0000 (UTC)
commit 85b7996647b171f82910538e2a9c90a6d359d1a2
Author: Christian Persch <chpe gnome org>
Date: Sun Oct 24 20:12:03 2010 +0200
Implement GtkScrollable interface on gtk3
src/vte.c | 75 ++++++++++++++++++++++++++++++++++++++++++++------
src/vte.h | 5 +++
src/vtedeprecated.h | 4 +++
3 files changed, 75 insertions(+), 9 deletions(-)
---
diff --git a/src/vte.c b/src/vte.c
index b9e1b2a..1e0adca 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -147,6 +147,10 @@ static guint signals[LAST_SIGNAL];
enum {
PROP_0,
+#if GTK_CHECK_VERSION (2, 91, 2)
+ PROP_HADJUSTMENT,
+ PROP_VADJUSTMENT,
+#endif
PROP_ALLOW_BOLD,
PROP_AUDIBLE_BELL,
PROP_BACKGROUND_IMAGE_FILE,
@@ -276,6 +280,18 @@ _vte_incoming_chunks_reverse(struct _vte_incoming_chunk *chunk)
}
+#if GTK_CHECK_VERSION (2, 91, 2)
+#ifdef VTE_DEBUG
+G_DEFINE_TYPE_WITH_CODE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET,
+ G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, NULL)
+ if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
+ g_printerr("vte_terminal_get_type()\n");
+ })
+#else
+G_DEFINE_TYPE_WITH_CODE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET,
+ G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, NULL))
+#endif
+#else
#ifdef VTE_DEBUG
G_DEFINE_TYPE_WITH_CODE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET,
if (_vte_debug_on(VTE_DEBUG_LIFECYCLE)) {
@@ -284,7 +300,7 @@ G_DEFINE_TYPE_WITH_CODE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET,
#else
G_DEFINE_TYPE(VteTerminal, vte_terminal, GTK_TYPE_WIDGET)
#endif
-
+#endif /* GTK 3.0 */
/* Indexes in the "palette" color array for the dim colors.
* Only the first %VTE_LEGACY_COLOR_SET_SIZE colors have dim versions. */
@@ -7826,14 +7842,17 @@ vte_terminal_handle_scroll(VteTerminal *terminal)
}
}
-/* Set the adjustment objects used by the terminal widget. */
static void
-vte_terminal_set_scroll_adjustments(GtkWidget *widget,
- GtkAdjustment *hadjustment G_GNUC_UNUSED,
- GtkAdjustment *adjustment)
+vte_terminal_set_hadjustment(VteTerminal *terminal,
+ GtkAdjustment *adjustment)
{
- VteTerminal *terminal = VTE_TERMINAL (widget);
+ /* do nothing */
+}
+static void
+vte_terminal_set_vadjustment(VteTerminal *terminal,
+ GtkAdjustment *adjustment)
+{
if (adjustment != NULL && adjustment == terminal->adjustment)
return;
if (adjustment == NULL && terminal->adjustment != NULL)
@@ -7865,6 +7884,17 @@ vte_terminal_set_scroll_adjustments(GtkWidget *widget,
terminal);
}
+/* Set the adjustment objects used by the terminal widget. */
+#if !GTK_CHECK_VERSION (2, 91, 2)
+static void
+vte_terminal_set_scroll_adjustments(GtkWidget *widget,
+ GtkAdjustment *hadjustment G_GNUC_UNUSED,
+ GtkAdjustment *vadjustment)
+{
+ vte_terminal_set_vadjustment(VTE_TERMINAL(widget), vadjustment);
+}
+#endif /* GTK 2.x */
+
/**
* vte_terminal_set_emulation:
* @terminal: a #VteTerminal
@@ -8076,7 +8106,7 @@ vte_terminal_init(VteTerminal *terminal)
gtk_widget_set_redraw_on_allocate (&terminal->widget, FALSE);
/* Set an adjustment for the application to use to control scrolling. */
- vte_terminal_set_scroll_adjustments(GTK_WIDGET(terminal), NULL, NULL);
+ vte_terminal_set_vadjustment(terminal, NULL);
/* Set up dummy metrics, value != 0 to avoid division by 0 */
terminal->char_width = 1;
@@ -11218,6 +11248,14 @@ vte_terminal_get_property (GObject *object,
switch (prop_id)
{
+#if GTK_CHECK_VERSION (2, 91, 2 )
+ case PROP_HADJUSTMENT:
+ g_value_set_object (value, NULL);
+ break;
+ case PROP_VADJUSTMENT:
+ g_value_set_object (value, terminal->adjustment);
+ break;
+#endif
case PROP_ALLOW_BOLD:
g_value_set_boolean (value, vte_terminal_get_allow_bold (terminal));
break;
@@ -11314,6 +11352,14 @@ vte_terminal_set_property (GObject *object,
switch (prop_id)
{
+#if GTK_CHECK_VERSION (2, 91, 2 )
+ case PROP_HADJUSTMENT:
+ vte_terminal_set_hadjustment (terminal, g_value_get_object (value));
+ break;
+ case PROP_VADJUSTMENT:
+ vte_terminal_set_vadjustment (terminal, g_value_get_object (value));
+ break;
+#endif
case PROP_ALLOW_BOLD:
vte_terminal_set_allow_bold (terminal, g_value_get_boolean (value));
break;
@@ -11510,10 +11556,17 @@ vte_terminal_class_init(VteTerminalClass *klass)
klass->copy_clipboard = vte_terminal_real_copy_clipboard;
klass->paste_clipboard = vte_terminal_real_paste_clipboard;
- klass->set_scroll_adjustments = vte_terminal_set_scroll_adjustments;
-
klass->beep = NULL;
+#if GTK_CHECK_VERSION (2, 91, 2)
+ /* GtkScrollable interface properties */
+ g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
+ g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
+
+#else
+
+ klass->set_scroll_adjustments = vte_terminal_set_scroll_adjustments;
+
/**
* VteTerminal::set-scroll-adjustments:
* @vteterminal: the object which received the signal
@@ -11536,6 +11589,8 @@ vte_terminal_class_init(VteTerminalClass *klass)
G_TYPE_NONE, 2,
GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
+#endif
+
/* Register some signals of our own. */
/**
@@ -13827,6 +13882,8 @@ vte_terminal_get_padding(VteTerminal *terminal, int *xpad, int *ypad)
* An accessor function provided for the benefit of language bindings.
*
* Returns: (transfer none): the contents of @terminal's adjustment field
+ *
+ * Deprecated: 0.28: Use gtk_scrollable_get_vadjustment() instead
*/
GtkAdjustment *
vte_terminal_get_adjustment(VteTerminal *terminal)
diff --git a/src/vte.h b/src/vte.h
index b41a585..c523307 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -125,9 +125,11 @@ struct _VteTerminalClass {
void (*copy_clipboard)(VteTerminal* terminal);
void (*paste_clipboard)(VteTerminal* terminal);
+#if !GTK_CHECK_VERSION (2, 91, 2)
void (* set_scroll_adjustments) (GtkWidget *widget,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
+#endif
void (*beep)(VteTerminal* terminal);
@@ -451,7 +453,10 @@ void vte_terminal_set_pty_object(VteTerminal *terminal, VtePty *pty);
VtePty *vte_terminal_get_pty_object(VteTerminal *terminal);
/* Accessors for bindings. */
+#if !GTK_CHECK_VERSION (2, 91, 2)
GtkAdjustment *vte_terminal_get_adjustment(VteTerminal *terminal);
+#endif
+
glong vte_terminal_get_char_width(VteTerminal *terminal);
glong vte_terminal_get_char_height(VteTerminal *terminal);
glong vte_terminal_get_row_count(VteTerminal *terminal);
diff --git a/src/vtedeprecated.h b/src/vtedeprecated.h
index 5a01d9e..e531b0d 100644
--- a/src/vtedeprecated.h
+++ b/src/vtedeprecated.h
@@ -94,6 +94,10 @@ void vte_terminal_get_padding(VteTerminal *terminal, int *xpad, int *ypad) G_GNU
void vte_terminal_set_pty(VteTerminal *terminal, int pty_master);
int vte_terminal_get_pty(VteTerminal *terminal);
+#if GTK_CHECK_VERSION (2, 91, 2)
+GtkAdjustment *vte_terminal_get_adjustment(VteTerminal *terminal);
+#endif
+
G_END_DECLS
#endif /* !vte_deprecated_h_included */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]