cheese r720 - in trunk: . data src



Author: kaserf
Date: Sun May 18 16:27:00 2008
New Revision: 720
URL: http://svn.gnome.org/viewvc/cheese?rev=720&view=rev

Log:
Added support to set the video and photo path in gconf! First priority has gconf, if gconf setting is "" then use xdg, if xdg is "" as well, use "~/.gnome2/cheese/media"!


Modified:
   trunk/ChangeLog
   trunk/data/cheese.schemas.in
   trunk/src/cheese-fileutil.c
   trunk/src/cheese-fileutil.h
   trunk/src/cheese-gconf.c
   trunk/src/cheese-gconf.h
   trunk/src/cheese-thumb-view.c
   trunk/src/cheese-window.c
   trunk/src/cheese.c

Modified: trunk/data/cheese.schemas.in
==============================================================================
--- trunk/data/cheese.schemas.in	(original)
+++ trunk/data/cheese.schemas.in	Sun May 18 16:27:00 2008
@@ -17,7 +17,7 @@
 			<applyto>/apps/cheese/webcam</applyto>
 			<owner>cheese</owner>
 			<type>string</type>
-			<default>CHECK_PATTERN</default>
+			<default></default>
 			<locale name="C">
 				<short>Webcam device string indicator</short>
 				<long>The device-string which points to the webcam, e.g. /dev/video0</long>
@@ -49,7 +49,7 @@
 				<short>X resolution</short>
 				<long>The X resolution of the image captured from the camera</long>
 			</locale>
-    	</schema>
+    </schema>
 		
 		<schema>
 			<key>/schemas/apps/cheese/y_resolution</key>
@@ -61,7 +61,31 @@
 				<short>Y resolution</short>
 				<long>The Y resolution of the image captured from the camera</long>
 			</locale>
-    	</schema>
+    </schema>
+    	
+    <schema>
+			<key>/schemas/apps/cheese/video_path</key>
+			<applyto>/apps/cheese/video_path</applyto>
+			<owner>cheese</owner>
+			<type>string</type>
+			<default></default>
+			<locale name="C">
+				<short>Video Path</short>
+				<long>Defines the path where the videos are stored, if empty "XDG_VIDEO/Webcam" will be used.</long>
+			</locale>
+    </schema>
+    
+    <schema>
+			<key>/schemas/apps/cheese/photo_path</key>
+			<applyto>/apps/cheese/photo_path</applyto>
+			<owner>cheese</owner>
+			<type>string</type>
+			<default></default>
+			<locale name="C">
+				<short>Photo Path</short>
+				<long>Defines the path where the photos are stored, if empty "XDG_PHOTO/Webcam" will be used.</long>
+			</locale>
+    </schema>
 
 	</schemalist>
 </gconfschemafile>

