gthumb r2392 - in trunk: . libgthumb src



Author: mjc
Date: Mon Aug 11 12:38:04 2008
New Revision: 2392
URL: http://svn.gnome.org/viewvc/gthumb?rev=2392&view=rev

Log:
2008-08-11  Michael J. Chudobiak  <mjc svn gnome org>

        * libgthumb/file-utils.c: (dir_remove_recursive),
        (ensure_dir_exists), (xfer_file), (local_file_move), (file_rename),
        (path_is_file), (path_is_dir), (get_file_size),
        (get_destination_free_space):
        * libgthumb/gfile-utils.c: (gfile_debug), (gfile_warning),
        (gfile_new), (gfile_new_va), (gfile_append_path), (gfile_is_local),
        (gfile_get_home_dir), (gfile_get_tmp_dir),
        (gfile_make_temp_in_dir):
        * libgthumb/gfile-utils.h:
        * src/catalog-web-exporter.c: (gfile_get_style_dir),
        (catalog_web_exporter_finalize), (catalog_web_exporter_init),
        (catalog_web_exporter_set_style),
        (catalog_web_exporter_set_location), (get_album_file),
        (get_image_file), (export__save_other_files), (parse_theme_files),
        (ensure_album_dir_exists), (catalog_web_exporter_export):
        * src/catalog-web-exporter.h:
        More gfile migration by Christophe BisiÃre. Bug #525482. Most
        notably, added gfile_new and gfile_new_va to elegantly construct
        gfiles from paths / uris.



Modified:
   trunk/ChangeLog
   trunk/libgthumb/file-utils.c
   trunk/libgthumb/gfile-utils.c
   trunk/libgthumb/gfile-utils.h
   trunk/src/catalog-web-exporter.c
   trunk/src/catalog-web-exporter.h

