[nautilus: 1/2] file: Sort type and link to type together



commit 4dcc2e7002617984bf7883a56cea66f855c7e14d
Author: Alexandru Fazakas <alex fazakas97 yahoo com>
Date:   Thu Mar 15 01:46:35 2018 +0200

    file: Sort type and link to type together
    
    As it is now, we only consider MIME types when sorting by type.
    
    This leads, for example to a text file and a link to it not being
    grouped together when sorted.
    
    We solved this issue by taking into consideration the basic type
    of the files when comparing (without the addition of "Link to").
    
    Fixes issue: https://gitlab.gnome.org/GNOME/nautilus/issues/292

 src/nautilus-file.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 1a95e3132..541897d16 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -165,6 +165,7 @@ static void     nautilus_file_info_iface_init (NautilusFileInfoInterface *iface)
 static char *nautilus_file_get_owner_as_string (NautilusFile *file,
                                                 gboolean      include_real_name);
 static char *nautilus_file_get_type_as_string (NautilusFile *file);
+static char *nautilus_file_get_type_as_string_no_extra_text (NautilusFile *file);
 static char *nautilus_file_get_detailed_type_as_string (NautilusFile *file);
 static gboolean update_info_and_name (NautilusFile *file,
                                       GFileInfo    *info);
@@ -3544,8 +3545,8 @@ compare_by_type (NautilusFile *file_1,
         return 0;
     }
 
-    type_string_1 = nautilus_file_get_type_as_string (file_1);
-    type_string_2 = nautilus_file_get_type_as_string (file_2);
+    type_string_1 = nautilus_file_get_type_as_string_no_extra_text (file_1);
+    type_string_2 = nautilus_file_get_type_as_string_no_extra_text (file_2);
 
     if (type_string_1 == NULL || type_string_2 == NULL)
     {
@@ -7744,6 +7745,22 @@ nautilus_file_get_type_as_string (NautilusFile *file)
     return update_description_for_link (file, get_description (file, FALSE));
 }
 
+static char *
+nautilus_file_get_type_as_string_no_extra_text (NautilusFile *file)
+{
+    if (file == NULL)
+    {
+        return NULL;
+    }
+
+    if (nautilus_file_is_broken_symbolic_link (file))
+    {
+        return g_strdup (_("Link (broken)"));
+    }
+
+    return get_description (file, FALSE);
+}
+
 static char *
 nautilus_file_get_detailed_type_as_string (NautilusFile *file)
 {


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