Modified: trunk/src/cheese-fileutil.c
==============================================================================
--- trunk/src/cheese-fileutil.c	(original)
+++ trunk/src/cheese-fileutil.c	Sun May 18 16:27:00 2008
@@ -1,7 +1,8 @@
 /*
  * Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
  * Copyright (C) 2007,2008 Jaap Haitsma <jaap haitsma org>
- *
+ * Copyright (C) 2008 Felix Kaser <f kaser gmx net>
+ * 
  * Licensed under the GNU General Public License Version 2
  *
  * This program is free software; you can redistribute it and/or modify
@@ -26,64 +27,77 @@
 #include <gio/gio.h>
 #include <stdlib.h>
 
+#include <string.h>
+
 #include "cheese-fileutil.h"
+#include "cheese-gconf.h"
+
+G_DEFINE_TYPE (CheeseFileUtil, cheese_fileutil, G_TYPE_OBJECT)
+
+#define CHEESE_FILEUTIL_GET_PRIVATE(o) \
+    (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHEESE_TYPE_FILEUTIL, CheeseFileUtilPrivate))
+
+typedef struct{
+  gchar *video_path;
+  gchar *photo_path;
+  gchar *log_path;
+} CheeseFileUtilPrivate;
 
-char *
-cheese_fileutil_get_photo_path ()
+gchar *
+cheese_fileutil_get_video_path (CheeseFileUtil *fileutil)
 {
-  char *path;
+  gchar *path;
+  CheeseFileUtilPrivate* priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
   
 #ifdef HILDON
   // TODO change HILDON to xdg as well?
-  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir(), "Mydocs", ".images", NULL);
+  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), "Mydocs", ".videos", NULL);
 #else
-  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), "Webcam", NULL);
+  path = priv->video_path;
 #endif
 
   return path;
 }
 
-char *
-cheese_fileutil_get_video_path ()
+gchar *
+cheese_fileutil_get_photo_path (CheeseFileUtil *fileutil)
 {
-  char *path;
+  gchar *path;
+  CheeseFileUtilPrivate* priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
   
 #ifdef HILDON
   // TODO change HILDON to xdg as well?
-  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), "Mydocs", "videos", NULL);
+  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), "Mydocs", ".images", NULL);
 #else
-  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS), "Webcam", NULL);
+  path = priv->photo_path;
 #endif
 
   return path;
-
 }
 
-char *
-cheese_fileutil_get_log_path ()
+gchar *
+cheese_fileutil_get_log_path (CheeseFileUtil *fileutil)
 {
-  char *path;
+  gchar *path;
+  CheeseFileUtilPrivate* priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
   
 #ifdef HILDON
   // TODO change HILDON to xdg as well?
-  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), "Mydocs", "cheese-log", NULL);
+  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), "Mydocs", ".cheese-log", NULL);
 #else
-  //path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_cache_dir(), NULL);
-  path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2", "cheese", NULL);
+  path = priv->log_path;
 #endif
 
   return path;
-
 }
 
-
-char *
-cheese_fileutil_get_new_media_filename (CheeseMediaMode mode)
+gchar *
+cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMode mode)
 {
   struct tm *ptr;
   time_t tm;
   char date[21];
-  char *path;
+  gchar *path;
   char *filename;
   GFile *file;
   int num;
@@ -93,9 +107,9 @@
   strftime (date, 20, "%F-%H%M%S", ptr);
 
   if (mode == CHEESE_MEDIA_MODE_PHOTO)
-    path = cheese_fileutil_get_photo_path ();
+    path = cheese_fileutil_get_photo_path (fileutil);
   else
-    path = cheese_fileutil_get_video_path ();
+    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);
@@ -123,8 +137,79 @@
       file = g_file_new_for_path (filename);
     }
   }
-
-  g_free (path);
+  
   return filename;
 }
 
+static void
+cheese_fileutil_finalize (GObject *object)
+{
+  CheeseFileUtil *fileutil;
+
+  fileutil = CHEESE_FILEUTIL (object);
+  CheeseFileUtilPrivate *priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);  
+
+  g_free (priv->video_path);
+  g_free (priv->photo_path);
+  g_free (priv->log_path);
+  G_OBJECT_CLASS (cheese_fileutil_parent_class)->finalize (object);
+}
+
+static void
+cheese_fileutil_class_init (CheeseFileUtilClass *klass)
+{  
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+  object_class->finalize = cheese_fileutil_finalize;
+
+  g_type_class_add_private (klass, sizeof (CheeseFileUtilPrivate));
+}
+
+static void
+cheese_fileutil_init (CheeseFileUtil *fileutil)
+{
+  CheeseFileUtilPrivate* priv = CHEESE_FILEUTIL_GET_PRIVATE (fileutil);
+  gchar *v_path, *p_path;
+  CheeseGConf *gconf;
+  
+  gconf = cheese_gconf_new ();  
+  
+  //get the path from gconf, xdg or hardcoded
+  g_object_get (gconf, "gconf_prop_video_path", &v_path, NULL);
+  
+  if (strcmp (v_path, "") == 0){
+    //get xdg    
+    v_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS), "Webcam", NULL);
+    if (strcmp (v_path, "") == 0){
+      //get "~/.gnome2/cheese/media"
+      
+      v_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir(), ".gnome2", "cheese", "media", NULL);
+    }
+  }
+  priv->video_path = v_path;
+  
+  //get the path from gconf, xdg or hardcoded
+  g_object_get (gconf, "gconf_prop_photo_path", &p_path, NULL);
+  
+  if (strcmp (p_path, "") == 0){
+    //get xdg
+    p_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_user_special_dir (G_USER_DIRECTORY_PICTURES), "Webcam", NULL);
+    if (strcmp (p_path, "") == 0){
+      //get "~/.gnome2/cheese/media"
+      p_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir(), ".gnome2", "cheese", "media", NULL);
+    }
+  }
+  priv->photo_path = p_path;
+  
+  priv->log_path = g_strjoin (G_DIR_SEPARATOR_S, g_get_home_dir (), ".gnome2", "cheese", NULL);
+                     
+  g_object_unref (gconf);
+}
+
+CheeseFileUtil * 
+cheese_fileutil_new ()
+{
+  CheeseFileUtil *fileutil;
+
+  fileutil = g_object_new (CHEESE_TYPE_FILEUTIL, NULL);  
+  return fileutil;
+}

Modified: trunk/src/cheese-fileutil.h
==============================================================================
--- trunk/src/cheese-fileutil.h	(original)
+++ trunk/src/cheese-fileutil.h	Sun May 18 16:27:00 2008
@@ -1,7 +1,8 @@
 /*
  * Copyright (C) 2007,2008 daniel g. siegel <dgsiegel gmail com>
  * Copyright (C) 2007,2008 Jaap Haitsma <jaap haitsma org>
- *
+ * Copyright (C) 2008 Felix Kaser <f kaser gmx net>
+ * 
  * Licensed under the GNU General Public License Version 2
  *
  * This program is free software; you can redistribute it and/or modify
@@ -18,21 +19,48 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __CHEESE_FILE_UTIL_H__
-#define __CHEESE_FILE_UTIL_H__
+#ifndef __CHEESE_FILEUTIL_H__
+#define __CHEESE_FILEUTIL_H__
 
 #define PHOTO_NAME_SUFFIX ".jpg"
 #define VIDEO_NAME_SUFFIX ".ogg"
 
+G_BEGIN_DECLS
+
+#include <glib-object.h>
+
+#define CHEESE_TYPE_FILEUTIL            (cheese_fileutil_get_type ())
+#define CHEESE_FILEUTIL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CHEESE_TYPE_FILEUTIL, CheeseFileUtil))
+#define CHEESE_FILEUTIL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  CHEESE_TYPE_FILEUTIL, CheeseFileUtilClass))
+#define CHEESE_IS_FILEUTIL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CHEESE_TYPE_FILEUTIL))
+#define CHEESE_IS_FILEUTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  CHEESE_TYPE_FILEUTIL))
+#define CHEESE_FILEUTIL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  CHEESE_TYPE_FILEUTIL, CheeseFileUtilClass))
+
+typedef struct 
+{
+  GObject parent;
+} CheeseFileUtil;
+
+typedef struct
+{
+  GObjectClass parent_class;
+} CheeseFileUtilClass;
+
 typedef enum
 {
   CHEESE_MEDIA_MODE_PHOTO,
   CHEESE_MEDIA_MODE_VIDEO
 } CheeseMediaMode;
 
-char *cheese_fileutil_get_photo_path (void);
-char *cheese_fileutil_get_video_path (void);
-char *cheese_fileutil_get_log_path (void);
-char *cheese_fileutil_get_new_media_filename (CheeseMediaMode mode);
 
-#endif /* __CHEESE_FILE_UTIL_H__ */
+GType        cheese_fileutil_get_type(void);
+CheeseFileUtil  *cheese_fileutil_new (void);
+gchar *cheese_fileutil_get_video_path (CheeseFileUtil *fileutil);
+gchar *cheese_fileutil_get_photo_path (CheeseFileUtil *fileutil);
+gchar *cheese_fileutil_get_log_path (CheeseFileUtil *fileutil);
+gchar *cheese_fileutil_get_new_media_filename (CheeseFileUtil *fileutil, CheeseMediaMode mode);
+
+G_END_DECLS
+
+#endif /* __CHEESE_FILEUTIL_H__ */
+

