[nautilus/wip/antoniof/properties-followup: 8/21] properties-window: Hide type if not homogeneous




commit f81c1dba8bc039d7c8e43877ecd5dd8d692eac66
Author: António Fernandes <antoniof gnome org>
Date:   Wed Aug 3 13:43:20 2022 +0100

    properties-window: Hide type if not homogeneous
    
    Multi-file windows may have files of different types.

 src/nautilus-properties-window.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 97fa172fc..7dced1c3d 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -2164,9 +2164,43 @@ should_show_custom_icon_buttons (NautilusPropertiesWindow *self)
     return TRUE;
 }
 
+static gboolean
+is_single_file_type (NautilusPropertiesWindow *self)
+{
+    if (is_multi_file_window (self))
+    {
+        g_autofree gchar *mime_type = NULL;
+        GList *l = self->original_files;
+
+        mime_type = nautilus_file_get_mime_type (NAUTILUS_FILE (l->data));
+        for (l = l->next; l != NULL; l = l->next)
+        {
+            g_autofree gchar *next_mime_type = NULL;
+
+            if (nautilus_file_is_gone (NAUTILUS_FILE (l->data)))
+            {
+                continue;
+            }
+
+            next_mime_type = nautilus_file_get_mime_type (NAUTILUS_FILE (l->data));
+            if (g_strcmp0 (next_mime_type, mime_type) != 0)
+            {
+                return FALSE;
+            }
+        }
+    }
+
+    return TRUE;
+}
+
 static gboolean
 should_show_file_type (NautilusPropertiesWindow *self)
 {
+    if (!is_single_file_type (self))
+    {
+        return FALSE;
+    }
+
     if (!is_multi_file_window (self)
         && (nautilus_file_is_in_trash (get_target_file (self)) ||
             is_network_directory (get_target_file (self)) ||


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