[nautilus/wip/antoniof/new-list-view-without-expanders: 17/17] list-view-item-ui: Use symbolic mime-type icons on compact list




commit 8981359a07e32ebc4d5ea03e4c1ce455b6d0fd93
Author: António Fernandes <antoniof gnome org>
Date:   Fri Jun 3 15:57:59 2022 +0100

    list-view-item-ui: Use symbolic mime-type icons on compact list
    
    At 16px we are unable to use meaningful thumbnails, so all files get a
    full-color MIME type icon.
    
    However, at this size, the fullcolor icons have fewer details, yet add
    a lot of visual noise because there are more icons in view at once.

 src/nautilus-icon-info.c                       |  9 ++++++++-
 src/nautilus-list-view-item-ui.c               | 16 +++++++++++++++-
 src/resources/css/Adwaita.css                  |  4 ++++
 src/resources/ui/nautilus-list-view-item-ui.ui |  6 ++++++
 4 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-icon-info.c b/src/nautilus-icon-info.c
index 0831ae168..3550e6f1a 100644
--- a/src/nautilus-icon-info.c
+++ b/src/nautilus-icon-info.c
@@ -340,6 +340,7 @@ nautilus_icon_info_lookup (GIcon *icon,
                            int    scale)
 {
     NautilusIconInfo *icon_info;
+    GtkIconLookupFlags flags = 0;
     g_autoptr (GtkIconPaintable) icon_paintable = NULL;
 
     if (G_IS_LOADABLE_ICON (icon))
@@ -390,8 +391,13 @@ nautilus_icon_info_lookup (GIcon *icon,
         return g_object_ref (icon_info);
     }
 
+    if (size <= NAUTILUS_LIST_ICON_SIZE_SMALL)
+    {
+        flags |= GTK_ICON_LOOKUP_FORCE_SYMBOLIC;
+    }
+
     icon_paintable = gtk_icon_theme_lookup_by_gicon (gtk_icon_theme_get_for_display (gdk_display_get_default 
()),
-                                                     icon, size, scale, GTK_TEXT_DIR_NONE, 0);
+                                                     icon, size, scale, GTK_TEXT_DIR_NONE, flags);
     if (icon_paintable == NULL)
     {
         return nautilus_icon_info_new_for_pixbuf (NULL, scale);
@@ -498,3 +504,4 @@ nautilus_icon_info_get_used_name (NautilusIconInfo *icon)
 {
     return icon->icon_name;
 }
+
diff --git a/src/nautilus-list-view-item-ui.c b/src/nautilus-list-view-item-ui.c
index 007d975ff..ff410862e 100644
--- a/src/nautilus-list-view-item-ui.c
+++ b/src/nautilus-list-view-item-ui.c
@@ -14,6 +14,7 @@ struct _NautilusListViewItemUi
 
     GtkWidget *fixed_height_box;
     GtkWidget *icon;
+    GtkWidget *compact_icon;
     GtkWidget *label;
     GtkWidget *snippet;
     GtkWidget *path;
@@ -39,19 +40,31 @@ update_icon (NautilusListViewItemUi *self)
     GtkStyleContext *style_context;
     NautilusFile *file;
     guint icon_size;
+    gboolean use_compact;
     int icon_height;
     int extra_margin;
     g_autofree gchar *thumbnail_path = NULL;
 
     file = nautilus_view_item_model_get_file (self->model);
     icon_size = nautilus_view_item_model_get_icon_size (self->model);
+    use_compact = (icon_size == NAUTILUS_LIST_ICON_SIZE_SMALL);
     flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS |
             NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE |
             NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS |
             NAUTILUS_FILE_ICON_FLAGS_USE_ONE_EMBLEM;
 
+    gtk_widget_set_visible (self->icon, !use_compact);
+    gtk_widget_set_visible (self->compact_icon, use_compact);
+
     icon_paintable = nautilus_file_get_icon_paintable (file, icon_size, 1, flags);
-    gtk_picture_set_paintable (GTK_PICTURE (self->icon), icon_paintable);
+    if (use_compact)
+    {
+        gtk_image_set_from_paintable (GTK_IMAGE (self->compact_icon), icon_paintable);
+    }
+    else
+    {
+        gtk_picture_set_paintable (GTK_PICTURE (self->icon), icon_paintable);
+    }
 
     /* Set the same width for all icons regardless of aspect ratio.
      * Don't set the width here because it would get GtkPicture w4h confused.
@@ -328,6 +341,7 @@ nautilus_list_view_item_ui_class_init (NautilusListViewItemUiClass *klass)
 
     gtk_widget_class_bind_template_child (widget_class, NautilusListViewItemUi, fixed_height_box);
     gtk_widget_class_bind_template_child (widget_class, NautilusListViewItemUi, icon);
+    gtk_widget_class_bind_template_child (widget_class, NautilusListViewItemUi, compact_icon);
     gtk_widget_class_bind_template_child (widget_class, NautilusListViewItemUi, label);
     gtk_widget_class_bind_template_child (widget_class, NautilusListViewItemUi, snippet);
     gtk_widget_class_bind_template_child (widget_class, NautilusListViewItemUi, path);
diff --git a/src/resources/css/Adwaita.css b/src/resources/css/Adwaita.css
index 869391b22..125d1bd8b 100644
--- a/src/resources/css/Adwaita.css
+++ b/src/resources/css/Adwaita.css
@@ -190,6 +190,10 @@
   margin-bottom: 2px;
 }
 
+.nautilus-list-view columnview > listview > row image:not(.star) {
+  color: mix(@view_fg_color, @view_bg_color, 0.30);
+}
+
 .nautilus-list-view columnview > listview > row {
   border-radius: 6px;
   margin-top: 4px;
diff --git a/src/resources/ui/nautilus-list-view-item-ui.ui b/src/resources/ui/nautilus-list-view-item-ui.ui
index fe2c0e30d..f1ee4131a 100644
--- a/src/resources/ui/nautilus-list-view-item-ui.ui
+++ b/src/resources/ui/nautilus-list-view-item-ui.ui
@@ -19,6 +19,12 @@
             <property name="can-shrink">False</property>
           </object>
         </child>
+        <child>
+          <object class="GtkImage" id="compact_icon">
+            <property name="halign">center</property>
+            <property name="valign">center</property>
+          </object>
+        </child>
       </object>
     </child>
     <child>


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