summaryrefslogtreecommitdiff
path: root/gtk/gtkscrollable.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/gtkscrollable.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/gtkscrollable.c')
-rw-r--r--gtk/gtkscrollable.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/gtk/gtkscrollable.c b/gtk/gtkscrollable.c
index 3e19c79ca6..ca0d8a4ea4 100644
--- a/gtk/gtkscrollable.c
+++ b/gtk/gtkscrollable.c
@@ -63,6 +63,7 @@
#include "config.h"
#include "gtkscrollable.h"
+#include "gtktypeutils.h"
#include "gtkprivate.h"
#include "gtkintl.h"
@@ -106,6 +107,38 @@ gtk_scrollable_default_init (GtkScrollableInterface *iface)
GTK_TYPE_ADJUSTMENT,
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_interface_install_property (iface, pspec);
+
+ /**
+ * GtkScrollable:hscroll-policy:
+ *
+ * Determines whether horizontal scrolling should commence once the scrollable
+ * widget is allocated less than it's minimum width or less than it's natural width.
+ *
+ * Since: 3.0
+ */
+ pspec = g_param_spec_enum ("hscroll-policy",
+ P_("Horizontal Scrollable Policy"),
+ P_("How the size of the content should be determined"),
+ GTK_TYPE_SCROLLABLE_POLICY,
+ GTK_SCROLL_MINIMUM,
+ GTK_PARAM_READWRITE);
+ g_object_interface_install_property (iface, pspec);
+
+ /**
+ * GtkScrollable:vscroll-policy:
+ *
+ * Determines whether vertical scrolling should commence once the scrollable
+ * widget is allocated less than it's minimum height or less than it's natural height.
+ *
+ * Since: 3.0
+ */
+ pspec = g_param_spec_enum ("vscroll-policy",
+ P_("Vertical Scrollable Policy"),
+ P_("How the size of the content should be determined"),
+ GTK_TYPE_SCROLLABLE_POLICY,
+ GTK_SCROLL_MINIMUM,
+ GTK_PARAM_READWRITE);
+ g_object_interface_install_property (iface, pspec);
}
/**
@@ -203,3 +236,88 @@ gtk_scrollable_set_vadjustment (GtkScrollable *scrollable,
g_object_set (scrollable, "vadjustment", vadjustment, NULL);
}
+
+
+/**
+ * gtk_scrollable_get_hscroll_policy:
+ * @scrollable: a #GtkScrollable
+ *
+ * Gets the horizontal #GtkScrollablePolicy.
+ *
+ * Return value: The horizontal #GtkScrollablePolicy.
+ *
+ * Since: 3.0
+ **/
+GtkScrollablePolicy
+gtk_scrollable_get_hscroll_policy (GtkScrollable *scrollable)
+{
+ GtkScrollablePolicy policy;
+
+ g_return_val_if_fail (GTK_IS_SCROLLABLE (scrollable), GTK_SCROLL_MINIMUM);
+
+ g_object_get (scrollable, "hscroll-policy", &policy, NULL);
+
+ return policy;
+}
+
+/**
+ * gtk_scrollable_set_hscroll_policy:
+ * @scrollable: a #GtkScrollable
+ * @policy: the horizontal #GtkScrollablePolicy
+ *
+ * Sets the #GtkScrollablePolicy to determine whether
+ * horizontal scrolling should commence below minimum or
+ * below natural width.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_scrollable_set_hscroll_policy (GtkScrollable *scrollable,
+ GtkScrollablePolicy policy)
+{
+ g_return_if_fail (GTK_IS_SCROLLABLE (scrollable));
+
+ g_object_set (scrollable, "hscroll-policy", policy, NULL);
+}
+
+/**
+ * gtk_scrollable_get_vscroll_policy:
+ * @scrollable: a #GtkScrollable
+ *
+ * Gets the vertical #GtkScrollablePolicy.
+ *
+ * Return value: The vertical #GtkScrollablePolicy.
+ *
+ * Since: 3.0
+ **/
+GtkScrollablePolicy
+gtk_scrollable_get_vscroll_policy (GtkScrollable *scrollable)
+{
+ GtkScrollablePolicy policy;
+
+ g_return_val_if_fail (GTK_IS_SCROLLABLE (scrollable), GTK_SCROLL_MINIMUM);
+
+ g_object_get (scrollable, "vscroll-policy", &policy, NULL);
+
+ return policy;
+}
+
+/**
+ * gtk_scrollable_set_vscroll_policy:
+ * @scrollable: a #GtkScrollable
+ * @policy: the vertical #GtkScrollablePolicy
+ *
+ * Sets the #GtkScrollablePolicy to determine whether
+ * vertical scrolling should commence below minimum or
+ * below natural height.
+ *
+ * Since: 3.0
+ **/
+void
+gtk_scrollable_set_vscroll_policy (GtkScrollable *scrollable,
+ GtkScrollablePolicy policy)
+{
+ g_return_if_fail (GTK_IS_SCROLLABLE (scrollable));
+
+ g_object_set (scrollable, "vscroll-policy", policy, NULL);
+}