From 3765acc0a59f9120843201bbe867f52af8fe52fb Mon Sep 17 00:00:00 2001 From: Adel Gadllah Date: Wed, 29 Jun 2011 18:07:06 +0200 Subject: [PATCH] StScrollView: Expose scrollbars visibility as property Add two boolean readonly properties that tell whether the scrollbars are visible or not. https://bugzilla.gnome.org/show_bug.cgi?id=651866 --- src/st/st-scroll-view.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c index a62869078..63e66c1a6 100644 --- a/src/st/st-scroll-view.c +++ b/src/st/st-scroll-view.c @@ -113,6 +113,8 @@ enum { PROP_VSCROLL, PROP_HSCROLLBAR_POLICY, PROP_VSCROLLBAR_POLICY, + PROP_HSCROLLBAR_VISIBLE, + PROP_VSCROLLBAR_VISIBLE, PROP_MOUSE_SCROLL, }; @@ -138,6 +140,12 @@ st_scroll_view_get_property (GObject *object, case PROP_VSCROLLBAR_POLICY: g_value_set_enum (value, priv->vscrollbar_policy); break; + case PROP_HSCROLLBAR_VISIBLE: + g_value_set_boolean (value, priv->hscrollbar_visible); + break; + case PROP_VSCROLLBAR_VISIBLE: + g_value_set_boolean (value, priv->vscrollbar_visible); + break; case PROP_MOUSE_SCROLL: g_value_set_boolean (value, priv->mouse_scroll); break; @@ -646,8 +654,22 @@ st_scroll_view_allocate (ClutterActor *actor, if (priv->child) clutter_actor_allocate (priv->child, &child_box, flags); - priv->hscrollbar_visible = hscrollbar_visible; - priv->vscrollbar_visible = vscrollbar_visible; + if (priv->hscrollbar_visible != hscrollbar_visible) + { + g_object_freeze_notify (G_OBJECT (actor)); + priv->hscrollbar_visible = hscrollbar_visible; + g_object_notify (G_OBJECT (actor), "hscrollbar-visible"); + g_object_thaw_notify (G_OBJECT (actor)); + } + + if (priv->vscrollbar_visible != vscrollbar_visible) + { + g_object_freeze_notify (G_OBJECT (actor)); + priv->vscrollbar_visible = vscrollbar_visible; + g_object_notify (G_OBJECT (actor), "vscrollbar-visible"); + g_object_thaw_notify (G_OBJECT (actor)); + } + } static void @@ -786,6 +808,20 @@ st_scroll_view_class_init (StScrollViewClass *klass) G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_HSCROLLBAR_POLICY, pspec); + pspec = g_param_spec_boolean ("hscrollbar-visible", + "Horizontal Scrollbar Visibility", + "Whether the horizontal scrollbar is visible", + TRUE, + G_PARAM_READABLE); + g_object_class_install_property (object_class, PROP_HSCROLLBAR_VISIBLE, pspec); + + pspec = g_param_spec_boolean ("vscrollbar-visible", + "Vertical Scrollbar Visibility", + "Whether the vertical scrollbar is visible", + TRUE, + G_PARAM_READABLE); + g_object_class_install_property (object_class, PROP_VSCROLLBAR_VISIBLE, pspec); + pspec = g_param_spec_boolean ("enable-mouse-scrolling", "Enable Mouse Scrolling", "Enable automatic mouse wheel scrolling",