[nautilus/wip/antoniof/gtk4-pre-switch-regressions: 12/13] icon-info: Remove unused or single-use API




commit e34a5d69f28558183ccc246e2d12b10e9daca8e8
Author: António Fernandes <antoniof gnome org>
Date:   Wed Dec 22 20:12:16 2021 +0000

    icon-info: Remove unused or single-use API
    
    The single-use functions can be dropped because:
    
      - in properties-window, we can just make and pass a GIcon.
      - in files-view, we can just use the NautilusFile method.
    
    There is a potential change in behavior in that files-view
    now may get the default icon. That's not a problem at all.

 src/nautilus-files-view.c        | 12 ++-------
 src/nautilus-icon-info.c         | 53 ++--------------------------------------
 src/nautilus-icon-info.h         |  9 -------
 src/nautilus-properties-window.c |  6 ++---
 4 files changed, 7 insertions(+), 73 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index df56cccfc..66e32cb26 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4939,17 +4939,9 @@ static GdkPixbuf *
 get_menu_icon_for_file (NautilusFile *file,
                         GtkWidget    *widget)
 {
-    NautilusIconInfo *info;
-    GdkPixbuf *pixbuf;
-    int scale;
+    int scale = gtk_widget_get_scale_factor (widget);
 
-    scale = gtk_widget_get_scale_factor (widget);
-
-    info = nautilus_file_get_icon (file, 16, scale, 0);
-    pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, NAUTILUS_LIST_ICON_SIZE_SMALL);
-    g_object_unref (info);
-
-    return pixbuf;
+    return nautilus_file_get_icon_pixbuf (file, 16, scale, 0);
 }
 
 static GList *
diff --git a/src/nautilus-icon-info.c b/src/nautilus-icon-info.c
index 8bf8a112c..6a7e95a6d 100644
--- a/src/nautilus-icon-info.c
+++ b/src/nautilus-icon-info.c
@@ -471,7 +471,7 @@ nautilus_icon_info_lookup (GIcon *icon,
     }
 }
 
-NautilusIconInfo *
+static NautilusIconInfo *
 nautilus_icon_info_lookup_from_name (const char *name,
                                      int         size,
                                      int         scale)
@@ -485,24 +485,7 @@ nautilus_icon_info_lookup_from_name (const char *name,
     return info;
 }
 
-NautilusIconInfo *
-nautilus_icon_info_lookup_from_path (const char *path,
-                                     int         size,
-                                     int         scale)
-{
-    GFile *icon_file;
-    GIcon *icon;
-    NautilusIconInfo *info;
-
-    icon_file = g_file_new_for_path (path);
-    icon = g_file_icon_new (icon_file);
-    info = nautilus_icon_info_lookup (icon, size, scale);
-    g_object_unref (icon);
-    g_object_unref (icon_file);
-    return info;
-}
-
-GdkPixbuf *
+static GdkPixbuf *
 nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo *icon)
 {
     GdkPixbuf *res;
@@ -543,38 +526,6 @@ nautilus_icon_info_get_pixbuf (NautilusIconInfo *icon)
     return res;
 }
 
-GdkPixbuf *
-nautilus_icon_info_get_pixbuf_nodefault_at_size (NautilusIconInfo *icon,
-                                                 gsize             forced_size)
-{
-    GdkPixbuf *pixbuf, *scaled_pixbuf;
-    int w, h, s;
-    double scale;
-
-    pixbuf = nautilus_icon_info_get_pixbuf_nodefault (icon);
-
-    if (pixbuf == NULL)
-    {
-        return NULL;
-    }
-
-    w = gdk_pixbuf_get_width (pixbuf) / icon->orig_scale;
-    h = gdk_pixbuf_get_height (pixbuf) / icon->orig_scale;
-    s = MAX (w, h);
-    if (s == forced_size)
-    {
-        return pixbuf;
-    }
-
-    scale = (double) forced_size / s;
-    scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
-                                             w * scale, h * scale,
-                                             GDK_INTERP_BILINEAR);
-    g_object_unref (pixbuf);
-    return scaled_pixbuf;
-}
-
-
 GdkPixbuf *
 nautilus_icon_info_get_pixbuf_at_size (NautilusIconInfo *icon,
                                        gsize             forced_size)
diff --git a/src/nautilus-icon-info.h b/src/nautilus-icon-info.h
index 64f643651..ba9096491 100644
--- a/src/nautilus-icon-info.h
+++ b/src/nautilus-icon-info.h
@@ -22,17 +22,8 @@ NautilusIconInfo *    nautilus_icon_info_new_for_pixbuf               (GdkPixbuf
 NautilusIconInfo *    nautilus_icon_info_lookup                       (GIcon             *icon,
                                                                       int                size,
                                                                       int                scale);
-NautilusIconInfo *    nautilus_icon_info_lookup_from_name             (const char        *name,
-                                                                      int                size,
-                                                                      int                scale);
-NautilusIconInfo *    nautilus_icon_info_lookup_from_path             (const char        *path,
-                                                                      int                size,
-                                                                      int                scale);
 gboolean              nautilus_icon_info_is_fallback                  (NautilusIconInfo  *icon);
 GdkPixbuf *           nautilus_icon_info_get_pixbuf                   (NautilusIconInfo  *icon);
-GdkPixbuf *           nautilus_icon_info_get_pixbuf_nodefault         (NautilusIconInfo  *icon);
-GdkPixbuf *           nautilus_icon_info_get_pixbuf_nodefault_at_size (NautilusIconInfo  *icon,
-                                                                      gsize              forced_size);
 GdkPixbuf *           nautilus_icon_info_get_pixbuf_at_size           (NautilusIconInfo  *icon,
                                                                       gsize              forced_size);
 const char *          nautilus_icon_info_get_used_name                (NautilusIconInfo  *icon);
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 13bc8e999..74aba1750 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -434,9 +434,9 @@ get_image_for_properties_window (NautilusPropertiesWindow  *self,
 
     if (!icon)
     {
-        icon = nautilus_icon_info_lookup_from_name ("text-x-generic",
-                                                    NAUTILUS_CANVAS_ICON_SIZE_STANDARD,
-                                                    icon_scale);
+        g_autoptr (GIcon) gicon = g_themed_icon_new ("text-x-generic");
+
+        icon = nautilus_icon_info_lookup (gicon, NAUTILUS_CANVAS_ICON_SIZE_STANDARD, icon_scale);
     }
 
     if (icon_name != NULL)


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