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.
This commit is contained in:
@ -53,6 +53,11 @@ struct _GtkLayoutPrivate
|
||||
GtkAdjustment *hadjustment;
|
||||
GtkAdjustment *vadjustment;
|
||||
|
||||
/* GtkScrollablePolicy needs to be checked when
|
||||
* driving the scrollable adjustment values */
|
||||
guint hscroll_policy : 1;
|
||||
guint vscroll_policy : 1;
|
||||
|
||||
/* Properties */
|
||||
|
||||
GdkVisibilityState visibility;
|
||||
@ -75,7 +80,9 @@ struct _GtkLayoutChild {
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_HADJUSTMENT,
|
||||
PROP_VADJUSTMENT,
|
||||
PROP_VADJUSTMENT,
|
||||
PROP_HSCROLL_POLICY,
|
||||
PROP_VSCROLL_POLICY,
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT
|
||||
};
|
||||
@ -618,8 +625,10 @@ gtk_layout_class_init (GtkLayoutClass *class)
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/* Scrollable 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");
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_WIDTH,
|
||||
@ -671,6 +680,12 @@ gtk_layout_get_property (GObject *object,
|
||||
case PROP_VADJUSTMENT:
|
||||
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;
|
||||
case PROP_WIDTH:
|
||||
g_value_set_uint (value, priv->width);
|
||||
break;
|
||||
@ -702,6 +717,14 @@ gtk_layout_set_property (GObject *object,
|
||||
gtk_layout_set_vadjustment (layout,
|
||||
(GtkAdjustment*) g_value_get_object (value));
|
||||
break;
|
||||
case PROP_HSCROLL_POLICY:
|
||||
priv->hscroll_policy = g_value_get_enum (value);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (layout));
|
||||
break;
|
||||
case PROP_VSCROLL_POLICY:
|
||||
priv->vscroll_policy = g_value_get_enum (value);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (layout));
|
||||
break;
|
||||
case PROP_WIDTH:
|
||||
gtk_layout_set_size (layout, g_value_get_uint (value),
|
||||
priv->height);
|
||||
|
||||
Reference in New Issue
Block a user