[libhandy/wip/exalm/leaflet-transltions: 25/31] leaflet: Add 'visible' child property




commit 1735b6245069912c3a0ad1fcc89c248e8090f7f2
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri May 29 01:02:04 2020 +0500

    leaflet: Add 'visible' child property
    
    Expose HdyStackableBox child visibility.
    
    Signed-off-by: Alexander Mikhaylenko <alexm gnome org>

 src/hdy-leaflet.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
---
diff --git a/src/hdy-leaflet.c b/src/hdy-leaflet.c
index 8c1ba2ad..828d1f9f 100644
--- a/src/hdy-leaflet.c
+++ b/src/hdy-leaflet.c
@@ -85,6 +85,7 @@ enum {
   CHILD_PROP_0,
   CHILD_PROP_NAME,
   CHILD_PROP_NAVIGATABLE,
+  CHILD_PROP_VISIBLE,
   LAST_CHILD_PROP,
 };
 
@@ -814,6 +815,10 @@ hdy_leaflet_get_child_property (GtkContainer *container,
     g_value_set_boolean (value, hdy_stackable_box_get_child_navigatable (HDY_GET_HELPER (container), 
widget));
     break;
 
+  case CHILD_PROP_VISIBLE:
+    g_value_set_boolean (value, hdy_stackable_box_get_child_visible (HDY_GET_HELPER (container), widget));
+    break;
+
   default:
     GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
     break;
@@ -1131,6 +1136,18 @@ hdy_leaflet_class_init (HdyLeafletClass *klass)
                           TRUE,
                           G_PARAM_READWRITE);
 
+  /**
+   * HdyLeaflet:visible:
+   *
+   * Since: 1.0
+   */
+  child_props[CHILD_PROP_VISIBLE] =
+    g_param_spec_boolean ("visible",
+                          _("Visible"),
+                          _("Whether the child is currently visible"),
+                          FALSE,
+                          G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY);
+
   gtk_container_class_install_child_properties (container_class, LAST_CHILD_PROP, child_props);
 
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
@@ -1170,6 +1187,15 @@ notify_orientation_cb (HdyLeaflet *self)
   g_object_notify (G_OBJECT (self), "orientation");
 }
 
+static void
+child_notify_visible_cb (HdyLeaflet *self,
+                         GtkWidget  *child)
+{
+  gtk_container_child_notify_by_pspec (GTK_CONTAINER (self),
+                                       child,
+                                       child_props[CHILD_PROP_VISIBLE]);
+}
+
 static void
 hdy_leaflet_init (HdyLeaflet *self)
 {
@@ -1194,6 +1220,7 @@ hdy_leaflet_init (HdyLeaflet *self)
   g_signal_connect_object (priv->box, "notify::can-swipe-back", G_CALLBACK (notify_can_swipe_back_cb), self, 
G_CONNECT_SWAPPED);
   g_signal_connect_object (priv->box, "notify::can-swipe-forward", G_CALLBACK (notify_can_swipe_forward_cb), 
self, G_CONNECT_SWAPPED);
   g_signal_connect_object (priv->box, "notify::orientation", G_CALLBACK (notify_orientation_cb), self, 
G_CONNECT_SWAPPED);
+  g_signal_connect_object (priv->box, "child-notify-visible", G_CALLBACK (child_notify_visible_cb), self, 
G_CONNECT_SWAPPED);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]