diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index b5a4983157..47b5b675b0 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -174,6 +174,54 @@ gtk_icon_helper_load_paintable (GtkIconHelper *self, return paintable; } +void +_gtk_icon_helper_preload (GtkIconHelper *self) +{ + GtkIconTheme *icon_theme; + GtkIconLookupFlags flags = 0; + int size, scale; + GtkCssStyle *style; + GIcon *gicon = NULL; + GIcon *free_gicon = NULL; + + switch (gtk_image_definition_get_storage_type (self->def)) + { + case GTK_IMAGE_ICON_NAME: + if (self->use_fallback) + free_gicon = g_themed_icon_new_with_default_fallbacks (gtk_image_definition_get_icon_name (self->def)); + else + free_gicon = g_themed_icon_new (gtk_image_definition_get_icon_name (self->def)); + gicon = free_gicon; + break; + case GTK_IMAGE_GICON: + gicon = gtk_image_definition_get_gicon (self->def) ; + break; + case GTK_IMAGE_EMPTY: + case GTK_IMAGE_PAINTABLE: + default: + break; + } + + if (gicon && G_IS_THEMED_ICON (gicon)) + { + style = gtk_css_node_get_style (self->node); + icon_theme = gtk_css_icon_theme_value_get_icon_theme + (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_THEME)); + flags |= get_icon_lookup_flags (self, style, + gtk_widget_get_direction (self->owner)); + size = gtk_icon_helper_get_size (self); + scale = gtk_widget_get_scale_factor (self->owner); + + gtk_icon_theme_choose_icon_async (icon_theme, + (const gchar **)g_themed_icon_get_names (G_THEMED_ICON (gicon)), + size, scale, + flags, NULL, NULL, NULL); + } + + if (free_gicon) + g_object_unref (free_gicon); +} + static void gtk_icon_helper_ensure_paintable (GtkIconHelper *self) { diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h index b7656bb849..9fbed2a92c 100644 --- a/gtk/gtkiconhelperprivate.h +++ b/gtk/gtkiconhelperprivate.h @@ -48,6 +48,7 @@ void _gtk_icon_helper_set_icon_name (GtkIconHelper *self, const gchar *icon_name); void _gtk_icon_helper_set_paintable (GtkIconHelper *self, GdkPaintable *paintable); +void _gtk_icon_helper_preload (GtkIconHelper *self); gboolean _gtk_icon_helper_set_pixel_size (GtkIconHelper *self, gint pixel_size); diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 8a415750e9..ad59d97b14 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -1294,6 +1294,8 @@ gtk_image_style_updated (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_image_parent_class)->style_updated (widget); + _gtk_icon_helper_preload (priv->icon_helper); + priv->baseline_align = 0.0; }