[nautilus/wip/antoniof/gnome-42: 51/72] Revert "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/gnome-42: 51/72] Revert "icon-info: Remove unused or single-use API"
- Date: Fri, 11 Feb 2022 19:28:01 +0000 (UTC)
commit dcd89f363e8123ac10bb0ab84013957ee47b455e
Author: Ondrej Holy <oholy redhat com>
Date: Fri Feb 11 14:35:55 2022 +0100
Revert "icon-info: Remove unused or single-use API"
This reverts commit 88b3e193476660a8dcbf760acf0cbd86d900fe0a.
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, 86 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 097be8cca..0ff80b1c7 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4867,9 +4867,17 @@ static GdkPixbuf *
get_menu_icon_for_file (NautilusFile *file,
GtkWidget *widget)
{
- int scale = gtk_widget_get_scale_factor (widget);
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
+ int scale;
- return nautilus_file_get_icon_pixbuf (file, 16, scale, 0);
+ 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;
}
static GList *
diff --git a/src/nautilus-icon-info.c b/src/nautilus-icon-info.c
index c4586da3d..8bf8a112c 100644
--- a/src/nautilus-icon-info.c
+++ b/src/nautilus-icon-info.c
@@ -471,7 +471,38 @@ nautilus_icon_info_lookup (GIcon *icon,
}
}
-static GdkPixbuf *
+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 *
nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo *icon)
{
GdkPixbuf *res;
@@ -512,6 +543,38 @@ 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 518db76a9..ed321dbfa 100644
--- a/src/nautilus-icon-info.h
+++ b/src/nautilus-icon-info.h
@@ -22,8 +22,17 @@ 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 ce6c8ad51..25de03af7 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -435,9 +435,9 @@ get_image_for_properties_window (NautilusPropertiesWindow *self,
if (!icon)
{
- g_autoptr (GIcon) gicon = g_themed_icon_new ("text-x-generic");
-
- icon = nautilus_icon_info_lookup (gicon, NAUTILUS_GRID_ICON_SIZE_STANDARD, icon_scale);
+ icon = nautilus_icon_info_lookup_from_name ("text-x-generic",
+ 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]