Modified: trunk/src/cheese-gconf.c
==============================================================================
--- trunk/src/cheese-gconf.c	(original)
+++ trunk/src/cheese-gconf.c	Sun May 18 16:27:00 2008
@@ -96,6 +96,16 @@
                                                     CHEESE_GCONF_PREFIX "/y_resolution",
                                                     NULL));
       break;
+    case GCONF_PROP_VIDEO_PATH:
+      g_value_set_string (value, gconf_client_get_string (priv->client,
+                                                    CHEESE_GCONF_PREFIX "/video_path",
+                                                    NULL));
+      break;
+    case GCONF_PROP_PHOTO_PATH:
+      g_value_set_string (value, gconf_client_get_string (priv->client,
+                                                    CHEESE_GCONF_PREFIX "/photo_path",
+                                                    NULL));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -161,6 +171,18 @@
                             g_value_get_int (value),
                             NULL);
       break;
+    case GCONF_PROP_VIDEO_PATH:
+      gconf_client_set_string (priv->client,
+                          CHEESE_GCONF_PREFIX "/video_path",
+                          g_value_get_string (value),
+                          NULL);
+      break;
+    case GCONF_PROP_PHOTO_PATH:
+      gconf_client_set_string (priv->client,
+                          CHEESE_GCONF_PREFIX "/photo_path",
+                          g_value_get_string (value),
+                          NULL);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -224,7 +246,21 @@
                                                      G_MAXINT,
                                                      0,
                                                      G_PARAM_READWRITE));
