[gthumb] Complete purged FileData->path and ->name



commit 0eff059888f4b17f8ab5018775861f781644c9ef
Author: mjclab <mjclab pekkala localdomain>
Date:   Fri May 29 15:45:08 2009 -0400

    Complete purged FileData->path and ->name
    
    Use utf8_path and utf8_name now.
---
 libgthumb/file-data.c            |   24 +++++----------
 libgthumb/file-data.h            |    2 -
 libgthumb/file-utils.c           |    2 +-
 libgthumb/gth-file-view-list.c   |    2 +-
 libgthumb/gth-file-view-thumbs.c |    2 +-
 src/catalog-list.c               |    5 +--
 src/catalog-web-exporter.c       |    5 ++-
 src/dlg-convert.c                |    2 +-
 src/dlg-rename-series.c          |   10 +++---
 src/gth-batch-op.c               |    4 +-
 src/gth-browser.c                |   58 +++++++++++++++++++-------------------
 11 files changed, 52 insertions(+), 64 deletions(-)

diff --git a/libgthumb/file-data.c b/libgthumb/file-data.c
index da2f0a2..369eaa5 100644
--- a/libgthumb/file-data.c
+++ b/libgthumb/file-data.c
@@ -66,7 +66,7 @@ load_info (FileData *fd)
 	char      *resolved_path;
 
 	g_free (fd->local_path);
