[gtk+] GtkStack: add transition-running property



commit 9223e3c25a7a4c3aabc904b0e81573bd61d62d1a
Author: Xavier Claessens <xavier claessens collabora co uk>
Date:   Mon Nov 11 16:38:35 2013 -0500

    GtkStack: add transition-running property
    
    This is useful to know when the transition is done we can
    remove the child from the stack.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711494

 docs/reference/gtk/gtk3-sections.txt |    1 +
 gtk/gtkstack.c                       |   33 +++++++++++++++++++++++++++++++++
 gtk/gtkstack.h                       |    2 ++
 3 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index c2287aa..cc56f00 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -7721,6 +7721,7 @@ gtk_stack_get_transition_duration
 GtkStackTransitionType
 gtk_stack_set_transition_type
 gtk_stack_get_transition_type
+gtk_stack_get_transition_running
 </SECTION>
 
 <SECTION>
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index 830b3c6..1f0da9e 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -85,6 +85,7 @@ enum  {
   PROP_VISIBLE_CHILD_NAME,
   PROP_TRANSITION_DURATION,
   PROP_TRANSITION_TYPE,
+  PROP_TRANSITION_RUNNING,
   LAST_PROP
 };
 
@@ -237,6 +238,9 @@ gtk_stack_get_property (GObject   *object,
     case PROP_TRANSITION_TYPE:
       g_value_set_enum (value, gtk_stack_get_transition_type (stack));
       break;
+    case PROP_TRANSITION_RUNNING:
+      g_value_set_boolean (value, gtk_stack_get_transition_running (stack));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -394,6 +398,11 @@ gtk_stack_class_init (GtkStackClass *klass)
                                                          GTK_TYPE_STACK_TRANSITION_TYPE,
                                                          GTK_STACK_TRANSITION_TYPE_NONE,
                                                          GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+  stack_props[PROP_TRANSITION_RUNNING] = g_param_spec_boolean ("transition-running",
+                                                               P_("Transition running"),
+                                                               P_("Whether or not the transition is 
currently running"),
+                                                               FALSE,
+                                                               GTK_PARAM_READABLE);
 
   g_object_class_install_properties (object_class, LAST_PROP, stack_props);
 
@@ -780,6 +789,7 @@ gtk_stack_transition_cb (GtkStack      *stack,
     {
       gtk_widget_set_opacity (GTK_WIDGET (stack), 1.0);
       priv->tick_id = 0;
+      g_object_notify_by_pspec (G_OBJECT (stack), stack_props[PROP_TRANSITION_RUNNING]);
 
       return FALSE;
     }
@@ -796,6 +806,7 @@ gtk_stack_schedule_ticks (GtkStack *stack)
     {
       priv->tick_id =
         gtk_widget_add_tick_callback (GTK_WIDGET (stack), (GtkTickCallback)gtk_stack_transition_cb, stack, 
NULL);
+      g_object_notify_by_pspec (G_OBJECT (stack), stack_props[PROP_TRANSITION_RUNNING]);
     }
 }
 
@@ -808,6 +819,7 @@ gtk_stack_unschedule_ticks (GtkStack *stack)
     {
       gtk_widget_remove_tick_callback (GTK_WIDGET (stack), priv->tick_id);
       priv->tick_id = 0;
+      g_object_notify_by_pspec (G_OBJECT (stack), stack_props[PROP_TRANSITION_RUNNING]);
     }
 }
 
@@ -1269,6 +1281,27 @@ gtk_stack_set_transition_type (GtkStack              *stack,
 }
 
 /**
+ * gtk_stack_get_transition_running:
+ * @stack: a #GtkStack
+ *
+ * Returns whether the @stack is currently in a transition from one page to
+ * another.
+ *
+ * Return value: %TRUE if the transition is currently running, %FALSE otherwise.
+ *
+ * Since: 3.12
+ */
+gboolean
+gtk_stack_get_transition_running (GtkStack *stack)
+{
+  GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
+
+  g_return_val_if_fail (GTK_IS_STACK (stack), FALSE);
+
+  return (priv->tick_id != 0);
+}
+
+/**
  * gtk_stack_get_visible_child:
  * @stack: a #GtkStack
  *
diff --git a/gtk/gtkstack.h b/gtk/gtkstack.h
index 82e527c..d0bb471 100644
--- a/gtk/gtkstack.h
+++ b/gtk/gtkstack.h
@@ -108,6 +108,8 @@ void                   gtk_stack_set_transition_type     (GtkStack
                                                           GtkStackTransitionType  transition);
 GDK_AVAILABLE_IN_3_10
 GtkStackTransitionType gtk_stack_get_transition_type     (GtkStack               *stack);
+GDK_AVAILABLE_IN_3_12
+gboolean               gtk_stack_get_transition_running  (GtkStack               *stack);
 
 G_END_DECLS
 


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