-    
+                                                     
+  g_object_class_install_property (object_class, GCONF_PROP_VIDEO_PATH,
+                                   g_param_spec_string ("gconf_prop_video_path",
+                                                        NULL,
+                                                        NULL,
+                                                        "",
+                                                        G_PARAM_READWRITE));
+  
+  g_object_class_install_property (object_class, GCONF_PROP_PHOTO_PATH,
+                                   g_param_spec_string ("gconf_prop_photo_path",
+                                                        NULL,
+                                                        NULL,
+                                                        "",
+                                                        G_PARAM_READWRITE));
+                                                          
   g_type_class_add_private (klass, sizeof (CheeseGConfPrivate));
 }
 

Modified: trunk/src/cheese-gconf.h
==============================================================================
--- trunk/src/cheese-gconf.h	(original)
+++ trunk/src/cheese-gconf.h	Sun May 18 16:27:00 2008
@@ -46,7 +46,9 @@
   GCONF_PROP_WEBCAM,
   GCONF_PROP_SELECTED_EFFECTS,
   GCONF_PROP_X_RESOLUTION,
-  GCONF_PROP_Y_RESOLUTION
+  GCONF_PROP_Y_RESOLUTION,
+  GCONF_PROP_VIDEO_PATH,
+  GCONF_PROP_PHOTO_PATH
 };
 
 GType        cheese_gconf_get_type(void);

Modified: trunk/src/cheese-thumb-view.c
==============================================================================
--- trunk/src/cheese-thumb-view.c	(original)
+++ trunk/src/cheese-thumb-view.c	Sun May 18 16:27:00 2008
@@ -42,6 +42,7 @@
 typedef struct
 {
   GtkListStore *store;
+  CheeseFileUtil *fileutil;
   GFileMonitor *photo_file_monitor;
   GFileMonitor *video_file_monitor;
 } CheeseThumbViewPrivate;
@@ -305,8 +306,8 @@
 
   gtk_list_store_clear (priv->store);
 
