diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-06-18 09:05:19 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-09-17 14:37:43 +0200 |
commit | e898276f5fd5c4748766748340fd2cde898ca2e3 (patch) | |
tree | 35f08e3a91c8a5f89a53428cd0a4818adad15121 | |
parent | 65027bed3ef54b18534e7f3a552bb7275df48b33 (diff) |
cheese-window: Add cancel_running_action () method
And use it to stop recording / the photo countdown when we get an error
while either one is active.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | src/cheese-window.vala | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/cheese-window.vala b/src/cheese-window.vala index dd8fbfc..e117ec2 100644 --- a/src/cheese-window.vala +++ b/src/cheese-window.vala @@ -717,6 +717,34 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow } /** + * Cancel the current action (if any) + */ + private bool cancel_running_action () + { + if ((current_countdown != null && current_countdown.running) || + is_bursting || is_recording) + { + action_cancelled = true; + switch (current_mode) + { + case MediaMode.PHOTO: + current_countdown.stop (); + finish_countdown_callback (); + break; + case MediaMode.BURST: + toggle_photo_bursting (false); + break; + case MediaMode.VIDEO: + toggle_video_recording (false); + break; + } + action_cancelled = false; + return true; + } + return false; + } + + /** * Cancel the current activity if the escape key is pressed. * * @param event the key event, to check which key was pressed @@ -729,23 +757,9 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow key = Gdk.keyval_name (event.keyval); if (strcmp (key, "Escape") == 0) { - if ((current_countdown != null && current_countdown.running) || is_bursting || is_recording) + if (cancel_running_action()) { - action_cancelled = true; - switch (current_mode) - { - case MediaMode.PHOTO: - current_countdown.stop (); - finish_countdown_callback (); - break; - case MediaMode.BURST: - toggle_photo_bursting (false); - break; - case MediaMode.VIDEO: - toggle_video_recording (false); - break; - } - action_cancelled = false; + return false; } else if (is_effects_selector_active) { @@ -1147,6 +1161,7 @@ public class Cheese.MainWindow : Gtk.ApplicationWindow */ public void camera_state_change_null () { + cancel_running_action(); if (!error_layer.visible) { show_error (_("There was an error playing video from the webcam")); |