[gthumb] Added a function to check existence of local_path and issue warnings



commit f05e506c827bd6b9c9907bb7d00a503c32f681ae
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Thu May 7 08:16:59 2009 -0400

    Added a function to check existence of local_path and issue warnings
---
 libgthumb/file-data.c      |   12 ++++++++++++
 libgthumb/file-data.h      |    1 +
 libgthumb/gth-exif-utils.c |    8 +++-----
 src/dlg-photo-importer.c   |    4 ++--
 src/main.c                 |   10 +++++++++-
 5 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/libgthumb/file-data.c b/libgthumb/file-data.c
index 8e60a2b..7772feb 100644
--- a/libgthumb/file-data.c
+++ b/libgthumb/file-data.c
@@ -357,3 +357,15 @@ file_data_list_find_path (GList      *list,
 	return NULL;
 }
 
+
+gboolean
+file_data_has_local_path (FileData *fd)
+{
+	/* TODO: this is where we could trying mounting unmounted remote URIs */
+        if (fd->local_path == NULL) {
+                g_warning ("%s has not been mounted, or the gvfs daemon has not provided a local mount point in ~/.gvfs/. gThumb can not access this remote file directly.", fd->utf8_path);
+                return FALSE;
+        } else {
+		return TRUE;
+	}
+}
diff --git a/libgthumb/file-data.h b/libgthumb/file-data.h
index f0458fe..3901563 100644
--- a/libgthumb/file-data.h
+++ b/libgthumb/file-data.h
@@ -83,5 +83,6 @@ GList*       file_data_list_dup            (GList            *list);
 void         file_data_list_free           (GList            *list);
 GList*       file_data_list_find_path      (GList            *list,
 					    const char       *path);
+gboolean     file_data_has_local_path      (FileData         *fd);
 
 #endif /* FILE_DATA_H */
diff --git a/libgthumb/gth-exif-utils.c b/libgthumb/gth-exif-utils.c
index 4cb41e7..fc5dcd8 100644
--- a/libgthumb/gth-exif-utils.c
+++ b/libgthumb/gth-exif-utils.c
@@ -434,10 +434,10 @@ update_and_save_metadata (const char *uri_src,
 	from_fd = file_data_new (uri_src);
 	to_fd = file_data_new (uri_dest);
 
-	if ((from_fd->local_path == NULL) || (to_fd->local_path == NULL)) {
+	if (!file_data_has_local_path (from_fd) || 
+	    !file_data_has_local_path (to_fd)) {
 		file_data_unref (from_fd);
 		file_data_unref (to_fd);
-		g_warning ("Can't write metadata if the remote files are not mounted locally.");
 		return;
 	}
 
@@ -514,10 +514,8 @@ update_metadata (FileData *fd)
 	if (fd->exif_data_loaded == TRUE)
 		return;
 
-	if (fd->local_path == NULL) {
-                g_warning ("Can't read metadata if the remote files are not mounted locally.");
+	if (!file_data_has_local_path (fd))
                 return;	
-	}
 	
 	if (fd->mime_type == NULL)
 		file_data_update_mime_type (fd, FALSE);
diff --git a/src/dlg-photo-importer.c b/src/dlg-photo-importer.c
index c074fe4..38921ac 100644
--- a/src/dlg-photo-importer.c
+++ b/src/dlg-photo-importer.c
@@ -1292,7 +1292,7 @@ save_image (DialogData *data,
 
 	folder_fd = file_data_new (local_folder);
 
-	if (folder_fd->local_path == NULL) {
+	if (!file_data_has_local_path (folder_fd)) {
 		error_found = TRUE;
 	} else {
 		/* When grouping by exif date, we need a temporary directory to upload the
@@ -1765,7 +1765,7 @@ ok_clicked_cb (GtkButton  *button,
 	}
 
 	folder_fd = file_data_new (data->local_folder);
-	if ((folder_fd->local_path==NULL) || !ensure_dir_exists (folder_fd->local_path, 0755)) {
+	if (!file_data_has_local_path (folder_fd) || !ensure_dir_exists (folder_fd->local_path, 0755)) {
 		char *msg;
 		msg = g_strdup_printf (_("Could not create the folder \"%s\": %s"),
 				       folder_fd->utf8_name,
diff --git a/src/main.c b/src/main.c
index 110b06e..535c27f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -455,10 +455,18 @@ initialize_data (void)
 		GFile     *gfile;
 		GFileType  file_type;
 		GFileInfo *file_info;
+		GError    *error = NULL;
 
 		gfile = g_file_new_for_commandline_arg (filename);
 		path = g_file_get_uri (gfile);
-		file_info = g_file_query_info (gfile, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
+		file_info = g_file_query_info (gfile, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, &error);
+		if (error != NULL) {
+			g_object_unref (gfile);
+			g_warning ("Error loading %s from command line argument: %s", filename, error->message);
+			g_error_free (error);
+			continue;
+		}
+
 		file_type = g_file_info_get_file_type (file_info);
 		g_object_unref (file_info);
 



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