[evince/gnome-3-22] comics: Sort pages in natural order



commit c718196909c67d4c0b74168514ba03affa6c8972
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Oct 5 14:20:50 2016 +0200

    comics: Sort pages in natural order
    
    Use g_utf8_collate_key_for_filename to convert the page filenames
    into collation keys in order to compare using strcmp().
    
    This prevents pages named such as page1, page2, page10, to be
    sorted as page1, page10, page2...
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770695

 backend/comics/comics-document.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/backend/comics/comics-document.c b/backend/comics/comics-document.c
index 845f517..96ed26e 100644
--- a/backend/comics/comics-document.c
+++ b/backend/comics/comics-document.c
@@ -466,7 +466,18 @@ static int
 sort_page_names (gconstpointer a,
                  gconstpointer b)
 {
-  return strcmp (* (const char **) a, * (const char **) b);
+  gchar *temp1, *temp2;
+  gint ret;
+
+  temp1 = g_utf8_collate_key_for_filename (* (const char **) a, -1);
+  temp2 = g_utf8_collate_key_for_filename (* (const char **) b, -1);
+
+  ret = strcmp (temp1, temp2);
+
+  g_free (temp1);
+  g_free (temp2);
+
+  return ret;
 }
 
 static gboolean


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