[cheese] Patch for bug #595005
- From: Felix Kaser <kaserf src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [cheese] Patch for bug #595005
- Date: Mon, 5 Oct 2009 13:44:06 +0000 (UTC)
commit 0c78e416da737667051bdefdbbcbf493f02759b7
Author: Felix Kaser <f kaser gmx net>
Date: Mon Sep 28 11:34:07 2009 +0200
Patch for bug #595005
In burstmode pictures get another filename than in normal mode (the same name as normal but with an index after the timestamp)
src/cheese-fileutil.c | 36 ++++++++++++++++++++++++++++++++----
src/cheese-fileutil.h | 4 +++-
src/cheese-window.c | 14 ++++++++++----
3 files changed, 45 insertions(+), 9 deletions(-)
---
diff --git a/src/cheese-fileutil.c b/src/cheese-fileutil.c
index f18e6a5..799f8ea 100644
--- a/src/cheese-fileutil.c
+++ b/src/cheese-fileutil.c
@@ -40,6 +40,8 @@ typedef struct
gchar *video_path;
gchar *photo_path;
gchar *log_path;
+ gint burst_count;
+ gchar *burst_raw_name;
} CheeseFileUtilPrivate;
gchar *
@@ -95,20 +97,30 @@ cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMod
GFile *file;
int num;
+ CheeseFileUtilPrivate *priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
tm = time (NULL);
ptr = localtime (&tm);
strftime (date, 20, "%F-%H%M%S", ptr);
-
- if (mode == CHEESE_MEDIA_MODE_PHOTO)
+
+ if ((mode == CHEESE_MEDIA_MODE_PHOTO) || (mode == CHEESE_MEDIA_MODE_BURST))
path = cheese_fileutil_get_photo_path (fileutil);
else
path = cheese_fileutil_get_video_path (fileutil);
if (mode == CHEESE_MEDIA_MODE_PHOTO)
+ {
filename = g_strdup_printf ("%s%s%s%s", path, G_DIR_SEPARATOR_S, date, PHOTO_NAME_SUFFIX);
- else
+ }else if (mode == CHEESE_MEDIA_MODE_BURST)
+ {
+ priv->burst_count++;
+ if (strlen(priv->burst_raw_name)==0)
+ priv->burst_raw_name = g_strdup_printf ("%s%s%s", path, G_DIR_SEPARATOR_S, date);
+
+ filename = g_strdup_printf ("%s_%d%s", priv->burst_raw_name, priv->burst_count, PHOTO_NAME_SUFFIX);
+ }else{
filename = g_strdup_printf ("%s%s%s%s", path, G_DIR_SEPARATOR_S, date, VIDEO_NAME_SUFFIX);
-
+ }
+
file = g_file_new_for_path (filename);
if (g_file_query_exists (file, NULL))
@@ -116,6 +128,8 @@ cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMod
num = 1;
if (mode == CHEESE_MEDIA_MODE_PHOTO)
filename = g_strdup_printf ("%s%s%s (%d)%s", path, G_DIR_SEPARATOR_S, date, num, PHOTO_NAME_SUFFIX);
+ else if (mode == CHEESE_MEDIA_MODE_BURST)
+ filename = g_strdup_printf ("%s_%d (%d)%s", priv->burst_raw_name, priv->burst_count, num, PHOTO_NAME_SUFFIX);
else
filename = g_strdup_printf ("%s%s%s (%d)%s", path, G_DIR_SEPARATOR_S, date, num, VIDEO_NAME_SUFFIX);
@@ -126,6 +140,8 @@ cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMod
num++;
if (mode == CHEESE_MEDIA_MODE_PHOTO)
filename = g_strdup_printf ("%s%s%s (%d)%s", path, G_DIR_SEPARATOR_S, date, num, PHOTO_NAME_SUFFIX);
+ else if (mode == CHEESE_MEDIA_MODE_BURST)
+ filename = g_strdup_printf ("%s_%d (%d)%s", priv->burst_raw_name, priv->burst_count, num, PHOTO_NAME_SUFFIX);
else
filename = g_strdup_printf ("%s%s%s (%d)%s", path, G_DIR_SEPARATOR_S, date, num, VIDEO_NAME_SUFFIX);
@@ -136,6 +152,15 @@ cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMod
return filename;
}
+void
+cheese_fileutil_reset_burst(CheeseFileUtil *fileutil)
+{
+ CheeseFileUtilPrivate *priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
+
+ priv->burst_count = 0;
+ priv->burst_raw_name = "";
+}
+
static void
cheese_fileutil_finalize (GObject *object)
{
@@ -165,6 +190,9 @@ cheese_fileutil_init (CheeseFileUtil *fileutil)
{
CheeseFileUtilPrivate *priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
+ priv->burst_count = 0;
+ priv->burst_raw_name = "";
+
CheeseGConf *gconf;
gconf = cheese_gconf_new ();
diff --git a/src/cheese-fileutil.h b/src/cheese-fileutil.h
index c695d55..665a727 100644
--- a/src/cheese-fileutil.h
+++ b/src/cheese-fileutil.h
@@ -49,7 +49,8 @@ typedef struct
typedef enum
{
CHEESE_MEDIA_MODE_PHOTO,
- CHEESE_MEDIA_MODE_VIDEO
+ CHEESE_MEDIA_MODE_VIDEO,
+ CHEESE_MEDIA_MODE_BURST
} CheeseMediaMode;
@@ -61,6 +62,7 @@ gchar *cheese_fileutil_get_photo_path (CheeseFileUtil *fileutil);
gchar *cheese_fileutil_get_path_before_224 (CheeseFileUtil *fileutil);
gchar *cheese_fileutil_get_log_path (CheeseFileUtil *fileutil);
gchar *cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMode mode);
+void cheese_fileutil_reset_burst(CheeseFileUtil *fileutil);
G_END_DECLS
diff --git a/src/cheese-window.c b/src/cheese-window.c
index b6eda76..623a9c9 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -91,8 +91,6 @@ typedef struct
char *startup_hal_dev_udi;
char *video_filename;
- int counter;
-
CheeseWebcam *webcam;
WebcamMode webcam_mode;
CheeseGConf *gconf;
@@ -1072,6 +1070,7 @@ cheese_window_cmd_about (GtkAction *action, CheeseWindow *cheese_window)
static const char *documenters[] = {
"Joshua Henderson <joshhendo gmail com>",
"Jaap A. Haitsma <jaap haitsma org>",
+ "Felix Kaser <f kaser gmx net>",
NULL
};
@@ -1273,7 +1272,13 @@ cheese_window_countdown_picture_cb (gpointer data)
char *shutter_filename;
char *photo_filename;
- photo_filename = cheese_fileutil_get_new_media_filename (cheese_window->fileutil, WEBCAM_MODE_PHOTO);
+ if (cheese_window->webcam_mode == WEBCAM_MODE_BURST)
+ {
+ photo_filename = cheese_fileutil_get_new_media_filename (cheese_window->fileutil, CHEESE_MEDIA_MODE_BURST);
+ }else{
+ photo_filename = cheese_fileutil_get_new_media_filename (cheese_window->fileutil, CHEESE_MEDIA_MODE_PHOTO);
+ }
+
if (cheese_webcam_take_photo (cheese_window->webcam, photo_filename))
{
cheese_flash_fire (cheese_window->flash);
@@ -1446,7 +1451,7 @@ cheese_window_take_photo (gpointer data)
repeat_delay = 5000;
}
- /* start burst mode phot series */
+ /* start burst mode photo series */
if (!cheese_window->is_bursting)
{
g_timeout_add (repeat_delay, cheese_window_take_photo, cheese_window);
@@ -1480,6 +1485,7 @@ cheese_window_action_button_clicked_cb (GtkWidget *widget, CheeseWindow *cheese_
gtk_action_group_set_sensitive (cheese_window->actions_effects, FALSE);
gtk_action_group_set_sensitive (cheese_window->actions_toggle, FALSE);
g_object_get (cheese_window->gconf, "gconf_prop_burst_repeat", &cheese_window->repeat_count, NULL); /* reset burst counter */
+ cheese_fileutil_reset_burst(cheese_window->fileutil); /* reset filename counter */
case WEBCAM_MODE_PHOTO:
cheese_window_take_photo (cheese_window);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]