[cheese] support taking a series of photos, partially fixes bug #581997



commit 011ee85b039d307c8b670b4238127d7817ae349f
Author: Aidan Delaney <a j delaney brighton ac uk>
Date:   Mon Jul 27 22:49:23 2009 +0200

    support taking a series of photos, partially fixes bug #581997
    
    this is the first part of the patch, which introduces a burst mode in cheese.
    the burst mode allows to take a series of photos, which are defined in a gconf
    entry for now and are not configurable yet.

 AUTHORS                |    1 +
 data/cheese.schemas.in |   22 ++++++++++++++++++++
 src/cheese-gconf.c     |   39 ++++++++++++++++++++++++++++++++++++
 src/cheese-gconf.h     |    4 ++-
 src/cheese-window.c    |   51 +++++++++++++++++++++++++++++++++++++++++------
 5 files changed, 109 insertions(+), 8 deletions(-)
---
diff --git a/AUTHORS b/AUTHORS
index 92a0841..006f9b2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,7 @@
 written by daniel g. siegel <dgsiegel gmail com> and Jaap A. Haitsma <jaap haitsma org>
 
 the following people contributed to cheese:
+  - Aidan Delaney <a j delaney brighton ac uk>
   - Alex "weej" Jones <alex weej com>
   - Andrea Cimitan <andrea cimitan gmail com>
   - Baptiste Mille-Mathias <bmm80 free fr>
diff --git a/data/cheese.schemas.in b/data/cheese.schemas.in
index 9b04aa0..44dcabb 100644
--- a/data/cheese.schemas.in
+++ b/data/cheese.schemas.in
@@ -148,5 +148,27 @@
 			</locale>
     </schema>
 
+    <schema>
+			<key>/schemas/apps/cheese/burst_delay</key>
+			<applyto>/apps/cheese/burst_delay</applyto>
+			<owner>cheese</owner>
+			<type>int</type>
+			<default>1000</default>
+			<locale name="C">
+				<short>Milliseconds between photos in burst mode.</short>
+				<long>The length of time, in milliseconds, to delay between taking each photo in a burst sequence of photos.</long>
+			</locale>
+    </schema>
+    <schema>
+			<key>/schemas/apps/cheese/burst_repeat</key>
+			<applyto>/apps/cheese/burst_repeat</applyto>
+			<owner>cheese</owner>
+			<type>int</type>
+			<default>4</default>
+			<locale name="C">
+				<short>Number of photos in burst mode.</short>
+				<long>The number of photos to take in a single burst.</long>
+			</locale>
+    </schema>
 	</schemalist>
 </gconfschemafile>
diff --git a/src/cheese-gconf.c b/src/cheese-gconf.c
index d2bda4d..fc2e026 100644
--- a/src/cheese-gconf.c
+++ b/src/cheese-gconf.c
@@ -172,6 +172,16 @@ cheese_gconf_get_property (GObject *object, guint prop_id, GValue *value,
                                                          CHEESE_GCONF_PREFIX "/enable_delete",
                                                          NULL));
       break;
+    case GCONF_PROP_BURST_DELAY:
+      g_value_set_int (value, gconf_client_get_int (priv->client,
+						    CHEESE_GCONF_PREFIX "/burst_mode_delay",
+						    NULL));
+      break;
+    case GCONF_PROP_BURST_REPEAT:
+      g_value_set_int (value, gconf_client_get_int (priv->client,
+						    CHEESE_GCONF_PREFIX "/burst_mode_repeat",
+						    NULL));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -299,6 +309,18 @@ cheese_gconf_set_property (GObject *object, guint prop_id, const GValue *value,
                              g_value_get_boolean (value),
                              NULL);
       break;
+    case GCONF_PROP_BURST_DELAY:
+      gconf_client_set_int (priv->client,
+			    CHEESE_GCONF_PREFIX "/burst_mode_delay",
+			    g_value_get_int (value),
+			    NULL);
+      break;
+    case GCONF_PROP_BURST_REPEAT:
+      gconf_client_set_int (priv->client,
+			    CHEESE_GCONF_PREFIX "/burst_mode_repeat",
+			    g_value_get_int (value),
+			    NULL);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -421,6 +443,23 @@ cheese_gconf_class_init (CheeseGConfClass *klass)
                                                          FALSE,
                                                          G_PARAM_READWRITE));
 
