[nautilus/wip/antoniof/gnome-42: 50/72] Revert "icon-info: Stop using gtk_icon_theme_choose_icon_for_scale()"
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gnome-42: 50/72] Revert "icon-info: Stop using gtk_icon_theme_choose_icon_for_scale()"
- Date: Fri, 11 Feb 2022 19:28:01 +0000 (UTC)
commit bbbe5607ec5da302534c5d308d4ee6b2efde8b5c
Author: António Fernandes <antoniof gnome org>
Date: Fri Feb 11 19:01:56 2022 +0000
Revert "icon-info: Stop using gtk_icon_theme_choose_icon_for_scale()"
This reverts commit d5d9be0c06bb9f0997baee5bb513fa1a7dd4ecd0.
src/nautilus-icon-info.c | 68 +++++++++++++++++++++++++++++++++++-------------
1 file changed, 50 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-icon-info.c b/src/nautilus-icon-info.c
index fee560806..c4586da3d 100644
--- a/src/nautilus-icon-info.c
+++ b/src/nautilus-icon-info.c
@@ -336,7 +336,6 @@ nautilus_icon_info_lookup (GIcon *icon,
int scale)
{
NautilusIconInfo *icon_info;
- g_autoptr (GtkIconInfo) gtkicon_info = NULL;
if (G_IS_LOADABLE_ICON (icon))
{
@@ -385,18 +384,13 @@ nautilus_icon_info_lookup (GIcon *icon,
return g_object_ref (icon_info);
}
-
- gtkicon_info = gtk_icon_theme_lookup_by_gicon_for_scale (gtk_icon_theme_get_default (),
- icon, size, scale, 0);
- if (gtkicon_info == NULL)
- {
- return nautilus_icon_info_new_for_pixbuf (NULL, scale);
- }
-
- if (G_IS_THEMED_ICON (icon))
+ else if (G_IS_THEMED_ICON (icon))
{
+ const char * const *names;
ThemedIconKey lookup_key;
ThemedIconKey *key;
+ GtkIconTheme *icon_theme;
+ GtkIconInfo *gtkicon_info;
const char *filename;
if (themed_icon_cache == NULL)
@@ -408,6 +402,17 @@ nautilus_icon_info_lookup (GIcon *icon,
(GDestroyNotify) g_object_unref);
}
+ names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+
+ icon_theme = gtk_icon_theme_get_default ();
+ gtkicon_info = gtk_icon_theme_choose_icon_for_scale (icon_theme, (const char **) names,
+ size, scale, GTK_ICON_LOOKUP_FORCE_SIZE);
+
+ if (gtkicon_info == NULL)
+ {
+ return nautilus_icon_info_new_for_pixbuf (NULL, scale);
+ }
+
filename = gtk_icon_info_get_filename (gtkicon_info);
if (filename == NULL)
{
@@ -420,22 +425,49 @@ nautilus_icon_info_lookup (GIcon *icon,
lookup_key.size = size;
icon_info = g_hash_table_lookup (themed_icon_cache, &lookup_key);
- if (!icon_info)
+ if (icon_info)
{
- icon_info = nautilus_icon_info_new_for_icon_info (gtkicon_info, scale);
-
- key = themed_icon_key_new (filename, scale, size);
- g_hash_table_insert (themed_icon_cache, key, icon_info);
+ g_object_unref (gtkicon_info);
+ return g_object_ref (icon_info);
}
+ icon_info = nautilus_icon_info_new_for_icon_info (gtkicon_info, scale);
+
+ key = themed_icon_key_new (filename, scale, size);
+ g_hash_table_insert (themed_icon_cache, key, icon_info);
+
+ g_object_unref (gtkicon_info);
+
return g_object_ref (icon_info);
}
else
{
- g_autoptr (GdkPixbuf) pixbuf = NULL;
+ GdkPixbuf *pixbuf;
+ GtkIconInfo *gtk_icon_info;
+
+ gtk_icon_info = gtk_icon_theme_lookup_by_gicon_for_scale (gtk_icon_theme_get_default (),
+ icon,
+ size,
+ scale,
+ GTK_ICON_LOOKUP_FORCE_SIZE);
+ if (gtk_icon_info != NULL)
+ {
+ pixbuf = gtk_icon_info_load_icon (gtk_icon_info, NULL);
+ g_object_unref (gtk_icon_info);
+ }
+ else
+ {
+ pixbuf = NULL;
+ }
+
+ icon_info = nautilus_icon_info_new_for_pixbuf (pixbuf, scale);
+
+ if (pixbuf != NULL)
+ {
+ g_object_unref (pixbuf);
+ }
- pixbuf = gtk_icon_info_load_icon (gtkicon_info, NULL);
- return nautilus_icon_info_new_for_pixbuf (pixbuf, scale);
+ return icon_info;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]