[cheese/three-point-oh] use static variables for the countdown return function and countdown variable
- From: Daniel G. Siegel <dgsiegel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese/three-point-oh] use static variables for the countdown return function and countdown variable
- Date: Tue, 15 Jun 2010 13:02:21 +0000 (UTC)
commit d0b6d0414a9d16e363675c41b02adda279209798
Author: daniel g. siegel <dgsiegel gnome org>
Date: Tue Jun 15 14:33:07 2010 +0200
use static variables for the countdown return function and countdown variable
those two variables are otherwise not used by the instance
and therefore point to the wrong address
valasrc/cheese-countdown.vala | 88 ++++++++++++++++++-----------------------
1 files changed, 38 insertions(+), 50 deletions(-)
---
diff --git a/valasrc/cheese-countdown.vala b/valasrc/cheese-countdown.vala
index 1fb82a8..5abe8e3 100644
--- a/valasrc/cheese-countdown.vala
+++ b/valasrc/cheese-countdown.vala
@@ -1,53 +1,41 @@
using GLib;
using Clutter;
-const int COUNTDOWN_TILL = 3;
-
-internal class Cheese.Countdown : GLib.Object{
-
- public delegate void CountdownCallback();
-
- private Clutter.Text countdown_actor;
- private CountdownCallback completed_callback;
-
- private int current_value = 0;
-
- public Countdown(Clutter.Text countdown_actor) {
- this.countdown_actor = countdown_actor;
- }
-
- // HACK: completed signal of animation never seems to be fired.
- // Faking it with a one shot timer. Ugh.
- private void fade_out() {
- Clutter.Animation anim = this.countdown_actor.animate(Clutter.AnimationMode.LINEAR, 500,
- "opacity", 0);
-// anim.completed.connect_after( () => {fade_in();});
- GLib.Timeout.add(500,
- () => { fade_in();
- return false;
- });
- }
-
- private void fade_in() {
- this.current_value++;
- if (this.current_value > 3) {
- this.completed_callback();
- return;
- }
- this.countdown_actor.text = this.current_value.to_string();
-
-
- Clutter.Animation anim = this.countdown_actor.animate(Clutter.AnimationMode.LINEAR, 500,
- "opacity", 255);
-// anim.completed.connect_after(() => {fade_out();});
- GLib.Timeout.add(500,
- () => { fade_out();
- return false;
- });
- }
-
- public void start_countdown (CountdownCallback completed_callback) {
- this.completed_callback = completed_callback;
- fade_in();
- }
-}
\ No newline at end of file
+const int COUNTDOWN_START = 3;
+
+internal class Cheese.Countdown : GLib.Object {
+
+ public delegate void CountdownCallback();
+
+ private Clutter.Text countdown_actor;
+ private static CountdownCallback completed_callback;
+
+ private static int current_value = 0;
+
+ public Countdown(Clutter.Text countdown_actor) {
+ this.countdown_actor = countdown_actor;
+ }
+
+ private void fade_out() {
+ Clutter.Animation anim = this.countdown_actor.animate(Clutter.AnimationMode.LINEAR, 500, "opacity", 0);
+ Signal.connect_after(anim, "completed", (GLib.Callback) fade_in, this);
+ }
+
+ private void fade_in() {
+ if (this.current_value <= 0) {
+ this.completed_callback();
+ return;
+ }
+ this.countdown_actor.text = this.current_value.to_string();
+ this.current_value--;
+
+ Clutter.Animation anim = this.countdown_actor.animate(Clutter.AnimationMode.LINEAR, 500, "opacity", 255);
+ Signal.connect_after(anim, "completed", (GLib.Callback) fade_out, this);
+ }
+
+ public void start_countdown (CountdownCallback completed_callback) {
+ this.completed_callback = completed_callback;
+ this.current_value = COUNTDOWN_START;
+ fade_in();
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]