static GtkCssValue * gtk_css_value_icon_theme_compute (GtkCssValue *icon_theme, guint property_id, GtkStyleProvider *provider, GtkCssStyle *style, GtkCssStyle *parent_style) { GtkIconTheme *icontheme; if (icon_theme->icontheme) icontheme = icon_theme->icontheme; else icontheme = gtk_icon_theme_get_for_display (_gtk_settings_get_display (gtk_style_provider_get_settings (provider))); return gtk_css_icon_theme_value_new (icontheme); }
static GdkPaintable * get_image_paintable (GtkImage *image) { const gchar *icon_name; GtkIconTheme *icon_theme; GtkIconInfo *icon_info; switch (gtk_image_get_storage_type (image)) { case GTK_IMAGE_PAINTABLE: return g_object_ref (gtk_image_get_paintable (image)); case GTK_IMAGE_ICON_NAME: icon_name = gtk_image_get_icon_name (image); icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (GTK_WIDGET (image))); icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, 48, GTK_ICON_LOOKUP_GENERIC_FALLBACK); if (icon_info == NULL) return NULL; return GDK_PAINTABLE (gtk_icon_info_load_texture (icon_info)); default: g_warning ("Image storage type %d not handled", gtk_image_get_storage_type (image)); return NULL; } }
static void draw_spinbutton (GtkWidget *widget, cairo_t *cr, gint x, gint y, gint width, gint *height) { GtkStyleContext *spin_context; GtkStyleContext *entry_context; GtkStyleContext *up_context; GtkStyleContext *down_context; GtkIconTheme *icon_theme; GtkIconInfo *icon_info; GdkPixbuf *pixbuf; GdkTexture *texture; gint icon_width, icon_height, icon_size; gint button_width; gint contents_x, contents_y, contents_width, contents_height; /* This information is taken from the GtkSpinButton docs, see "CSS nodes" */ spin_context = get_style (NULL, "spinbutton.horizontal:focus"); entry_context = get_style (spin_context, "entry:focus"); up_context = get_style (spin_context, "button.up:focus:active"); down_context = get_style (spin_context, "button.down:focus"); *height = 0; query_size (spin_context, NULL, height); query_size (entry_context, NULL, height); query_size (up_context, NULL, height); query_size (down_context, NULL, height); button_width = *height; draw_style_common (spin_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL); draw_style_common (entry_context, cr, x, y, width, *height, NULL, NULL, NULL, NULL); icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget)); gtk_style_context_get (up_context, "min-width", &icon_width, "min-height", &icon_height, NULL); icon_size = MIN (icon_width, icon_height); icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-add-symbolic", icon_size, 0); pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, up_context, NULL, NULL); texture = gdk_texture_new_for_pixbuf (pixbuf); g_object_unref (icon_info); draw_style_common (up_context, cr, x + width - button_width, y, button_width, *height, &contents_x, &contents_y, &contents_width, &contents_height); gtk_render_icon (up_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2); g_object_unref (pixbuf); g_object_unref (texture); gtk_style_context_get (down_context, "min-width", &icon_width, "min-height", &icon_height, NULL); icon_size = MIN (icon_width, icon_height); icon_info = gtk_icon_theme_lookup_icon (icon_theme, "list-remove-symbolic", icon_size, 0); pixbuf = gtk_icon_info_load_symbolic_for_context (icon_info, down_context, NULL, NULL); texture = gdk_texture_new_for_pixbuf (pixbuf); g_object_unref (icon_info); draw_style_common (down_context, cr, x + width - 2 * button_width, y, button_width, *height, &contents_x, &contents_y, &contents_width, &contents_height); gtk_render_icon (down_context, cr, texture, contents_x, contents_y + (contents_height - icon_size) / 2); g_object_unref (pixbuf); g_object_unref (texture); g_object_unref (down_context); g_object_unref (up_context); g_object_unref (entry_context); g_object_unref (spin_context); }