From d243a9ba9320971d5ce8524ff8355b24606d9420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Nov 2023 13:50:42 +0100 Subject: [PATCH] st/scroll-view: Expose adjustments as properties The adjustments are currently only accessible indirectly via the scroll bars. It is a bit odd to expose internal children, and as nearly all users only access them for the adjustments, it makes sense to expose those instead. Part-of: --- src/st/st-scroll-view.c | 72 +++++++++++++++++++++++++++++++++++++++++ src/st/st-scroll-view.h | 3 ++ 2 files changed, 75 insertions(+) diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c index 3313307de..b12c8fd1d 100644 --- a/src/st/st-scroll-view.c +++ b/src/st/st-scroll-view.c @@ -99,6 +99,8 @@ enum { PROP_CHILD, PROP_HSCROLL, PROP_VSCROLL, + PROP_HADJUSTMENT, + PROP_VADJUSTMENT, PROP_HSCROLLBAR_POLICY, PROP_VSCROLLBAR_POLICY, PROP_HSCROLLBAR_VISIBLE, @@ -131,6 +133,12 @@ st_scroll_view_get_property (GObject *object, case PROP_VSCROLL: g_value_set_object (value, priv->vscroll); break; + case PROP_HADJUSTMENT: + g_value_set_object (value, priv->hadjustment); + break; + case PROP_VADJUSTMENT: + g_value_set_object (value, priv->vadjustment); + break; case PROP_HSCROLLBAR_POLICY: g_value_set_enum (value, priv->hscrollbar_policy); break; @@ -888,6 +896,30 @@ st_scroll_view_class_init (StScrollViewClass *klass) ST_TYPE_SCROLL_BAR, ST_PARAM_READABLE); + /** + * StScrollView:hadjustment: + * + * The horizontal #StAdjustment for the #StScrollView. + */ + props[PROP_HADJUSTMENT] = + g_param_spec_object ("hadjustment", + "StAdjustment", + "Horizontal scroll adjustment", + ST_TYPE_ADJUSTMENT, + ST_PARAM_READABLE); + + /** + * StScrollView:vadjustment: + * + * The vertical #StAdjustment for the #StScrollView. + */ + props[PROP_VADJUSTMENT] = + g_param_spec_object ("vadjustment", + "StAdjustment", + "Vertical scroll adjustment", + ST_TYPE_ADJUSTMENT, + ST_PARAM_READABLE); + /** * StScrollView:vscrollbar-policy: * @@ -1169,6 +1201,46 @@ st_scroll_view_get_vscroll_bar (StScrollView *scroll) return priv->vscroll; } +/** + * st_scroll_view_get_hadjustment: + * @scroll: a #StScrollView + * + * Gets the horizontal #StAdjustment of the #StScrollView. + * + * Returns: (transfer none): the horizontal adjustment + */ +StAdjustment * +st_scroll_view_get_hadjustment (StScrollView *scroll) +{ + StScrollViewPrivate *priv; + + g_return_val_if_fail (ST_IS_SCROLL_VIEW (scroll), NULL); + + priv = st_scroll_view_get_instance_private (scroll); + + return priv->hadjustment; +} + +/** + * st_scroll_view_get_vadjustment: + * @scroll: a #StScrollView + * + * Gets the vertical #StAdjustment of the #StScrollView. + * + * Returns: (transfer none): the vertical adjustment + */ +StAdjustment * +st_scroll_view_get_vadjustment (StScrollView *scroll) +{ + StScrollViewPrivate *priv; + + g_return_val_if_fail (ST_IS_SCROLL_VIEW (scroll), NULL); + + priv = st_scroll_view_get_instance_private (scroll); + + return priv->vadjustment; +} + /** * st_scroll_view_get_column_size: * @scroll: a #StScrollView diff --git a/src/st/st-scroll-view.h b/src/st/st-scroll-view.h index 4a59d28ea..9d300a402 100644 --- a/src/st/st-scroll-view.h +++ b/src/st/st-scroll-view.h @@ -56,6 +56,9 @@ void st_scroll_view_set_child (StScrollView *scroll, ClutterActor *st_scroll_view_get_hscroll_bar (StScrollView *scroll); ClutterActor *st_scroll_view_get_vscroll_bar (StScrollView *scroll); +StAdjustment *st_scroll_view_get_hadjustment (StScrollView *scroll); +StAdjustment *st_scroll_view_get_vadjustment (StScrollView *scroll); + gfloat st_scroll_view_get_column_size (StScrollView *scroll); void st_scroll_view_set_column_size (StScrollView *scroll, gfloat column_size);