static void ensure_pixbuf_for_gicon (GtkIconHelper *self, GtkStyleContext *context) { GtkIconTheme *icon_theme; gint width, height; GtkIconInfo *info; GtkIconLookupFlags flags; if (!check_invalidate_pixbuf (self, context)) return; icon_theme = gtk_icon_theme_get_for_screen (gtk_style_context_get_screen (context)); flags = get_icon_lookup_flags (self, context); ensure_icon_size (self, context, &width, &height); if (self->priv->gicon != NULL) { info = gtk_icon_theme_lookup_by_gicon (icon_theme, self->priv->gicon, MIN (width, height), flags); } else { g_assert_not_reached (); return; } self->priv->rendered_pixbuf = ensure_stated_icon_from_info (self, context, info); if (info) g_object_unref (info); }
static void ensure_surface_for_icon_name_or_gicon (GtkIconHelper *self, GtkStyleContext *context) { GtkIconTheme *icon_theme; gint width, height, scale; GtkIconInfo *info; GtkIconLookupFlags flags; if (!check_invalidate_surface (self, context)) return; icon_theme = gtk_icon_theme_get_default (); flags = get_icon_lookup_flags (self); ensure_icon_size (self, context, &width, &height); scale = get_scale_factor (self, context); if (self->priv->storage_type == GTK_IMAGE_ICON_NAME && self->priv->icon_name != NULL) { info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, self->priv->icon_name, MIN (width, height), scale, flags); } else if (self->priv->storage_type == GTK_IMAGE_GICON && self->priv->gicon != NULL) { info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, self->priv->gicon, MIN (width, height), scale, flags); } else { g_assert_not_reached (); return; } ensure_stated_surface_from_info (self, context, info, scale); if (info) g_object_unref (info); }
static GdkPaintable * ensure_paintable_for_gicon (GtkIconHelper *self, GtkCssStyle *style, GtkTextDirection dir, gint scale, GIcon *gicon, gboolean *symbolic) { GtkIconTheme *icon_theme; gint width, height; GtkIconInfo *info; GtkIconLookupFlags flags; GdkPaintable *paintable; 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, dir); width = height = gtk_icon_helper_get_size (self); info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, gicon, MIN (width, height), scale, flags); if (info == NULL) info = gtk_icon_theme_lookup_icon (icon_theme, "image-missing", width, flags | GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK); *symbolic = gtk_icon_info_is_symbolic (info); paintable = GDK_PAINTABLE (gtk_icon_info_load_texture (info)); g_object_unref (info); if (paintable && scale != 1) { GdkPaintable *orig = paintable; paintable = gtk_scaler_new (orig, scale); g_object_unref (orig); } return paintable; }
static cairo_surface_t * ensure_surface_for_gicon (GtkIconHelper *self, GtkCssStyle *style, GtkTextDirection dir, gint scale, GIcon *gicon) { GtkIconHelperPrivate *priv = self->priv; GtkIconTheme *icon_theme; gint width, height; GtkIconInfo *info; GtkIconLookupFlags flags; cairo_surface_t *surface; GdkPixbuf *destination; gboolean symbolic; 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, dir); ensure_icon_size (self, &width, &height); info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, gicon, MIN (width, height), scale, flags); if (info) { symbolic = gtk_icon_info_is_symbolic (info); if (symbolic) { GdkRGBA fg, success_color, warning_color, error_color; gtk_icon_theme_lookup_symbolic_colors (style, &fg, &success_color, &warning_color, &error_color); destination = gtk_icon_info_load_symbolic (info, &fg, &success_color, &warning_color, &error_color, NULL, NULL); } else { destination = gtk_icon_info_load_icon (info, NULL); } g_object_unref (info); } else { destination = NULL; } if (destination == NULL) { destination = gtk_icon_theme_load_icon (icon_theme, "image-missing", width, flags | GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK, NULL); /* We include this image as resource, so we always have it available or * the icontheme code is broken */ g_assert (destination); symbolic = FALSE; } surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, gtk_widget_get_window (gtk_css_gadget_get_owner (GTK_CSS_GADGET (self)))); if (!symbolic) { GtkCssIconEffect icon_effect; icon_effect = _gtk_css_icon_effect_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_EFFECT)); gtk_css_icon_effect_apply (icon_effect, surface); } else { priv->rendered_surface_is_symbolic = TRUE; } g_object_unref (destination); return surface; }