[gthumb] Base filename sorting on gfile-provided UTF8 display names.



commit eb73bbf2b1343a1350d77cc3cdb29b9591ebd642
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Wed Apr 22 13:21:25 2009 -0400

    Base filename sorting on gfile-provided UTF8 display names.
    
    Also, purge a bunch of no-longer-required gnomevfs includes.
---
 libgthumb/comments.c               |    4 +--
 libgthumb/gth-sort-utils.c         |   41 +++++++++++++++++++++---------------
 libgthumb/thumb-loader.c           |    5 +---
 src/gth-browser.c                  |    3 --
 src/gth-dir-list.c                 |    4 +--
 src/gth-window-actions-callbacks.c |    2 +-
 6 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/libgthumb/comments.c b/libgthumb/comments.c
index f791f91..0421696 100644
--- a/libgthumb/comments.c
+++ b/libgthumb/comments.c
@@ -33,9 +33,7 @@
 #include <time.h>
 
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-result.h>
 #include <libxml/tree.h>
 #include <libxml/parser.h>
 #include <libxml/xmlmemory.h>
diff --git a/libgthumb/gth-sort-utils.c b/libgthumb/gth-sort-utils.c
index b5c7b08..f7976b4 100644
--- a/libgthumb/gth-sort-utils.c
+++ b/libgthumb/gth-sort-utils.c
@@ -24,7 +24,6 @@
 #include <strings.h>
 #include <glib.h>
 #include <gnome.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
 #include "file-data.h"
 #include "file-utils.h"
 #include "gth-exif-utils.h"
@@ -102,20 +101,15 @@ gth_sort_by_exiftime_then_name (FileData *fd1,
 	return gth_sort_by_filename_but_ignore_path (fd1->path, fd2->path);
 }
 
-
 int
-gth_sort_by_filename_but_ignore_path (const char *name1,
-				      const char *name2)
+gth_sort_by_filename (const char *name1,
+                      const char *name2,
+                      gboolean    ignore_path)
 {
-	/* This sorts by the filename. It ignores the path portion, if present. */
-
-	/* Based heavily on the Nautilus compare_by_display_name (libnautilus-private/nautilus-file.c)
-	   function, for consistent Nautilus / gthumb behaviour. */
-
 	char     *key_1, *key_2;
 	gboolean  sort_last_1, sort_last_2;
 	int       compare;
-	char     *unesc_name1, *unesc_name2;
+	char     *utf8_name1, *utf8_name2;
 
 	sort_last_1 = file_name_from_path (name1)[0] == SORT_LAST_CHAR1
 			|| file_name_from_path (name1)[0] == SORT_LAST_CHAR2;
@@ -127,28 +121,41 @@ gth_sort_by_filename_but_ignore_path (const char *name1,
 	} else if (!sort_last_1 && sort_last_2) {
 		compare = -1;
 	} else {
-		unesc_name1 = gnome_vfs_unescape_string (name1, "");
-		unesc_name2 = gnome_vfs_unescape_string (name2, "");
+		utf8_name1 = get_utf8_display_name_from_uri (name1);
+		utf8_name2 = get_utf8_display_name_from_uri (name2);
 
-		key_1 = g_utf8_collate_key_for_filename (file_name_from_path (unesc_name1), -1);
-		key_2 = g_utf8_collate_key_for_filename (file_name_from_path (unesc_name2), -1);
+		if (ignore_path) {
+			key_1 = g_utf8_collate_key_for_filename (file_name_from_path (utf8_name1), -1);
+			key_2 = g_utf8_collate_key_for_filename (file_name_from_path (utf8_name2), -1);
+		} else {
+                        key_1 = g_utf8_collate_key_for_filename (utf8_name1, -1);
+                        key_2 = g_utf8_collate_key_for_filename (utf8_name2, -1);
+		}
 
 		compare = strcmp (key_1, key_2);
 
 		g_free(key_1);
 		g_free(key_2);
-		g_free(unesc_name1);
-		g_free(unesc_name2);
+		g_free(utf8_name1);
+		g_free(utf8_name2);
 	}
 
 	return compare;
 }
 
 
+int
+gth_sort_by_filename_but_ignore_path (const char *name1,
+				      const char *name2)
+{
+	return gth_sort_by_filename (name1, name2, TRUE);
+}
+
+
 int gth_sort_by_full_path (const char *path1,
 			   const char *path2)
 {
-	return uricmp (path1, path2);
+	return gth_sort_by_filename (path1, path2, FALSE);
 }
 
 
diff --git a/libgthumb/thumb-loader.c b/libgthumb/thumb-loader.c
index 2ca5b77..579471e 100644
--- a/libgthumb/thumb-loader.c
+++ b/libgthumb/thumb-loader.c
@@ -29,10 +29,7 @@
 
 #include <gtk/gtk.h>
 #include <libgnomeui/gnome-thumbnail.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-mime.h>
+#include <libgnomevfs/gnome-vfs-result.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "gthumb-init.h"
diff --git a/src/gth-browser.c b/src/gth-browser.c
index 92570d8..99924ae 100644
--- a/src/gth-browser.c
+++ b/src/gth-browser.c
@@ -28,10 +28,7 @@
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gtk/gtk.h>
 #include <gio/gio.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
 #include <libgnomevfs/gnome-vfs-result.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
 #include <glade/glade.h>
 
 #include "bookmarks.h"
diff --git a/src/gth-dir-list.c b/src/gth-dir-list.c
index 996ddb2..e69347f 100644
--- a/src/gth-dir-list.c
+++ b/src/gth-dir-list.c
@@ -24,9 +24,7 @@
 #include <string.h>
 #include <strings.h>
 #include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-result.h>
 #include "typedefs.h"
 #include "gth-dir-list.h"
 #include "gth-file-list.h"
diff --git a/src/gth-window-actions-callbacks.c b/src/gth-window-actions-callbacks.c
index c595718..d70a159 100644
--- a/src/gth-window-actions-callbacks.c
+++ b/src/gth-window-actions-callbacks.c
@@ -31,7 +31,7 @@
 #include <libgnome/gnome-exec.h>
 #include <libgnome/gnome-help.h>
 #include <libgnome/gnome-url.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-result.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "async-pixbuf-ops.h"



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