[nautilus/wip/antoniof/gtk4-pre-switch-regressions: 5/9] icon-info: Remove unused or single-use API
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-pre-switch-regressions: 5/9] icon-info: Remove unused or single-use API
- Date: Fri, 31 Dec 2021 11:03:38 +0000 (UTC)
commit 88b3e193476660a8dcbf760acf0cbd86d900fe0a
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 | 65 +---------------------------------------
src/nautilus-icon-info.h | 9 ------
src/nautilus-properties-window.c | 6 ++--
4 files changed, 6 insertions(+), 86 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index b464748c8..bcab2d8ec 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4877,17 +4877,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..c4586da3d 100644
--- a/src/nautilus-icon-info.c
+++ b/src/nautilus-icon-info.c
@@ -471,38 +471,7 @@ nautilus_icon_info_lookup (GIcon *icon,
}
}
-NautilusIconInfo *
-nautilus_icon_info_lookup_from_name (const char *name,
- int size,
- int scale)
-{
- GIcon *icon;
- NautilusIconInfo *info;
-
- icon = g_themed_icon_new (name);
- info = nautilus_icon_info_lookup (icon, size, scale);
- g_object_unref (icon);
- 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 +512,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 ed321dbfa..518db76a9 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 8b6b772a1..4861e76ce 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_GRID_ICON_SIZE_STANDARD,
- icon_scale);
+ g_autoptr (GIcon) gicon = g_themed_icon_new ("text-x-generic");
+
+ icon = nautilus_icon_info_lookup (gicon, NAUTILUS_GRID_ICON_SIZE_STANDARD, icon_scale);
}
if (icon_name != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]