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:
Tristan Van Berkom
2010-10-26 09:59:02 +09:00
parent 04c1337bda
commit 3fe0fb4ed9
12 changed files with 387 additions and 62 deletions

View File

@ -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;