-  path_videos = cheese_fileutil_get_video_path ();
-  path_photos = cheese_fileutil_get_photo_path ();
+  path_videos = cheese_fileutil_get_video_path (priv->fileutil);
+  path_photos = cheese_fileutil_get_photo_path (priv->fileutil);
   
   dir_videos = g_dir_open (path_videos, 0, NULL);
   dir_photos = g_dir_open (path_photos, 0, NULL);
@@ -326,7 +327,6 @@
     g_free (filename);
     g_object_unref (file);
   }
-  g_free (path_videos);
   g_dir_close (dir_videos);
   
   //read photos from the photo directory
@@ -341,7 +341,6 @@
     g_free (filename);
     g_object_unref (file);
   }
-  g_free (path_photos);
   g_dir_close (dir_photos);
 }
 
@@ -354,6 +353,7 @@
   CheeseThumbViewPrivate *priv = CHEESE_THUMB_VIEW_GET_PRIVATE (thumb_view);  
 
   g_object_unref (priv->store);
+  g_object_unref (priv->fileutil);
   g_file_monitor_cancel (priv->photo_file_monitor);
   g_file_monitor_cancel (priv->video_file_monitor);
 
@@ -382,13 +382,15 @@
   eog_thumbnail_init ();
 
   priv->store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
+  
+  priv->fileutil = cheese_fileutil_new ();
 
   gtk_icon_view_set_model (GTK_ICON_VIEW (thumb_view), GTK_TREE_MODEL (priv->store));
 
   gtk_widget_set_size_request (GTK_WIDGET (thumb_view), -1, THUMB_VIEW_HEIGHT);
 
-  path_videos = cheese_fileutil_get_video_path ();
-  path_photos = cheese_fileutil_get_photo_path ();
+  path_videos = cheese_fileutil_get_video_path (priv->fileutil);
+  path_photos = cheese_fileutil_get_photo_path (priv->fileutil);
   
   g_mkdir_with_parents (path_videos, 0775);
   g_mkdir_with_parents (path_photos, 0775);
@@ -398,14 +400,16 @@
   priv->video_file_monitor = g_file_monitor_directory (file, 0, NULL, NULL);
   g_signal_connect (priv->video_file_monitor, "changed", G_CALLBACK (cheese_thumb_view_monitor_cb), thumb_view);
   
-  //connect signal to photo path
-  file = g_file_new_for_path (path_photos);
-  priv->photo_file_monitor = g_file_monitor_directory (file, 0, NULL, NULL);
-  g_signal_connect (priv->photo_file_monitor, "changed", G_CALLBACK (cheese_thumb_view_monitor_cb), thumb_view);
-
-  g_free (path_videos);
-  g_free (path_photos);
-
+  //if both paths are the same, make only one file monitor and point twice to the file monitor (photo_file_monitor = video_file_monitor)
+  if (strcmp (path_videos, path_photos) != 0){
+    //connect signal to photo path
+    file = g_file_new_for_path (path_photos);
+    priv->photo_file_monitor = g_file_monitor_directory (file, 0, NULL, NULL);
+    g_signal_connect (priv->photo_file_monitor, "changed", G_CALLBACK (cheese_thumb_view_monitor_cb), thumb_view);
+  }else{
+    priv->photo_file_monitor = priv->video_file_monitor;
+  }
+  
   gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (thumb_view), 0);
 #ifdef HILDON
   gtk_icon_view_set_columns (GTK_ICON_VIEW (thumb_view), -1);

Modified: trunk/src/cheese-window.c
==============================================================================
--- trunk/src/cheese-window.c	(original)
+++ trunk/src/cheese-window.c	Sun May 18 16:27:00 2008
@@ -71,6 +71,7 @@
   CheeseWebcam *webcam;
   WebcamMode webcam_mode;
   CheeseGConf *gconf;
+  CheeseFileUtil *fileutil;
 
   GtkWidget *window;
   GtkWidget *notebook;
@@ -407,7 +408,7 @@
     return;
 
   //delete all videos