-	gfile = gfile_new (fd->path);
+	gfile = gfile_new (fd->utf8_path);
 	fd->local_path = g_file_get_path (gfile);
 
 	if ( (fd->local_path != NULL) &&
@@ -81,7 +81,7 @@ load_info (FileData *fd)
 
 	g_free (fd->uri);
 
-	resolved_path = resolve_all_symlinks (fd->path);
+	resolved_path = resolve_all_symlinks (fd->utf8_path);
 	gfile_resolved = gfile_new (resolved_path);
 	fd->uri = g_file_get_uri (gfile_resolved);
 	g_object_unref (gfile_resolved);
@@ -130,9 +130,7 @@ file_data_new (const char *path)
 	fd = g_new0 (FileData, 1);
 
 	fd->ref = 1;
-	fd->path = add_scheme_if_absent (path);
-	fd->name = file_name_from_path (fd->path);
-	fd->utf8_path = get_utf8_display_name_from_uri (fd->path);
+	fd->utf8_path = get_utf8_display_name_from_uri (path);
 	fd->utf8_name = file_name_from_path (fd->utf8_path);
 
 	load_info (fd);
@@ -173,8 +171,6 @@ file_data_dup (FileData *source)
 	fd = g_new0 (FileData, 1);
 
 	fd->ref = 1;
-	fd->path = g_strdup (source->path);
-	fd->name = file_name_from_path (fd->path);
         fd->utf8_path = g_strdup (source->utf8_path);
         fd->utf8_name = file_name_from_path (fd->utf8_path);
 	fd->local_path = g_strdup (source->local_path);
@@ -207,7 +203,6 @@ file_data_unref (FileData *fd)
 	fd->ref--;
 
 	if (fd->ref == 0) {
-		g_free (fd->path);
 		g_free (fd->utf8_path);
 		g_free (fd->local_path);
 		g_free (fd->uri);
@@ -229,7 +224,6 @@ file_data_update (FileData *fd)
 	fd->error = FALSE;
 	fd->thumb_loaded = FALSE;
 	fd->thumb_created = FALSE;
-	fd->name = file_name_from_path (fd->path);
         fd->utf8_name = file_name_from_path (fd->utf8_path);
 
 	load_info (fd);
@@ -242,7 +236,7 @@ void
 file_data_update_mime_type (FileData *fd,
 			    gboolean  fast_mime_type)
 {
-	fd->mime_type = get_file_mime_type (fd->path, fast_mime_type || ! is_local_file (fd->path));
+	fd->mime_type = get_file_mime_type (fd->utf8_path, fast_mime_type || ! is_local_file (fd->utf8_path));
 }
 
 
@@ -262,10 +256,8 @@ file_data_set_path (FileData   *fd,
 	g_return_if_fail (fd != NULL);
 	g_return_if_fail (path != NULL);
 
-	g_free (fd->path);
-	fd->path = add_scheme_if_absent (path);
 	g_free (fd->utf8_path);
-        fd->utf8_path = get_utf8_display_name_from_uri (fd->path);
+        fd->utf8_path = get_utf8_display_name_from_uri (path);
 
 	file_data_update (fd);
 }
@@ -281,7 +273,7 @@ file_data_update_comment (FileData *fd)
 	if (fd->comment_data != NULL)
 		comment_data_free (fd->comment_data);
 
-	fd->comment_data = comments_load_comment (fd->path, FALSE);
+	fd->comment_data = comments_load_comment (fd->utf8_path, FALSE);
 
 	if (fd->comment_data == NULL) {
                 fd->comment_data = comment_data_new ();
@@ -322,7 +314,7 @@ uri_list_from_file_data_list (GList *list)
 	
 	for (scan = list; scan; scan = scan->next) {
 		FileData *fd = scan->data;
-		result = g_list_prepend (result, g_strdup (fd->path));
+		result = g_list_prepend (result, g_strdup (fd->utf8_path));
 	}
 	
 	return g_list_reverse (result);	
@@ -435,7 +427,7 @@ file_data_get_comment (FileData *fd,
 	g_return_val_if_fail (fd != NULL, NULL);
 
 	if (!fd->comment_data)
-                fd->comment_data = comments_load_comment (fd->path, try_embedded);
+                fd->comment_data = comments_load_comment (fd->utf8_path, try_embedded);
 
 	if (!fd->comment_data)
                 fd->comment_data = comment_data_new ();
diff --git a/libgthumb/file-data.h b/libgthumb/file-data.h
index 11a92ec..a55ce83 100644
--- a/libgthumb/file-data.h
+++ b/libgthumb/file-data.h
@@ -33,8 +33,6 @@
 typedef struct {
 	guint               ref : 8;
 
-	char               *path;          /* Full path name, may be escaped or unescaped. */
-	const char         *name;          /* File name only, may be escaped on unescaped. */
 	char               *utf8_path;	   /* Full path name, always unescaped UTF8 */
 	const char	   *utf8_name;     /* File name only, always unescaped UTF8 */
 	char		   *local_path;    /* May be a gvfs mount point */
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index dbd1e34..8452655 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -396,7 +396,7 @@ file_filter (FileData *file,
 	if (file->mime_type == NULL)
 		return FALSE;
 
-	if (! show_hidden_files && file_is_hidden (file->name))
+	if (! show_hidden_files && file_is_hidden (file->utf8_name))
 		return FALSE;
 		
 	if (show_only_images && ! mime_type_is_image (file->mime_type))
diff --git a/libgthumb/gth-file-view-list.c b/libgthumb/gth-file-view-list.c
index 4fef5db..cef1194 100644
--- a/libgthumb/gth-file-view-list.c
+++ b/libgthumb/gth-file-view-list.c
@@ -1559,7 +1559,7 @@ comp_func_name (gconstpointer  ptr1,
 	if ((fd1 == NULL) || (fd2 == NULL))
 		return 0;
 
-	return gth_sort_by_filename_but_ignore_path (fd1->name, fd2->name);
+	return gth_sort_by_filename_but_ignore_path (fd1->utf8_path, fd2->utf8_path);
 }
 
 
diff --git a/libgthumb/gth-file-view-thumbs.c b/libgthumb/gth-file-view-thumbs.c
index 797a40e..51685b3 100644
--- a/libgthumb/gth-file-view-thumbs.c
+++ b/libgthumb/gth-file-view-thumbs.c
@@ -574,7 +574,7 @@ comp_func_name (gconstpointer  ptr1,
 	if ((fd1 == NULL) || (fd2 == NULL))
 		return 0;
 
-	return gth_sort_by_filename_but_ignore_path (fd1->name, fd2->name);
+	return gth_sort_by_filename_but_ignore_path (fd1->utf8_path, fd2->utf8_path);
 }
 
 
diff --git a/src/catalog-list.c b/src/catalog-list.c
index 2935bd9..a280491 100644
--- a/src/catalog-list.c
+++ b/src/catalog-list.c
@@ -577,7 +577,6 @@ catalog_list_refresh (CatalogList *cat_list)
 	if (! cat_list->dirs_only) {
 		for (scan = file_list; scan; scan = scan->next) {
 			FileData    *file = scan->data;
-			char        *name;
 			char        *utf8_name;
 			GtkTreeIter  iter;
 			GdkPixbuf   *pixbuf;
@@ -592,8 +591,7 @@ catalog_list_refresh (CatalogList *cat_list)
 				pixbuf = catalog_pixbuf;
 			}
 
-			name = remove_extension_from_path (file->name);
-			utf8_name = get_utf8_display_name_from_uri (name);
+			utf8_name = remove_extension_from_path (file->utf8_name);
 			
 			gtk_list_store_append (cat_list->list_store, &iter);
 			gtk_list_store_set (cat_list->list_store, &iter,
@@ -604,7 +602,6 @@ catalog_list_refresh (CatalogList *cat_list)
 					    -1);
 					    
 			g_free (utf8_name);
-			g_free (name);
 		}
 	}
 
diff --git a/src/catalog-web-exporter.c b/src/catalog-web-exporter.c
index 672e1ea..028d274 100644
--- a/src/catalog-web-exporter.c
+++ b/src/catalog-web-exporter.c
@@ -172,7 +172,7 @@ image_data_new (FileData *file)
 	idata->src_file = file_data_ref (file);
 	idata->dest_filename = g_strconcat (zero_padded (img_counter++),
 					    "-",
-					    file->name,
+					    file->utf8_name,
 					    NULL);
 
 	idata->image = NULL;
@@ -719,7 +719,8 @@ comp_func_name (gconstpointer a, gconstpointer b)
 	data_a = IMAGE_DATA (a);
 	data_b = IMAGE_DATA (b);
 
-	return gth_sort_by_filename_but_ignore_path (data_a->src_file->name, data_b->src_file->name);}
+	return gth_sort_by_filename_but_ignore_path (data_a->src_file->utf8_path, data_b->src_file->utf8_path);
+}
 
 
 static int
diff --git a/src/dlg-convert.c b/src/dlg-convert.c
index 837b5e3..0f430f8 100644
--- a/src/dlg-convert.c
+++ b/src/dlg-convert.c
@@ -163,7 +163,7 @@ load_current_image (DialogData *data)
 	data->new_path = NULL;
 
 	fd = (FileData*) data->current_image->data;
-	name_no_ext = remove_extension_from_path (fd->name);
+	name_no_ext = remove_extension_from_path (fd->utf8_name);
 
 	data->new_path = g_strconcat (data->destination, "/", name_no_ext, ".", data->ext, NULL);
 
diff --git a/src/dlg-rename-series.c b/src/dlg-rename-series.c
index bee9625..cc4d2d8 100644
--- a/src/dlg-rename-series.c
+++ b/src/dlg-rename-series.c
@@ -158,7 +158,7 @@ comp_func_name (gconstpointer  ptr1,
 	if ((fd1 == NULL) || (fd2 == NULL))
 		return 0;
 
-	return gth_sort_by_filename_but_ignore_path (fd1->name, fd2->name);
+	return gth_sort_by_filename_but_ignore_path (fd1->utf8_path, fd2->utf8_path);
 }
 
 
@@ -361,7 +361,7 @@ update_list (DialogData *data)
 
 	for (scan = data->file_list; scan; scan = scan->next) {
 		FileData *fdata = scan->data;
-		char     *name_wo_ext = remove_extension_from_path (fdata->name);
+		char     *name_wo_ext = remove_extension_from_path (fdata->utf8_name);
 		char     *utf8_txt, *image_date, *image_size;
 		char     *name1 = NULL;
 		char     *name2;
@@ -397,11 +397,11 @@ update_list (DialogData *data)
 		name4 = _g_substitute_pattern (name3, 's', image_size);
 		g_free (image_size);
 
-		if (strrchr (fdata->name, '.') != NULL)
-			extension = g_filename_to_utf8 (strrchr (fdata->name, '.'), -1, 0, 0, 0);
+		if (strrchr (fdata->utf8_name, '.') != NULL)
+			extension = g_filename_to_utf8 (strrchr (fdata->utf8_name, '.'), -1, 0, 0, 0);
 		name5 = _g_substitute_pattern (name4, 'e', extension);
 
-		original_enum = extract_utf8_digits (fdata->name);
+		original_enum = extract_utf8_digits (fdata->utf8_name);
 		name6 = _g_substitute_pattern (name5, 'n', original_enum);
 		g_free (original_enum);
 
diff --git a/src/gth-batch-op.c b/src/gth-batch-op.c
index 1241d74..6f1c03c 100644
--- a/src/gth-batch-op.c
+++ b/src/gth-batch-op.c
@@ -384,10 +384,10 @@ load_current_image (GthBatchOp *bop)
 		folder = remove_level_from_path (PD(bop)->new_path);
 	else
 		folder = g_strdup (PD(bop)->destination);
-	name_no_ext = remove_extension_from_path (fd->name);
+	name_no_ext = remove_extension_from_path (fd->utf8_name);
 
 	if (mime_type_is (fd->mime_type, get_mime_type_from_ext (PD(bop)->image_type)))
-		PD(bop)->new_path = g_strconcat (folder, "/", fd->name, NULL);
+		PD(bop)->new_path = g_strconcat (folder, "/", fd->utf8_name, NULL);
 	else
 		PD(bop)->new_path = g_strconcat (folder, "/", name_no_ext, ".", PD(bop)->image_type, NULL);
 
diff --git a/src/gth-browser.c b/src/gth-browser.c
index db14d05..4d3b75d 100644
--- a/src/gth-browser.c
+++ b/src/gth-browser.c
@@ -541,7 +541,7 @@ update_image_comment (GthBrowser *browser)
 	/**/
 
 	if (cdata->changed)
-		gth_file_list_update_comment (priv->file_list, priv->image->path);
+		gth_file_list_update_comment (priv->file_list, priv->image->utf8_path);
 
 	g_free (comment);
 }
@@ -575,7 +575,7 @@ window_update_infobar (GthBrowser *browser)
 	}
 
 	images = gth_file_view_get_images (priv->file_list->view);
-	current = gth_file_list_pos_from_path (priv->file_list, priv->image->path) + 1;
+	current = gth_file_list_pos_from_path (priv->file_list, priv->image->utf8_path) + 1;
 
 	escaped_name = g_markup_escape_text (priv->image->utf8_name, -1);
 
@@ -631,7 +631,7 @@ window_update_title (GthBrowser *browser)
 		int   images, current;
 
 		images = gth_file_view_get_images (priv->file_list->view);
-		current = gth_file_list_pos_from_path (priv->file_list, priv->image->path) + 1;
+		current = gth_file_list_pos_from_path (priv->file_list, priv->image->utf8_path) + 1;
 
 		if (priv->image_catalog != NULL) {
 			char *cat_name = basename_for_display (priv->image_catalog);
@@ -816,7 +816,7 @@ window_update_sensitivity (GthBrowser *browser)
 	image_is_image = (browser->priv->image != NULL) && mime_type_is_image (browser->priv->image->mime_type);
 	
 	if (priv->image != NULL)
-		image_pos = gth_file_list_pos_from_path (priv->file_list, priv->image->path);
+		image_pos = gth_file_list_pos_from_path (priv->file_list, priv->image->utf8_path);
 	else
 		image_pos = -1;
 
@@ -1659,8 +1659,8 @@ save_pixbuf__image_saved_cb (FileData *file,
 			
 		g_free (browser->priv->image_path_saved);
 		browser->priv->image_path_saved = NULL;
-		if (file->path != NULL)
-			browser->priv->image_path_saved = g_strdup (file->path);
+		if (file->utf8_path != NULL)
+			browser->priv->image_path_saved = g_strdup (file->utf8_path);
 
 		browser->priv->image_modified = FALSE;
 		browser->priv->saving_modified_image = FALSE;
@@ -1670,8 +1670,8 @@ save_pixbuf__image_saved_cb (FileData *file,
 		if (! closing) {
 			GList *file_list;
 		
-			file_list = g_list_prepend (NULL, (char*) file->path);
-			if (gth_file_list_pos_from_path (browser->priv->file_list, file->path) != -1)
+			file_list = g_list_prepend (NULL, (char*) file->utf8_path);
+			if (gth_file_list_pos_from_path (browser->priv->file_list, file->utf8_path) != -1)
 				gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, file_list);
 			else
 				gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, file_list);
@@ -1693,7 +1693,7 @@ gth_browser_save_pixbuf (GthWindow *window,
 	char                  *current_folder = NULL;
 
 	if (priv->image != NULL) {
-		current_folder = g_strdup (priv->image->path);
+		current_folder = g_strdup (priv->image->utf8_path);
 		update_metadata (priv->image);
 	}
 	else if (priv->dir_list->path != NULL)
@@ -1733,7 +1733,7 @@ ask_whether_to_save__response_cb (GtkWidget  *dialog,
 	if (response_id == GTK_RESPONSE_YES) {
 		update_metadata (priv->image);
 		dlg_save_image_as (GTK_WINDOW (browser),
-				   priv->image->path,
+				   priv->image->utf8_path,
 				   priv->image->metadata,
 				   image_viewer_get_current_pixbuf (IMAGE_VIEWER (priv->viewer)),
 				   save_pixbuf__image_saved_cb,
@@ -2587,7 +2587,7 @@ static void
 go_to_folder_after_image_loaded (GthBrowser *browser)
 {
 	GthBrowserPrivateData *priv = browser->priv;
-	char *folder_uri = remove_level_from_path (priv->image->path);
+	char *folder_uri = remove_level_from_path (priv->image->utf8_path);
 
 	priv->focus_current_image = TRUE;
 	gth_browser_hide_sidebar (browser);
@@ -2651,7 +2651,7 @@ image_requested_done_cb (GThumbPreloader *gploader,
 
 	priv->loading_image = TRUE;
 
-	loader = gthumb_preloader_get_loader (priv->preloader, priv->image->path);
+	loader = gthumb_preloader_get_loader (priv->preloader, priv->image->utf8_path);
 	if (loader != NULL)
 		image_viewer_load_from_image_loader (IMAGE_VIEWER (priv->viewer), loader);
 }
@@ -2865,13 +2865,13 @@ launch_selected_videos_or_audio (GthBrowser *browser)
 		FileData *file = scan->data;
 
 		if (mime_type_is (file->mime_type, image_mime_type)) {
-			video_list = g_list_append (video_list, g_strdup (file->path));
+			video_list = g_list_append (video_list, g_strdup (file->utf8_path));
 		}
 		else {
 			GAppInfo  *selected_app;
 			selected_app = g_app_info_get_default_for_type (file->mime_type, TRUE);
 			if (g_app_info_equal (app_info, selected_app))
-				video_list = g_list_append (video_list, g_strdup (file->path));
+				video_list = g_list_append (video_list, g_strdup (file->utf8_path));
 			g_object_unref (selected_app);
 		}
 	}
@@ -5557,10 +5557,10 @@ gth_browser_notify_files_changed (GthBrowser *browser,
 
 	if ((priv->image != NULL)
 	    && ! priv->image_modified
-	    && (path_list_find_path (list, priv->image->path) != NULL)) {
+	    && (path_list_find_path (list, priv->image->utf8_path) != NULL)) {
 		int pos;
 		
-		pos = gth_file_list_pos_from_path (priv->file_list, priv->image->path);
+		pos = gth_file_list_pos_from_path (priv->file_list, priv->image->utf8_path);
 		if (pos != -1)
 			view_image_at_pos (browser, pos);
 	}
@@ -5760,13 +5760,13 @@ gth_browser_notify_directory_rename (GthBrowser *browser,
 
 	if ((priv->image != NULL)
 	    && (priv->sidebar_content == GTH_SIDEBAR_DIR_LIST)
-	    && path_in_path (old_name, priv->image->path)) 
+	    && path_in_path (old_name, priv->image->utf8_path)) 
 	{
-		char *new_image_path = g_strdup (priv->image->path);
+		char *new_image_path = g_strdup (priv->image->utf8_path);
 		char *new_image_name;
 
 		new_image_name = g_strconcat (new_name,
-					      priv->image->path + strlen (old_name),
+					      priv->image->utf8_path + strlen (old_name),
 					      NULL);
 		gth_browser_notify_file_rename (browser,
 						new_image_path,
@@ -5805,10 +5805,10 @@ gth_browser_notify_directory_delete (GthBrowser *browser,
 	}
 
 	if ((priv->image != NULL)
-	    && (path_in_path (priv->image->path, path))) {
+	    && (path_in_path (priv->image->utf8_path, path))) {
 		GList *list;
 
-		list = g_list_append (NULL, priv->image->path);
+		list = g_list_append (NULL, priv->image->utf8_path);
 		gth_browser_notify_files_deleted (browser, list);
 		g_list_free (list);
 	}
@@ -6225,7 +6225,7 @@ dir_list_done_cb (GthDirList     *dir_list,
 	if ((file_list == NULL) && (browser->priv->image != NULL)) {
 		char *image_dir;
 		
-		image_dir = remove_level_from_path (browser->priv->image->path);
+		image_dir = remove_level_from_path (browser->priv->image->utf8_path);
 		if (uricmp (image_dir, browser->priv->dir_list->path) == 0)
 			file_list = g_list_append (NULL, file_data_dup (browser->priv->image));
 		g_free (image_dir);
@@ -7435,8 +7435,8 @@ gth_browser_set_sidebar_content (GthBrowser *browser,
 		if (priv->dir_list->path == NULL) {
 			char *folder_uri = NULL;
 			if (priv->image != NULL) {
-				ImageToDisplay = g_strdup (priv->image->path);
-				folder_uri = remove_level_from_path (priv->image->path);
+				ImageToDisplay = g_strdup (priv->image->utf8_path);
+				folder_uri = remove_level_from_path (priv->image->utf8_path);
 			} else
 				folder_uri = g_strdup (get_home_uri ());
 
@@ -8019,7 +8019,7 @@ gth_browser_show_next_image (GthBrowser *browser,
 			pos = gth_file_list_next_image (priv->file_list, pos, skip_broken, only_selected);
 	} 
 	else {
-		pos = gth_file_list_pos_from_path (priv->file_list, priv->image->path);
+		pos = gth_file_list_pos_from_path (priv->file_list, priv->image->utf8_path);
 		pos = gth_file_list_next_image (priv->file_list, pos, skip_broken, only_selected);
 	}
 
@@ -8057,7 +8057,7 @@ gth_browser_show_prev_image (GthBrowser *browser,
 		}
 	} 
 	else {
-		pos = gth_file_list_pos_from_path (priv->file_list, priv->image->path);
+		pos = gth_file_list_pos_from_path (priv->file_list, priv->image->utf8_path);
 		pos = gth_file_list_prev_image (priv->file_list, pos, skip_broken, only_selected);
 	}
 
@@ -8215,7 +8215,7 @@ get_image_to_preload (GthBrowser *browser,
 		max_size = PRELOADED_IMAGE_MAX_DIM2;
 
 	if (fdata->size > max_size) {
-		debug (DEBUG_INFO, "image %s filesize too large for preloading\n", fdata->path);
+		debug (DEBUG_INFO, "image %s filesize too large for preloading\n", fdata->utf8_path);
 		file_data_unref (fdata);
 		return NULL;
 	}
@@ -8253,7 +8253,7 @@ load_timeout_cb (gpointer data)
 	/* update the mtime in order to reload the image if required. */
 	file_data_update (browser->priv->image);
 
-	browser->priv->image_position = gth_file_list_pos_from_path (browser->priv->file_list, browser->priv->image->path);
+	browser->priv->image_position = gth_file_list_pos_from_path (browser->priv->file_list, browser->priv->image->utf8_path);
 	if (browser->priv->image_position >= 0) {
 		prev1 = get_image_to_preload (browser, browser->priv->image_position - 1, 1);
 		next1 = get_image_to_preload (browser, browser->priv->image_position + 1, 1);
@@ -8481,7 +8481,7 @@ gth_browser_update_current_image_metadata (GthWindow *window)
 
 	if (browser->priv->image == NULL)
 		return;
-	gth_browser_notify_update_comment (browser, browser->priv->image->path);
+	gth_browser_notify_update_comment (browser, browser->priv->image->utf8_path);
 
 	if (browser->priv->image_prop_dlg != NULL)
 		dlg_image_prop_update (browser->priv->image_prop_dlg);



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