[cheese/wip-cancel] Esc now does nothing when no action is being taken



commit 392ef912fa5e6d1a6a868aa42a8f1983b090b48e
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date:   Thu Aug 19 02:01:17 2010 +0530

    Esc now does nothing when no action is being taken

 src/cheese-countdown.vala |    7 ++++++-
 src/cheese-window.vala    |   41 ++++++++++++++++++++++-------------------
 2 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/src/cheese-countdown.vala b/src/cheese-countdown.vala
index 1f4b882..1dd426e 100644
--- a/src/cheese-countdown.vala
+++ b/src/cheese-countdown.vala
@@ -38,6 +38,8 @@ internal class Cheese.Countdown : GLib.Object
 
   private static Clutter.Animation anim;
 
+  public bool running;
+  
   public Countdown (Clutter.Text countdown_actor)
   {
     this.countdown_actor = countdown_actor;
@@ -54,6 +56,7 @@ internal class Cheese.Countdown : GLib.Object
     if (this.current_value <= 0)
     {
       this.completed_callback ();
+	  running = false;
       return;
     }
     this.countdown_actor.text = this.current_value.to_string ();
@@ -63,10 +66,11 @@ internal class Cheese.Countdown : GLib.Object
     signal_id = Signal.connect_after (anim, "completed", (GLib.Callback)fade_out, this);
   }
 
-  public void start_countdown (CountdownCallback completed_callback)
+  public void start (CountdownCallback completed_callback)
   {
     this.completed_callback = completed_callback;
     this.current_value      = COUNTDOWN_START;
+	running = true;
     countdown_actor.show ();
     fade_in ();
   }
@@ -75,5 +79,6 @@ internal class Cheese.Countdown : GLib.Object
   {
     countdown_actor.hide ();
     SignalHandler.disconnect (anim, signal_id);
+	running = false;
   }
 }
diff --git a/src/cheese-window.vala b/src/cheese-window.vala
index 9347305..5b9fc0f 100644
--- a/src/cheese-window.vala
+++ b/src/cheese-window.vala
@@ -611,7 +611,7 @@ public class Cheese.MainWindow : Gtk.Window
       if (current_mode == MediaMode.PHOTO)
         take_photo_action.sensitive = false;
       current_countdown = new Countdown (this.countdown_layer);
-      current_countdown.start_countdown (finish_countdown_callback);
+      current_countdown.start (finish_countdown_callback);
     }
     else
     {
@@ -648,27 +648,30 @@ public class Cheese.MainWindow : Gtk.Window
     string key;
 
     key = Gdk.keyval_name (event.keyval);
-    if (strcmp (key, "Escape") == 0)
+    if ((current_countdown != null && current_countdown.running) || is_bursting || is_recording)
     {
-      action_cancelled = true;
-      if (current_mode == MediaMode.PHOTO)
-      {
-        current_countdown.stop ();
-        finish_countdown_callback ();
-      }
-      else
-      if (current_mode == MediaMode.BURST)
-      {
-        current_countdown.stop ();
-        is_bursting = false;
-        burst_take_photo ();
-      }
-      else
-      if (current_mode == MediaMode.VIDEO)
+      if (strcmp (key, "Escape") == 0)
       {
-        toggle_video_recording (false);
+        action_cancelled = true;
+        if (current_mode == MediaMode.PHOTO)
+        {
+          current_countdown.stop ();
+          finish_countdown_callback ();
+        }
+        else
+        if (current_mode == MediaMode.BURST)
+        {
+          current_countdown.stop ();
+          is_bursting = false;
+          burst_take_photo ();
+        }
+        else
+        if (current_mode == MediaMode.VIDEO)
+        {
+          toggle_video_recording (false);
+        }
+        action_cancelled = false;
       }
-      action_cancelled = false;
     }
     return false;
   }



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