summaryrefslogtreecommitdiff
path: root/gtk/gtktextview.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2010-10-26 09:59:02 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-10-26 10:15:56 +0900
commit3fe0fb4ed95a3d5c51a049a24147e628e6965d62 (patch)
tree0f1d9594d0dc787643509012cac76fe3871a6b5e /gtk/gtktextview.c
parent04c1337bdae99b2c45e44e20c9432a72e5e6602c (diff)
downloadgtk+-3fe0fb4ed95a3d5c51a049a24147e628e6965d62.tar.gz
Added GtkScrollablePolicy property to scrollable interface
This patch adds the GtkScrollablePolicy type property to GtkScrollable and implements it in all subclasses. GtkScrolledWindow observes this property to make a good guess about when to show/hide scrollbars for height-for-width content. Most scrollable children do not do height-for-width *yet* but most certainly will (toolpalette, treeview, iconview, textview widgets all TODO), for scrollable widgets that do have a minimum and natural size, it's important for them to observe the state of this property in order to properly drive the scroll adjustments according to the desired GtkScrollablePolicy. This patch makes GtkViewport do this. Patch also adds tests/testscrolledwindow.c to display the effects of this property.
Diffstat (limited to 'gtk/gtktextview.c')
-rw-r--r--gtk/gtktextview.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index f0eca6575f..ae12071c89 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -210,6 +210,11 @@ struct _GtkTextViewPrivate
guint mouse_cursor_obscured : 1;
guint scroll_after_paste : 1;
+
+ /* GtkScrollablePolicy needs to be checked when
+ * driving the scrollable adjustment values */
+ guint hscroll_policy : 1;
+ guint vscroll_policy : 1;
};
struct _GtkTextPendingScroll
@@ -260,7 +265,9 @@ enum
PROP_ACCEPTS_TAB,
PROP_IM_MODULE,
PROP_HADJUSTMENT,
- PROP_VADJUSTMENT
+ PROP_VADJUSTMENT,
+ PROP_HSCROLL_POLICY,
+ PROP_VSCROLL_POLICY
};
static void gtk_text_view_finalize (GObject *object);
@@ -771,8 +778,10 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
GTK_PARAM_READWRITE));
/* GtkScrollable interface */
- g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
- g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
+ g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
+ g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
+ g_object_class_override_property (gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy");
+ g_object_class_override_property (gobject_class, PROP_VSCROLL_POLICY, "vscroll-policy");
/*
* Style properties
@@ -3092,6 +3101,16 @@ gtk_text_view_set_property (GObject *object,
gtk_text_view_set_vadjustment (text_view, g_value_get_object (value));
break;
+ case PROP_HSCROLL_POLICY:
+ priv->hscroll_policy = g_value_get_enum (value);
+ gtk_widget_queue_resize (GTK_WIDGET (text_view));
+ break;
+
+ case PROP_VSCROLL_POLICY:
+ priv->vscroll_policy = g_value_get_enum (value);
+ gtk_widget_queue_resize (GTK_WIDGET (text_view));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -3180,6 +3199,14 @@ gtk_text_view_get_property (GObject *object,
g_value_set_object (value, priv->vadjustment);
break;
+ case PROP_HSCROLL_POLICY:
+ g_value_set_enum (value, priv->hscroll_policy);
+ break;
+
+ case PROP_VSCROLL_POLICY:
+ g_value_set_enum (value, priv->vscroll_policy);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;