[nautilus/wip/antoniof/hidpi-and-icons-cleanup: 6/11] properties: Use existing flag to get mount icon




commit 88e5da9a391ea1293c68fd8b126422e5321fe8ab
Author: António Fernandes <antoniof gnome org>
Date:   Thu Sep 1 09:16:11 2022 +0100

    properties: Use existing flag to get mount icon
    
    Instead of duplicating the work here.
    
    Also push "upstream" the root directory special case which was
    recently added in commit 5722c394567d36f214fe58fb4bef7334b5209bad.

 src/nautilus-file.c              | 11 +++++++++++
 src/nautilus-properties-window.c | 23 ++---------------------
 2 files changed, 13 insertions(+), 21 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 451f759d2..3f0f489d8 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -4635,6 +4635,17 @@ get_mount_icon (NautilusFile *file)
         mount_icon = g_mount_get_icon (mount);
         g_object_unref (mount);
     }
+    else
+    {
+        g_autoptr (GFile) location = nautilus_file_get_location (file);
+
+        /* Root directory doesn't have a GMount, but for UI purposes we want
+         * it to be treated the same way. */
+        if (nautilus_is_root_directory (location))
+        {
+            mount_icon = g_themed_icon_new_with_default_fallbacks ("drive-harddisk");
+        }
+    }
 
     return mount_icon;
 }
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index a2d5cc206..228ac5802 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -576,12 +576,14 @@ get_image_for_properties_window (NautilusPropertiesWindow  *self,
         {
             icon = nautilus_file_get_icon (file, NAUTILUS_GRID_ICON_SIZE_MEDIUM, icon_scale,
                                            NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS |
+                                           NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON |
                                            NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING);
         }
         else
         {
             new_icon = nautilus_file_get_icon (file, NAUTILUS_GRID_ICON_SIZE_MEDIUM, icon_scale,
                                                NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS |
+                                               NAUTILUS_FILE_ICON_FLAGS_USE_MOUNT_ICON |
                                                NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING);
             if (!new_icon || new_icon != icon)
             {
@@ -592,27 +594,6 @@ get_image_for_properties_window (NautilusPropertiesWindow  *self,
         }
     }
 
-    if (!is_multi_file_window (self))
-    {
-        g_autoptr (GIcon) gicon = NULL;
-        g_autoptr (GMount) mount = NULL;
-        mount = nautilus_file_get_mount (get_original_file (self));
-        if (mount != NULL)
-        {
-            gicon = g_mount_get_icon (mount);
-        }
-        else if (is_root_directory (get_original_file (self)))
-        {
-            gicon = g_themed_icon_new_with_default_fallbacks ("drive-harddisk");
-        }
-
-        if (gicon != NULL)
-        {
-            g_clear_object (&icon);
-            icon = nautilus_icon_info_lookup (gicon, NAUTILUS_GRID_ICON_SIZE_MEDIUM, icon_scale);
-        }
-    }
-
     if (!icon)
     {
         g_autoptr (GIcon) gicon = g_themed_icon_new ("text-x-generic");


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