[libgd] revealer: add a child-revealed property



commit 4cd7128e3b6c3dbafc4b1839585e69885b9f4741
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Feb 11 14:02:04 2013 -0500

    revealer: add a child-revealed property
    
    This is for clients who are interested in a passive notification when
    the revealed/unrevealed status of the child widget has changed.

 libgd/gd-revealer.c |   26 ++++++++++++++++++++++++++
 libgd/gd-revealer.h |    2 ++
 2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/libgd/gd-revealer.c b/libgd/gd-revealer.c
index b028ec5..f50beb2 100644
--- a/libgd/gd-revealer.c
+++ b/libgd/gd-revealer.c
@@ -29,6 +29,7 @@ enum  {
   PROP_ORIENTATION,
   PROP_DURATION,
   PROP_REVEAL_CHILD,
+  PROP_CHILD_REVEALED
 };
 
 #define FRAME_TIME_MSEC 17 /* 17 msec => 60 fps */
@@ -128,6 +129,9 @@ gd_revealer_get_property (GObject *object,
   case PROP_REVEAL_CHILD:
     g_value_set_boolean (value, gd_revealer_get_reveal_child (revealer));
     break;
+  case PROP_CHILD_REVEALED:
+    g_value_set_boolean (value, gd_revealer_get_child_revealed (revealer));
+    break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     break;
@@ -204,6 +208,13 @@ gd_revealer_class_init (GdRevealerClass * klass)
                                                          FALSE,
                                                          GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
+  g_object_class_install_property (object_class,
+                                   PROP_CHILD_REVEALED,
+                                   g_param_spec_boolean ("child-revealed", "Child Revealed",
+                                                         "Whether the child is revealed and the animation target reached",
+                                                         FALSE,
+                                                         G_PARAM_READABLE));
+
   g_type_class_add_private (klass, sizeof (GdRevealerPrivate));
 }
 
@@ -430,6 +441,9 @@ gd_revealer_set_position (GdRevealer *revealer,
     gtk_widget_set_child_visible (child, new_visible);
 
   gtk_widget_queue_resize (GTK_WIDGET (revealer));
+
+  if (priv->current_pos == priv->target_pos)
+    g_object_notify (G_OBJECT (revealer), "child-revealed");
 }
 
 static gdouble
@@ -580,6 +594,18 @@ gd_revealer_get_reveal_child (GdRevealer *revealer)
   return revealer->priv->target_pos != 0.0;
 }
 
+gboolean
+gd_revealer_get_child_revealed (GdRevealer *revealer)
+{
+  gboolean animation_finished = (revealer->priv->target_pos == revealer->priv->current_pos);
+  gboolean reveal_child = gd_revealer_get_reveal_child (revealer);
+
+  if (animation_finished)
+    return reveal_child;
+  else
+    return !reveal_child;
+}
+
 /* These all report only the natural size, ignoring the minimal size,
  * because its not really possible to allocate the right size during
  * animation if the child size can change (without the child
diff --git a/libgd/gd-revealer.h b/libgd/gd-revealer.h
index 246de54..5fbfc22 100644
--- a/libgd/gd-revealer.h
+++ b/libgd/gd-revealer.h
@@ -60,6 +60,8 @@ gint           gd_revealer_get_duration       (GdRevealer     *revealer);
 void           gd_revealer_set_duration       (GdRevealer     *revealer,
 					       gint            duration_msec);
 
+gboolean       gd_revealer_get_child_revealed (GdRevealer     *revealer);
+
 G_END_DECLS
 
 #endif


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