Modified: trunk/libgthumb/file-utils.c
==============================================================================
--- trunk/libgthumb/file-utils.c	(original)
+++ trunk/libgthumb/file-utils.c	Mon Aug 11 12:38:04 2008
@@ -422,17 +422,14 @@
 {
 	GFile    *file;
 	gboolean  result;
-	char     *uri;
 	
 	if (path == NULL)
 		return FALSE;
 	
-	uri = add_scheme_if_absent (path);
-	file = g_file_new_for_uri (uri);
+	file = gfile_new (path);
 	
 	result = gfile_dir_remove_recursive (file);
 	
-	g_free (uri);
 	g_object_unref (file);
 
 	return result;
@@ -452,17 +449,14 @@
 {
 	GFile    *file;
 	gboolean  result;
-	char     *uri;
 	
 	if (path == NULL)
 		return FALSE;
 	
-	uri = add_scheme_if_absent (path);
-	file = g_file_new_for_uri (uri);
+	file = gfile_new (path);
 	
 	result = gfile_ensure_dir_exists (file, mode, NULL);
 	
-	g_free (uri);
 	g_object_unref (file);
 
 	return result;
@@ -743,7 +737,6 @@
 	   const char *to,
 	   gboolean    move)
 {
-	GnomeVFSURI   *from_uri, *to_uri;
 	GError        *ioerror = NULL;
 	GFile         *sfile, *dfile;
 
@@ -752,11 +745,8 @@
 		return FALSE;
 	}
 
-	from_uri = new_uri_from_path (from);
-	to_uri = new_uri_from_path (to);
-
-	sfile = g_file_new_for_uri (gnome_vfs_uri_get_path (from_uri));
-	dfile = g_file_new_for_uri (gnome_vfs_uri_get_path (to_uri));
+	sfile = gfile_new (from);
+	dfile = gfile_new (to);
 	if (move)
 		g_file_move (sfile, dfile,
 			     G_FILE_COPY_OVERWRITE,
@@ -770,8 +760,6 @@
 
 	g_object_unref (sfile);
 	g_object_unref (dfile);
-	g_free (from_uri);
-	g_free (to_uri);
 	
 	if (ioerror) {
 		g_error_free (ioerror);
@@ -801,32 +789,20 @@
 local_file_move (const char *from,
 	         const char *to)
 {
-	char     *from_uri;
-	char     *to_uri;
-	gboolean  result;
-	
-	from_uri = get_uri_from_local_path (from);
-	to_uri = get_uri_from_local_path (to);
-	
-	result = xfer_file (from_uri, to_uri, TRUE);
-	
-	g_free (from_uri);
-	g_free (to_uri);
-	
-	return result;
+	return xfer_file (from, to, TRUE);
 }
 
 
 gboolean 
-file_rename (const char *old_path,
-	     const char *new_path,
-	     GError **error)
+file_rename (const char  *old_path,
+	     const char  *new_path,
+	     GError     **error)
 {
 	GFile *sfile, *dfile;
 	GError *err = NULL;
 	gboolean result;
-	sfile = g_file_new_for_uri (old_path);
-	dfile = g_file_new_for_uri (new_path);
+	sfile = gfile_new (old_path);
+	dfile = gfile_new (new_path);
 
 	result = g_file_move (sfile, dfile,
                               G_FILE_COPY_OVERWRITE,
@@ -1049,17 +1025,14 @@
 {
 	GFile    *file;
 	gboolean  result;
-	char     *uri;
 	
 	if (path == NULL)
 		return FALSE;
 	
-	uri = add_scheme_if_absent (path);
-	file = g_file_new_for_uri (uri);
+	file = gfile_new (path);
 	
 	result = gfile_path_is_file (file);
 	
-	g_free (uri);
 	g_object_unref (file);
 
 	return result;
@@ -1070,17 +1043,14 @@
 {
 	GFile    *file;
 	gboolean  result;
-	char     *uri;
 	
 	if (path == NULL)
 		return FALSE;
 
-	uri = add_scheme_if_absent (path);
-	file = g_file_new_for_uri (uri);
+	file = gfile_new (path);
 
 	result = gfile_path_is_dir (file);
 	
-	g_free (uri);
 	g_object_unref (file);
 
 	return result;
@@ -1092,17 +1062,14 @@
 {
 	GFile    *file;
 	goffset   result;
-	char     *uri;
 	
 	if (path == NULL)
 		return 0;
 
-	uri = add_scheme_if_absent (path);
-	file = g_file_new_for_uri (uri);
+	file = gfile_new (path);
 
 	result = gfile_get_file_size (file);
 	
-	g_free (uri);
 	g_object_unref (file);
 
 	return result;
@@ -2670,17 +2637,14 @@
 {
 	GFile    *file;
 	gboolean  result;
-	char     *uri;
 	
 	if (path == NULL)
-		return FALSE;
+		return 0;
 	
-	uri = add_scheme_if_absent (path);
-	file = g_file_new_for_uri (uri);
+	file = gfile_new (path);
 
 	result = gfile_get_destination_free_space (file);
 	
-	g_free (uri);
 	g_object_unref (file);
 
 	return result;

Modified: trunk/libgthumb/gfile-utils.c
==============================================================================
--- trunk/libgthumb/gfile-utils.c	(original)
+++ trunk/libgthumb/gfile-utils.c	Mon Aug 11 12:38:04 2008
@@ -22,6 +22,7 @@
 
 
 #include <stdlib.h>
+#include <string.h>
 #include <glib.h>
 
 #include "gfile-utils.h"
@@ -56,7 +57,31 @@
 }
 
 
-/* warning about a GFile */
+/* Debug */
+
+void 
+gfile_debug (const char *cfile,
+	     int         line,
+	     const char *function,
+	     const char *msg,
+	     GFile      *file)
+{
+	char *uri;
+	char *dbg;
+	
+	if (file == NULL)
+		uri = g_strdup ("(null)");
+	else
+		uri = gfile_get_uri (file);
+	
+	dbg = g_strdup_printf ("%s: %s\n", msg, uri);
+	
+	debug (cfile, line, function, dbg);
+	
+        g_free (uri);
+        g_free (dbg);
+}
+
 
 void 
 gfile_warning (const char *msg,
@@ -72,11 +97,104 @@
 	g_warning (warning);
 	
         g_free (uri);
+        g_free (warning);
+}
+
+
+/* Constructor enforcing the "uri only" GFile policy */
+
+GFile *
+gfile_new (const char *path)
+{
+	GFile *file;
+	char  *uri;
+	
+	g_assert (path != NULL);
+	
+	if (strstr (path, "://") == NULL)
+		uri = g_strconcat ("file://", path, NULL);
+	else
+		uri = g_strdup (path);
+
+	file = g_file_new_for_uri (uri);
+	
+	g_free (uri);
+	
+	return file;
+}
+
+
+GFile *
+gfile_new_va (const char *path,
+              ...)
+{
+	va_list  args;
+	GFile   *file;
+	char    *pathx;
+	
+	g_assert (path != NULL);
+	
+	file = gfile_new (path);
+	
+	va_start (args, path);
+	
+	while ((pathx = va_arg (args, char*)) != NULL) {
+		GFile *tmp;
+		
+		tmp = g_file_dup (file);
+		g_object_unref (file);
+		
+		file = g_file_resolve_relative_path (tmp, pathx);
+		g_object_unref (tmp);
+	}
+	
+	va_end (args);
+
+	return file;
 }
 
 
 /* File utils */
 
+GFile *
+gfile_append_path (GFile      *dir,
+		   const char *path,
+                   ...)
+{
+	va_list  args;
+	GFile   *file;
+	char    *pathx;
+	
+	if (path == NULL)
+		return g_file_dup (dir);
+	
+	file = g_file_resolve_relative_path (dir, path);
+	
+	va_start (args, path);
+	
+	while ((pathx = va_arg (args, char*)) != NULL) {
+		GFile *tmp;
+		
+		tmp = g_file_dup (file);
+		g_object_unref (file);
+
+		file = g_file_resolve_relative_path (tmp, pathx);
+		g_object_unref (tmp);
+	}
+	
+	va_end (args);
+
+	return file;
+}
+
+
+gboolean
+gfile_is_local (GFile *file)
+{
+	return g_file_has_uri_scheme (file, "file");
+}
+
+
 static gboolean
 gfile_is_filetype (GFile      *file,
 		   GFileType   file_type)
@@ -210,13 +328,6 @@
 }
 
 
-gboolean
-gfile_is_local (GFile *file)
-{
-	return g_file_has_uri_scheme (file, "file");
-}
-
-
 guint64
 gfile_get_destination_free_space (GFile *file)
 {
@@ -248,12 +359,8 @@
 gfile_get_home_dir (void)
 {
 	GFile *dir;
-	char  *path;
 	
-	path = g_strconcat ("file://", g_get_home_dir (), NULL);
-	dir = g_file_new_for_uri (path);
-	
-	g_free (path);
+	dir = gfile_new (g_get_home_dir ());
 	
 	return dir;
 }
@@ -263,12 +370,8 @@
 gfile_get_tmp_dir (void)
 {
 	GFile *dir;
-	char  *path;
-	
-	path = g_strconcat ("file://", g_get_tmp_dir (), NULL);
-	dir = g_file_new_for_uri (path);
 	
-	g_free (path);
+	dir = gfile_new (g_get_tmp_dir ());
 	
 	return dir;
 }
@@ -295,7 +398,6 @@
 {
 	char  *path0;
 	char  *path1;
-	char  *path2;
 	char  *template;
 	GFile *dir;
 	
@@ -308,11 +410,9 @@
 	if (path1 == NULL)
 		return NULL;
 	
-	path2 = g_strconcat ("file://", path1, NULL);
-	dir = g_file_new_for_uri (path2);
+	dir = gfile_new (path1);
 	
 	g_free (path1);
-	g_free (path2);
 	
 	return dir;
 }

Modified: trunk/libgthumb/gfile-utils.h
==============================================================================
--- trunk/libgthumb/gfile-utils.h	(original)
+++ trunk/libgthumb/gfile-utils.h	Mon Aug 11 12:38:04 2008
@@ -24,6 +24,7 @@
 #define GFILE_UTILS_H
 
 #include <gio/gio.h>
+#include "glib-utils.h"
 
 
 #define UNREF(obj) {				\
@@ -42,13 +43,29 @@
 char *        gfile_get_uri                    (GFile *file);
 char *        gfile_get_path                   (GFile *file);
 
-/* Warning */
+/* Debug */
 
+void          gfile_debug                      (const char *cfile,
+					        int         line,
+						const char *function,
+						const char *msg,
+	                                        GFile      *file);
 void          gfile_warning                    (const char *msg,
 	                                        GFile      *file,
 	                                        GError     *err);
+/* Constructors */
+
+GFile *       gfile_new                        (const char *path);
+GFile *       gfile_new_va                     (const char *path,
+                                                ...);
+
 /* File utils */
 
+GFile *       gfile_append_path                (GFile      *dir,
+		                                const char *path,
+                                                ...);
+
+gboolean      gfile_is_local                   (GFile      *file);
 gboolean      gfile_path_is_file               (GFile      *file);
 gboolean      gfile_path_is_dir                (GFile      *file);
 goffset       gfile_get_file_size              (GFile      *file);
@@ -59,6 +76,8 @@
 			                        mode_t      mode,
 			                        GError    **error);
 guint64       gfile_get_destination_free_space (GFile      *file);
+GFile *       gfile_get_home_dir               (void);
+GFile *       gfile_get_tmp_dir                (void);
 GFile *       gfile_get_temp_dir_name          (void);
 gboolean      gfile_dir_remove_recursive       (GFile *dir);
 

Modified: trunk/src/catalog-web-exporter.c
==============================================================================
--- trunk/src/catalog-web-exporter.c	(original)
+++ trunk/src/catalog-web-exporter.c	Mon Aug 11 12:38:04 2008
@@ -301,6 +301,43 @@
 }
 
 
+static GFile *
+gfile_get_style_dir (CatalogWebExporter *ce,
+		     const char         *style)
+{
+	GFile *dir;
+	GFile *style_dir;
+
+	if (style == NULL)
+		return NULL;
+	
+	dir = gfile_get_home_dir ();
+	style_dir = gfile_append_path (dir,
+			               ".gnome2",
+			               "gthumb",
+			               "albumthemes",
+			               style,
+			               NULL);
+ 	g_object_unref (dir);
+ 	
+	if (! gfile_path_is_dir (style_dir)) {
+		g_object_unref (style_dir);
+
+		style_dir = gfile_new_va (GTHUMB_DATADIR,
+				          "gthumb",
+				          "albumthemes",
+				          style,
+				          NULL);
+		if (! gfile_path_is_dir (style_dir)) {
+			g_object_unref (style_dir);
+			style_dir = NULL;
+		}
+	}
+
+	return style_dir;
+}
+
+
 static void
 catalog_web_exporter_finalize (GObject *object)
 {
@@ -316,8 +353,7 @@
 	g_free (ce->footer);
 	ce->footer = NULL;
 
-	g_free (ce->style);
-	ce->style = NULL;
+	UNREF (ce->style_dir)
 
 	g_free (ce->base_dir);     /* NOTE: gio port: get rid of these two */
 	g_free (ce->base_tmp_dir);
@@ -406,7 +442,7 @@
 {
 	ce->header = NULL;
 	ce->footer = NULL;
-	ce->style = NULL;
+	ce->style_dir = NULL;
 
 	ce->base_dir = NULL;     /* NOTE: gio port: get rid of these two */
 	ce->base_tmp_dir = NULL;
@@ -518,8 +554,8 @@
 				const char         *style)
 {
 	g_return_if_fail (IS_CATALOG_WEB_EXPORTER (ce));
-	g_free (ce->style);
-	ce->style = g_strdup (style);
+	UNREF (ce->style_dir)
+	ce->style_dir = gfile_get_style_dir (ce, style);
 }
 
 
@@ -529,7 +565,7 @@
 {
 	g_return_if_fail (IS_CATALOG_WEB_EXPORTER (ce));
 	UNREF (ce->target_dir)
-	ce->target_dir = g_file_new_for_uri (location);
+	ce->target_dir = gfile_new (location);
 }
 
 
@@ -1128,42 +1164,7 @@
 }
 
 
-
-/* build a GFile (helpers) */
-
-GFile *
-file_resolve_relative_path (GFile	*file,
-			    const char  *relative_path)
-{
-	GFile *result;
-	
-	if (relative_path != NULL)
-		result = g_file_resolve_relative_path (file, relative_path);
-	else
-		result = g_file_dup (file);
-	
-	return result;
-}
-
-
-GFile *
-get_filename (GFile              *dir,
-	      const char         *subdir,
-	      const char         *filename)
-{
-	GFile *file, *result;
-	
-	file = file_resolve_relative_path (dir, subdir);
-	result = file_resolve_relative_path (file, filename);
-
-	g_object_unref (file);
-	
-	return result;
-}
-
-
-/* build a GFile for a CatalogWebExporter */
-
+/* construct a GFile for a CatalogWebExporter */
 
 GFile *
 get_album_file (CatalogWebExporter *ce,
@@ -1171,9 +1172,19 @@
 		const char         *subdir,
 		const char         *filename)
 {
-	return get_filename (target_dir, 
-			     (ce->use_subfolders ? subdir : NULL),
-			     filename);
+
+	GFile *dir, *file;
+
+	dir = gfile_append_path (target_dir, 
+			         (ce->use_subfolders ? subdir : NULL),
+			         NULL);
+	file = gfile_append_path (dir, 
+				  filename,
+				  NULL);
+
+	g_object_unref (dir);
+
+	return file;
 }
 
 
@@ -1293,7 +1304,7 @@
 		g_free (escaped);
 
 	} else {
-		result = g_file_new_for_uri (idata->src_file->path);
+		result = gfile_new (idata->src_file->path);
 	}
 	
 	return result;
@@ -2099,46 +2110,6 @@
 }
 
 
-static char *
-get_style_dir (CatalogWebExporter *ce)
-{
-	char *path;
-	char *uri;
-	char *style_dir;
-
-	style_dir = g_uri_unescape_string (ce->style, NULL);
-	
-	path = g_build_filename (g_get_home_dir (),
-			         ".gnome2",
-			         "gthumb",
-			         "albumthemes",
-			         style_dir,
-			         NULL);
-	uri = get_uri_from_local_path (path);
- 	g_free (path);
-
-	if (!path_is_dir (uri)) {
-		g_free (uri);
-
-		path = g_build_filename (GTHUMB_DATADIR,
-				         "gthumb",
-				         "albumthemes",
-				         style_dir,
-				         NULL);
-		uri = get_uri_from_local_path (path);
- 		g_free (path);
-
-		if (!path_is_dir (uri)) {
-			g_free (uri);
-			uri = NULL;
-		}
-	}
-
-	g_free (style_dir);
-	return uri;
-}
-
-
 static int
 export__save_other_files__progress_update_cb (GnomeVFSXferProgressInfo *info,
 					      gpointer                  data)
@@ -2166,14 +2137,12 @@
 {
 	GnomeVFSResult  result;
 	GList          *file_list = NULL;
-	char           *source_dir;
-
-	source_dir = get_style_dir (ce);
-
-	if (source_dir != NULL)
-		result = gnome_vfs_directory_list_load (&file_list, source_dir, GNOME_VFS_FILE_INFO_DEFAULT);
-	else
-		result = GNOME_VFS_ERROR_NOT_A_DIRECTORY;
+	char           *uri;
+		
+	uri = gfile_get_uri (ce->style_dir);
+	result = gnome_vfs_directory_list_load (&file_list, uri, GNOME_VFS_FILE_INFO_DEFAULT);
+		
+	g_free (uri);
 
 	if (result == GNOME_VFS_OK) {
 		GList *scan;
@@ -2181,8 +2150,8 @@
 
 		for (scan = file_list; scan; scan = scan->next) {
 			GnomeVFSFileInfo *info = scan->data;
-			char		 *source_filename, *uri;
-			GFile            *file;
+			char		 *target_filename, *source_filename;
+			GFile            *source_file, *target_file;
 			GnomeVFSURI	 *source_uri = NULL, *target_uri = NULL;
 
 			if (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
@@ -2193,25 +2162,28 @@
 			    || (strcmp (info->name, "image.gthtml") == 0))
 				continue;
 
-			source_filename = g_build_filename (source_dir,
-							    info->name,
-							    NULL);
-			source_uri = new_uri_from_path (source_filename);
+			source_file = gfile_append_path (ce->style_dir,
+							 info->name,
+							 NULL);
+			target_file = get_theme_file (ce, 
+					              ce->target_tmp_dir,
+					              info->name);
+
+			source_filename = gfile_get_uri (source_file);
+			source_uri = gnome_vfs_uri_new (source_filename);
 			
-			file = get_theme_file (ce, 
-					       ce->target_tmp_dir,
-					       info->name);
-			uri = gfile_get_uri (file);
-			target_uri = gnome_vfs_uri_new (uri);
+			target_filename = gfile_get_uri (target_file);
+			target_uri = gnome_vfs_uri_new (target_filename);
 			
 			source_uri_list = g_list_prepend (source_uri_list, source_uri);
 			target_uri_list = g_list_prepend (target_uri_list, target_uri);
 
-			debug (DEBUG_INFO, "save file: %s", source_filename);
+			gfile_debug (DEBUG_INFO, "save file", source_file);
 
 			g_free (source_filename);
-			g_free (uri);
-			g_object_unref (file);
+			g_free (target_filename);
+			g_object_unref (source_file);
+			g_object_unref (target_file);
 		}
 		
 		if (source_uri_list != NULL) {
@@ -2242,8 +2214,6 @@
 
 	if (file_list != NULL)
 		gnome_vfs_file_info_list_free (file_list);
-	g_free (source_dir);
-
 }
 
 
@@ -2853,30 +2823,25 @@
 static void
 parse_theme_files (CatalogWebExporter *ce)
 {
-	char  *style_dir;
-	char  *template_uri;
+	GFile *template;
 	char  *local_file;
 	GList *scan;
 
 	free_parsed_docs (ce);
 
-	style_dir = get_style_dir (ce);
-
-	debug (DEBUG_INFO, "style dir: %s", style_dir);
-
 	ce->image = 0;
 
 	/* read and parse index.gthtml */
 
 	yy_parsed_doc = NULL;
-	template_uri = build_uri (style_dir, 
-				  "index.gthtml",
-				  NULL);
-	local_file = get_local_path_from_uri (template_uri);
-
-	debug (DEBUG_INFO, "load %s", local_file);
-
+	template = gfile_append_path (ce->style_dir, 
+				      "index.gthtml",
+				      NULL);
+	gfile_debug (DEBUG_INFO, "load", template);
+	
+	local_file = gfile_get_path (template);
 	yyin = fopen (local_file, "r");
+	
 	if ((yyin != NULL) && (yyparse () == 0))
 		ce->index_parsed = yy_parsed_doc;
 	else
@@ -2890,20 +2855,20 @@
 		ce->index_parsed = g_list_prepend (NULL, tag);
 	}
 
-	g_free (template_uri);
+	g_object_unref (template);
 	g_free (local_file);
 
 	/* read and parse thumbnail.gthtml */
 
 	yy_parsed_doc = NULL;
-	template_uri = build_uri (style_dir, 
-				  "thumbnail.gthtml",
-				  NULL);
-	local_file = get_local_path_from_uri (template_uri);
+	template = gfile_append_path (ce->style_dir, 
+				      "thumbnail.gthtml",
+				      NULL);
+	gfile_debug (DEBUG_INFO, "load", template);
 	
-	debug (DEBUG_INFO, "load %s", local_file);
- 
+	local_file = gfile_get_path (template);
 	yyin = fopen (local_file, "r");
+	
 	if ((yyin != NULL) && (yyparse () == 0))
 		ce->thumbnail_parsed = yy_parsed_doc;
 	else
@@ -2932,20 +2897,20 @@
 		ce->thumbnail_parsed = g_list_prepend (NULL, tag);
 	}
 
-	g_free (template_uri);
+	g_object_unref (template);
 	g_free (local_file);
 
 	/* Read and parse image.gthtml */
 
 	yy_parsed_doc = NULL;
-	template_uri = build_uri (style_dir, 
-				  "image.gthtml",
-				  NULL);
-	local_file = get_local_path_from_uri (template_uri);
-	
-	debug (DEBUG_INFO, "load %s", local_file);
+	template = gfile_append_path (ce->style_dir, 
+				      "image.gthtml",
+				      NULL);
+	gfile_debug (DEBUG_INFO, "load", template);
 	
+	local_file = gfile_get_path (template);	
 	yyin = fopen (local_file, "r");
+	
 	if ((yyin != NULL) && (yyparse () == 0))
 		ce->image_parsed = yy_parsed_doc;
 	else
@@ -2974,10 +2939,9 @@
 		ce->image_parsed = g_list_prepend (NULL, tag);
 	}
 
-	g_free (template_uri);
+	g_object_unref (template);
 	g_free (local_file);
-	g_free (style_dir);
-
+	
 	/* read index.html and set variables. */
 
 	for (scan = ce->index_parsed; scan; scan = scan->next) {
@@ -3032,7 +2996,7 @@
 	gboolean  ok;
 	GFile    *dir;
 	
-	dir = file_resolve_relative_path (target_dir, subdir);
+	dir = gfile_append_path (target_dir, subdir, NULL);
 	
 	ok = gfile_ensure_dir_exists (dir, 0700, NULL);
 	
@@ -3070,6 +3034,20 @@
 		return;
 	ce->exporting = TRUE;
 
+	/* 
+	 * check that the style directory is not NULL. A NULL indicates that
+	 * the folder of the selected style has been deleted or renamed 
+	 * before the user started the export. It is unlikely.
+	 */
+	
+	if (ce->style_dir == NULL) {
+		_gtk_error_dialog_run (GTK_WINDOW (ce->window), _("Could not find the style folder"));
+		g_signal_emit (G_OBJECT (ce), catalog_web_exporter_signals[WEB_EXPORTER_DONE], 0);
+		return;
+	}
+	
+	gfile_debug (DEBUG_INFO, "style dir", ce->style_dir);
+	
 	/* get index file name and subdirs from gconf (hidden prefs) */
 
 	g_free (ce->index_file);
@@ -3090,14 +3068,9 @@
 		g_signal_emit (G_OBJECT (ce), catalog_web_exporter_signals[WEB_EXPORTER_DONE], 0);
 		return;
 	}
-	else {
-		char	*tmp_dir;
-		
-		tmp_dir = gfile_get_path (ce->target_tmp_dir);
-		debug (DEBUG_INFO, "temp dir: %s", tmp_dir);
-		g_free (tmp_dir);
-	}
-
+	
+	gfile_debug (DEBUG_INFO, "temp dir", ce->target_tmp_dir);
+	
 	/* compute n_images, n_pages */
 	
 	ce->n_images = g_list_length (ce->file_list);
@@ -3111,7 +3084,7 @@
 	}
 
 	/* parse .gthtml files */
-		
+
 	parse_theme_files (ce);
 
 	debug (DEBUG_INFO, "thumb size: %dx%d", ce->thumb_width, ce->thumb_height);

Modified: trunk/src/catalog-web-exporter.h
==============================================================================
--- trunk/src/catalog-web-exporter.h	(original)
+++ trunk/src/catalog-web-exporter.h	Mon Aug 11 12:38:04 2008
@@ -63,7 +63,7 @@
 
 	char         *header;
 	char         *footer;
-	char         *style;
+	GFile        *style_dir;
 
 	int           page_rows;              /* Number of rows and columns
 	 				       * each page must have. */



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