+  g_object_class_install_property (object_class, GCONF_PROP_BURST_DELAY,
+                                   g_param_spec_int ("gconf_prop_burst_delay",
+                                                     NULL,
+                                                     NULL,
+                                                     200,  // based on some experiments
+                                                     G_MAXINT,
+                                                     1000,
+                                                     G_PARAM_READWRITE));
+
+  g_object_class_install_property (object_class, GCONF_PROP_BURST_REPEAT,
+                                   g_param_spec_int ("gconf_prop_burst_repeat",
+                                                     NULL,
+                                                     NULL,
+                                                     1,
+                                                     G_MAXINT,
+                                                     4,
+                                                     G_PARAM_READWRITE));
 
   g_type_class_add_private (klass, sizeof (CheeseGConfPrivate));
 }
diff --git a/src/cheese-gconf.h b/src/cheese-gconf.h
index 4086169..d9cabb8 100644
--- a/src/cheese-gconf.h
+++ b/src/cheese-gconf.h
@@ -53,7 +53,9 @@ enum
   GCONF_PROP_HUE,
   GCONF_PROP_VIDEO_PATH,
   GCONF_PROP_PHOTO_PATH,
-  GCONF_PROP_ENABLE_DELETE
+  GCONF_PROP_ENABLE_DELETE,
+  GCONF_PROP_BURST_DELAY,
+  GCONF_PROP_BURST_REPEAT
 };
 
 GType        cheese_gconf_get_type (void);
diff --git a/src/cheese-window.c b/src/cheese-window.c
index e500e89..821f1e1 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -70,7 +70,8 @@
 typedef enum
 {
   WEBCAM_MODE_PHOTO,
-  WEBCAM_MODE_VIDEO
+  WEBCAM_MODE_VIDEO,
+  WEBCAM_MODE_BURST
 } WebcamMode;
 
 typedef enum
@@ -178,6 +179,8 @@ typedef struct
 
   int audio_play_counter;
 
+  gint repeat_count;
+
   CheeseFlash *flash;
 } CheeseWindow;
 
@@ -1280,14 +1283,11 @@ cheese_window_escape_key_cb (CheeseWindow *cheese_window,
   return TRUE;
 }
 
-static void
-cheese_window_action_button_clicked_cb (GtkWidget *widget, CheeseWindow *cheese_window)
+static gboolean
+cheese_window_take_burst_photo (gpointer data)
 {
-  char *str;
-
-  if (cheese_window->webcam_mode == WEBCAM_MODE_PHOTO)
-  {
     gboolean countdown;
+    CheeseWindow *cheese_window = (CheeseWindow *) data;
     g_object_get (cheese_window->gconf, "gconf_prop_countdown", &countdown, NULL);
     if (countdown)
     {
@@ -1323,8 +1323,45 @@ cheese_window_action_button_clicked_cb (GtkWidget *widget, CheeseWindow *cheese_
     gtk_widget_set_sensitive (cheese_window->take_picture, FALSE);
     gtk_widget_set_sensitive (cheese_window->take_picture_fullscreen, FALSE);
 
+    cheese_window->repeat_count--;
+    if(0 >= cheese_window->repeat_count)
+    {
+      return FALSE;
+    }
+    return TRUE;
+}
+
+static void
+cheese_window_action_button_clicked_cb (GtkWidget *widget, CheeseWindow *cheese_window)
+{
+  char *str;
+
+  if (cheese_window->webcam_mode == WEBCAM_MODE_PHOTO)
+  {
+    cheese_window->repeat_count=1;
+    cheese_window_take_burst_photo(cheese_window);
+
     /* FIXME: set menu inactive */
   }
+  else if (cheese_window->webcam_mode == WEBCAM_MODE_BURST)
+  {
+    guint repeat_delay=1000;
+    gboolean countdown;
+
+    g_object_get (cheese_window->gconf, "gconf_prop_burst_delay", &repeat_delay, NULL);
+    g_object_get (cheese_window->gconf, "gconf_prop_burst_repeat", &cheese_window->repeat_count, NULL);
+    g_object_get (cheese_window->gconf, "gconf_prop_countdown", &countdown, NULL);
+
+    if (countdown && repeat_delay < 5000)
+    {
+      // A countdown takes 4 seconds, leave some headroom before repeating it.
+      // Magic number chosen via expiriment on Netbook
+      repeat_delay = 5000;
+    }
+
+    g_timeout_add (repeat_delay, &cheese_window_take_burst_photo, cheese_window);
+
+  }
   else if (cheese_window->webcam_mode == WEBCAM_MODE_VIDEO)
   {
     if (!cheese_window->recording)



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