[nautilus/gtk4-preparation-trunk: 55/64] list-view: Drop HiDPI icon support




commit c905b8813a9eb1bdeda3bdf46cc8879992f27376
Author: António Fernandes <antoniof gnome org>
Date:   Wed Dec 15 16:59:02 2021 +0000

    list-view: Drop HiDPI icon support
    
    gdk_cairo_surface_create_from_pixbuf() is gone in GDK 4. A replacement
    cannot be easily implemented in GTK 3 which would be portable to GTK 4.
    
    Take this temporary regression, to be fixed with paintables in GTK 4.

 src/nautilus-list-model.c | 11 ++++++-----
 src/nautilus-list-view.c  | 16 ++++++++++------
 2 files changed, 16 insertions(+), 11 deletions(-)
---
diff --git a/src/nautilus-list-model.c b/src/nautilus-list-model.c
index 7e2aeeeee..ebafcebf8 100644
--- a/src/nautilus-list-model.c
+++ b/src/nautilus-list-model.c
@@ -174,7 +174,7 @@ nautilus_list_model_get_column_type (GtkTreeModel *tree_model,
         case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN:
         case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN:
         {
-            return CAIRO_GOBJECT_TYPE_SURFACE;
+            return GDK_TYPE_PIXBUF;
         }
 
         case NAUTILUS_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN:
@@ -303,6 +303,9 @@ nautilus_list_model_get_icon_scale (NautilusListModel *model)
         retval = gdk_monitor_get_scale_factor (gdk_display_get_monitor (gdk_display_get_default (), 0));
     }
 
+    /* FIXME: Temporary regression: HiDPI icons not supported, ignore scale. */
+    retval = 1;
+
     return retval;
 }
 
@@ -349,7 +352,6 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model,
     int icon_size, icon_scale;
     NautilusListZoomLevel zoom_level;
     NautilusFileIconFlags flags;
-    cairo_surface_t *surface;
 
     model = NAUTILUS_LIST_MODEL (tree_model);
     priv = nautilus_list_model_get_instance_private (model);
@@ -383,7 +385,7 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model,
         case NAUTILUS_LIST_MODEL_LARGE_ICON_COLUMN:
         case NAUTILUS_LIST_MODEL_LARGER_ICON_COLUMN:
         {
-            g_value_init (value, CAIRO_GOBJECT_TYPE_SURFACE);
+            g_value_init (value, GDK_TYPE_PIXBUF);
 
             if (file != NULL)
             {
@@ -432,8 +434,7 @@ nautilus_list_model_get_value (GtkTreeModel *tree_model,
                     }
                 }
 
-                surface = gdk_cairo_surface_create_from_pixbuf (icon, icon_scale, NULL);
-                g_value_take_boxed (value, surface);
+                g_value_set_object (value, icon);
                 g_object_unref (icon);
             }
         }
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 9ae919930..202f0996c 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1644,7 +1644,7 @@ icon_cell_data_func (GtkTreeViewColumn *column,
                      GtkTreeIter       *iter,
                      NautilusListView  *view)
 {
-    cairo_surface_t *surface;
+    g_autoptr (GdkPixbuf) pixbuf = NULL;
     GtkStyleContext *context;
     g_autoptr (NautilusFile) file = NULL;
     g_autofree gchar *thumbnail_path = NULL;
@@ -1653,7 +1653,7 @@ icon_cell_data_func (GtkTreeViewColumn *column,
     gtk_tree_model_get (model,
                         iter,
                         nautilus_list_model_get_column_id_from_zoom_level (view->details->zoom_level),
-                        &surface,
+                        &pixbuf,
                         NAUTILUS_LIST_MODEL_FILE_COLUMN,
                         &file,
                         -1);
@@ -1678,9 +1678,8 @@ icon_cell_data_func (GtkTreeViewColumn *column,
     }
 
     g_object_set (renderer,
-                  "surface", surface,
+                  "pixbuf", pixbuf,
                   NULL);
-    cairo_surface_destroy (surface);
 }
 
 static void
@@ -1977,7 +1976,8 @@ static gint
 get_icon_scale_callback (NautilusListModel *model,
                          NautilusListView  *view)
 {
-    return gtk_widget_get_scale_factor (GTK_WIDGET (view->details->tree_view));
+    /* FIXME: Temporary regression: HiDPI icons not supported, ignore scale. */
+    return 1;
 }
 
 static void
@@ -2256,6 +2256,10 @@ create_and_set_up_tree_view (NautilusListView *view)
             gtk_tree_view_column_set_cell_data_func (view->details->file_name_column, cell,
                                                      (GtkTreeCellDataFunc) icon_cell_data_func,
                                                      view, NULL);
+            gtk_tree_view_column_set_attributes (view->details->file_name_column,
+                                                 cell,
+                                                 "pixbuf", nautilus_list_model_get_column_id_from_zoom_level 
(view->details->zoom_level),
+                                                 NULL);
 
             cell = gtk_cell_renderer_text_new ();
             view->details->file_name_cell = (GtkCellRendererText *) cell;
@@ -3425,7 +3429,7 @@ nautilus_list_view_set_zoom_level (NautilusListView      *view,
     column = nautilus_list_model_get_column_id_from_zoom_level (new_level);
     gtk_tree_view_column_set_attributes (view->details->file_name_column,
                                          GTK_CELL_RENDERER (view->details->pixbuf_cell),
-                                         "surface", column,
+                                         "pixbuf", column,
                                          NULL);
     set_up_pixbuf_size (view);
 }


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