[cheese] Shoot when the webcam capture button is pressed
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Shoot when the webcam capture button is pressed
- Date: Wed, 2 Jan 2013 22:00:28 +0000 (UTC)
commit 242cc91db549f160f4047ef1bbb26b83ebffd206
Author: David King <amigadave amigadave com>
Date: Wed Jan 2 19:07:56 2013 +0000
Shoot when the webcam capture button is pressed
This functionality existed is Cheese 2.32 (it was added in commit
de0114556cef148c396552d1c189b476ea0c8aab) but was lost in 3.0. Add it
back to fix bug 690961.
src/cheese-main.vala | 43 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/src/cheese-main.vala b/src/cheese-main.vala
index 259e554..ac5ba6f 100644
--- a/src/cheese-main.vala
+++ b/src/cheese-main.vala
@@ -129,10 +129,15 @@ public class Cheese.Main : Gtk.Application
if (fullscreen)
main_window.set_startup_fullscreen_mode ();
- main_window.show ();
- setup_camera (device);
- preferences_dialog = new PreferencesDialog (camera);
- }
+ /* Shoot when the webcam capture button is pressed. */
+ main_window.add_events (Gdk.EventMask.KEY_PRESS_MASK
+ | Gdk.EventMask.KEY_RELEASE_MASK);
+ main_window.key_press_event.connect (on_webcam_key_pressed);
+
+ main_window.show ();
+ setup_camera (device);
+ preferences_dialog = new PreferencesDialog (camera);
+ }
}
/**
@@ -286,6 +291,36 @@ public class Cheese.Main : Gtk.Application
}
/**
+ * Handle the webcam take photo button being pressed.
+ *
+ * @param event the Gdk.KeyEvent
+ * @return true to stop other handlers being invoked, false to propagate
+ * the event further
+ */
+ private bool on_webcam_key_pressed (Gdk.EventKey event)
+ {
+ /* Ignore the event if any modifier keys are pressed. */
+ if (event.state != 0
+ && ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0
+ || (event.state & Gdk.ModifierType.MOD1_MASK) != 0
+ || (event.state & Gdk.ModifierType.MOD3_MASK) != 0
+ || (event.state & Gdk.ModifierType.MOD4_MASK) != 0
+ || (event.state & Gdk.ModifierType.MOD5_MASK) != 0))
+ {
+ return false;
+ }
+
+ switch (event.keyval)
+ {
+ case Gdk.Key.WebCam:
+ on_shoot ();
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
* Handle the camera state changing.
*
* @param new_state the new Cheese.Camera state
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]