-  path_videos = cheese_fileutil_get_video_path ();
+  path_videos = cheese_fileutil_get_video_path (cheese_window->fileutil);
   dir_videos = g_dir_open (path_videos, 0, NULL);
   while ((name = g_dir_read_name (dir_videos)) != NULL)
   {
@@ -424,8 +425,8 @@
   g_list_free (files_list);
   g_dir_close (dir_videos);
   
-  //delete all videos
-  path_photos = cheese_fileutil_get_photo_path ();
+  //delete all photos
+  path_photos = cheese_fileutil_get_photo_path (cheese_window->fileutil);
   dir_photos = g_dir_open (path_photos, 0, NULL);
   while ((name = g_dir_read_name (dir_photos)) != NULL)
   {
@@ -851,7 +852,7 @@
 
   g_free (file);
 
-  cheese_window->photo_filename = cheese_fileutil_get_new_media_filename (WEBCAM_MODE_PHOTO);
+  cheese_window->photo_filename = cheese_fileutil_get_new_media_filename (cheese_window->fileutil, WEBCAM_MODE_PHOTO);
   cheese_webcam_take_photo (cheese_window->webcam, cheese_window->photo_filename);
 }
 
@@ -922,6 +923,7 @@
 cheese_window_action_button_clicked_cb (GtkWidget *widget, CheeseWindow *cheese_window)
 {
   char *str;
+  
 
   if (cheese_window->webcam_mode == WEBCAM_MODE_PHOTO)
   {
@@ -956,7 +958,7 @@
       gtk_label_set_use_markup (GTK_LABEL (cheese_window->label_take_photo), TRUE);
       gtk_image_set_from_stock (GTK_IMAGE (cheese_window->image_take_photo), GTK_STOCK_MEDIA_STOP, GTK_ICON_SIZE_BUTTON);
 
-      cheese_window->video_filename = cheese_fileutil_get_new_media_filename (WEBCAM_MODE_VIDEO);
+      cheese_window->video_filename = cheese_fileutil_get_new_media_filename (cheese_window->fileutil, WEBCAM_MODE_VIDEO);
       cheese_webcam_start_video_recording (cheese_window->webcam, cheese_window->video_filename);
 
       cheese_window->recording = TRUE;
@@ -1420,6 +1422,7 @@
   cheese_window->gconf = cheese_gconf_new ();
   cheese_window->audio_play_counter = 0;
   cheese_window->rand = g_rand_new ();
+  cheese_window->fileutil = cheese_fileutil_new ();
 
   cheese_window_create_window (cheese_window);
  

Modified: trunk/src/cheese.c
==============================================================================
--- trunk/src/cheese.c	(original)
+++ trunk/src/cheese.c	Sun May 18 16:27:00 2008
@@ -43,31 +43,39 @@
   static FILE *fp = NULL;
   GDir *dir;
   char *filename, *path;
+  
+  CheeseFileUtil *fileutil = cheese_fileutil_new ();
+  
 
   if (fp == NULL)
   {
-    path = cheese_fileutil_get_log_path ();
+    path = cheese_fileutil_get_log_path (fileutil);
+    g_object_unref (fileutil);
+    
     dir = g_dir_open (path, 0, NULL);
-    if (!dir)
+    if (!dir) {
       return;
-
+    }
+    
     filename = g_build_filename (path, "log", NULL);
-    fp = fopen(filename, "w");
+    fp = fopen (filename, "w");
 
-    g_free(filename);
+    g_free (filename);
   }
 
   if (fp)
-    fputs(string, fp);
+    fputs (string, fp);
 
   if (CheeseOptions.verbose)
     fprintf (stdout, "%s", string);
+    
 }
 
 int
 main (int argc, char **argv)
 {
   GOptionContext *context;
+  
   GOptionEntry options[] = {
     { "verbose", 'v', 0, G_OPTION_ARG_NONE, &CheeseOptions.verbose, _("Be verbose"), NULL},
     { "hal-device", 'd', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &CheeseOptions.hal_device_id, NULL, NULL},



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