summaryrefslogtreecommitdiff
path: root/gtk/gtkicontheme.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2010-11-05 10:33:16 +0100
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-11-08 11:31:01 +0900
commit4239e499825e3fb3166e79a52186469d8c9238af (patch)
tree788ab0536a458a52e0d45bce13dadf006bef97a5 /gtk/gtkicontheme.c
parentcb51ad606fcc0d88e7fe1c0612f1a91e69ad1d07 (diff)
downloadgtk+-4239e499825e3fb3166e79a52186469d8c9238af.tar.gz
icon-theme: support pixbufs implementing the GIcon interface
https://bugzilla.gnome.org/show_bug.cgi?id=634060
Diffstat (limited to 'gtk/gtkicontheme.c')
-rw-r--r--gtk/gtkicontheme.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index f4821d6d0f..199f8468ba 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -137,6 +137,7 @@ struct _GtkIconInfo
GdkPixbuf *pixbuf;
GError *load_error;
gdouble scale;
+ gboolean emblems_applied;
guint ref_count;
};
@@ -2757,6 +2758,9 @@ apply_emblems (GtkIconInfo *info)
if (info->emblem_infos == NULL)
return;
+ if (info->emblems_applied)
+ return;
+
w = gdk_pixbuf_get_width (info->pixbuf);
h = gdk_pixbuf_get_height (info->pixbuf);
@@ -2819,6 +2823,8 @@ apply_emblems (GtkIconInfo *info)
g_object_unref (info->pixbuf);
info->pixbuf = icon;
}
+
+ info->emblems_applied = TRUE;
}
/* This function contains the complicated logic for deciding
@@ -2840,7 +2846,10 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
return TRUE;
if (icon_info->pixbuf)
- return TRUE;
+ {
+ apply_emblems (icon_info);
+ return TRUE;
+ }
if (icon_info->load_error)
return FALSE;
@@ -3721,6 +3730,39 @@ gtk_icon_theme_lookup_by_gicon (GtkIconTheme *icon_theme,
return info;
}
+ else if (GDK_IS_PIXBUF (icon))
+ {
+ GdkPixbuf *pixbuf;
+
+ pixbuf = GDK_PIXBUF (icon);
+
+ if ((flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0)
+ {
+ gint width, height, max;
+ gdouble scale;
+ GdkPixbuf *scaled;
+
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ max = MAX (width, height);
+ scale = (gdouble) size / (gdouble) max;
+
+ scaled = gdk_pixbuf_scale_simple (pixbuf,
+ 0.5 + width * scale,
+ 0.5 + height * scale,
+ GDK_INTERP_BILINEAR);
+
+ info = gtk_icon_info_new_for_pixbuf (icon_theme, scaled);
+
+ g_object_unref (scaled);
+ }
+ else
+ {
+ info = gtk_icon_info_new_for_pixbuf (icon_theme, pixbuf);
+ }
+
+ return info;
+ }
return NULL;
}