[cheese/three-point-oh] Burst mode works.



commit e87a9bd34bb5660d18dfcc538344039003d1c1ca
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date:   Sun Jun 13 19:37:35 2010 +0530

    Burst mode works.
    
    WARNING: HACK. Not quite the ideal code. Can break.

 valasrc/cheese-countdown.vala |    5 ++++-
 valasrc/cheese-window.vala    |   40 ++++++++++++++++++++++------------------
 2 files changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/valasrc/cheese-countdown.vala b/valasrc/cheese-countdown.vala
index 56796fe..1fb82a8 100644
--- a/valasrc/cheese-countdown.vala
+++ b/valasrc/cheese-countdown.vala
@@ -16,6 +16,8 @@ internal class Cheese.Countdown : GLib.Object{
 		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);
@@ -28,11 +30,12 @@ internal class Cheese.Countdown : GLib.Object{
 	
 	private void fade_in() {
 		this.current_value++;
-		this.countdown_actor.text = "%d".printf(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);
diff --git a/valasrc/cheese-window.vala b/valasrc/cheese-window.vala
index f0fa7bb..6b490a0 100644
--- a/valasrc/cheese-window.vala
+++ b/valasrc/cheese-window.vala
@@ -285,6 +285,26 @@ public class Cheese.MainWindow : Gtk.Window {
 		cd.start_countdown(finish_countdown_callback);
 	}
 
+	private int burst_count;
+
+	private bool burst_take_photo() {
+		if (is_bursting && burst_count < 3) {
+			this.take_photo();
+			burst_count++;
+			return true;
+		}
+		else {
+			is_bursting = false;			
+			this.enable_mode_change();
+			take_action_button.related_action.sensitive = true;
+			effects_toggle_action.sensitive = true;
+			burst_count = 0;
+			fileutil.reset_burst();
+			return false;
+		}
+	}
+									
+	
 	[CCode (instance_pos = -1)]
 	internal void on_take_action (Action action ) {
 		if (current_mode == MediaMode.PHOTO) {
@@ -309,28 +329,12 @@ public class Cheese.MainWindow : Gtk.Window {
 			}
 		}
 		else if (current_mode == MediaMode.BURST) {
-			int burst_count = 0;
 			is_bursting = true;
 			this.disable_mode_change();
 			take_action_button.related_action.sensitive = false;
 			effects_toggle_action.sensitive = false;
-			GLib.Timeout.add_seconds(2,
-									 () => {
-										 if (is_bursting && burst_count < 3) {
-											 this.take_photo();
-											 burst_count++;
-											 return true;
-										 }
-										 else {
-											 is_bursting = false;
-											 	
-											 this.enable_mode_change();
-											 take_action_button.related_action.sensitive = true;
-											 effects_toggle_action.sensitive = true;
-											 fileutil.reset_burst();
-											 return false;
-										 }
-										 });
+			burst_take_photo();
+			GLib.Timeout.add(3500, burst_take_photo);
 		}
 	}
 	



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