Blob Blame History Raw
From 2de72b3bd653b03a09f4b3c2e1f863278e70fafc Mon Sep 17 00:00:00 2001
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
Date: Mon, 10 Jun 2013 22:57:41 +0300
Subject: [PATCH] util: Remove existing transition before adding new one

Before starting an opacity animation, ensure that there isn't one
already scheduled.

This patch fixes at least two cases of actors not showing-up:

1. When right-clicking on an item in collection view: overlay bar
doesn't become visible.
2. When launching Boxes with installer media argument: you end up in the
wizard but with main wizard area invisible.

https://bugzilla.gnome.org/show_bug.cgi?id=701635
---
 src/util-app.vala | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/util-app.vala b/src/util-app.vala
index 0370b0c..ae184be 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -109,8 +109,6 @@ public void allocate_actor_no_animation (Clutter.Actor actor,
         actor.set_easing_duration (old_duration);
     }
 
-    private uint transition_index = 0;
-
     public void fade_actor (Clutter.Actor actor, uint opacity) {
         if (opacity != 0)
             actor.show ();
@@ -118,18 +116,21 @@ public void fade_actor (Clutter.Actor actor, uint opacity) {
         // Don't react to use input while fading out
         actor.set_reactive (opacity == 255);
 
-        var transition = new Clutter.PropertyTransition ("opacity");
+        var transition = actor.get_transition ("animate-opacity");
+        if (transition != null)
+            actor.remove_transition ("animate-opacity");
+
+        transition = new Clutter.PropertyTransition ("opacity");
         var value = GLib.Value (typeof (uint));
         value.set_uint (opacity);
         transition.set_to_value (value);
         transition.set_duration (App.app.duration);
         transition.set_progress_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
-        var name = "opacity%u".printf (transition_index++);
         transition.completed.connect (() => {
-            actor.remove_transition (name);
+            actor.remove_transition ("animate-opacity");
             actor.visible = actor.opacity != 0;
         });
-        actor.add_transition (name, transition);
+        actor.add_transition ("animate-opacity", transition);
     }
 
     public delegate void ActorFunc (Clutter.Actor actor);
-- 
1.8.4.2