-gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
- GtkWidget *widget)
-{
- GtkCellRendererPixbufPrivate *priv;
-
- priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cellpixbuf);
-
- if (cellpixbuf->pixbuf)
- g_object_unref (cellpixbuf->pixbuf);
-
- cellpixbuf->pixbuf = gtk_widget_render_icon (widget,
- priv->stock_id,
- priv->stock_size,
- priv->stock_detail);
-
- g_object_notify (G_OBJECT (cellpixbuf), "pixbuf");
-}
-
-static void
-gtk_cell_renderer_pixbuf_create_themed_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
- GtkWidget *widget)
-{
- GtkCellRendererPixbufPrivate *priv;
- GdkScreen *screen;
- GtkIconTheme *icon_theme;
- GtkSettings *settings;
- gint width, height;
- GError *error = NULL;
-
- priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cellpixbuf);
-
- if (cellpixbuf->pixbuf)
- {
- g_object_unref (cellpixbuf->pixbuf);
- cellpixbuf->pixbuf = NULL;
- }
-
- screen = gtk_widget_get_screen (GTK_WIDGET (widget));
- icon_theme = gtk_icon_theme_get_for_screen (screen);
- settings = gtk_settings_get_for_screen (screen);
-
- if (!gtk_icon_size_lookup_for_settings (settings,
- priv->stock_size,
- &width, &height))
- {
- g_warning ("Invalid icon size %u\n", priv->stock_size);
- width = height = 24;
- }
-
- if (priv->icon_name)
- cellpixbuf->pixbuf = gtk_icon_theme_load_icon (icon_theme,
- priv->icon_name,
- MIN (width, height),
- GTK_ICON_LOOKUP_USE_BUILTIN,
- &error);
- else if (priv->gicon)
- {
- GtkIconInfo *info;
-
- info = gtk_icon_theme_lookup_by_gicon (icon_theme,
- priv->gicon,
- MIN (width, height),
- GTK_ICON_LOOKUP_USE_BUILTIN);
- if (!info)
- {
- g_set_error (&error, GTK_ICON_THEME_ERROR, GTK_ICON_THEME_NOT_FOUND,
- _("Icon not present in theme"));
- }
- else
- {
- cellpixbuf->pixbuf = gtk_icon_info_load_icon (info, &error);
- gtk_icon_info_free (info);
- }
- }
-
- if (!cellpixbuf->pixbuf)
- {
- g_warning ("could not load image: %s\n", error->message);
- g_error_free (error);
- }
-
- g_object_notify (G_OBJECT (cellpixbuf), "pixbuf");
-}
-
-static GdkPixbuf *
-create_colorized_pixbuf (GdkPixbuf *src,
- GdkColor *new_color)
-{
- gint i, j;
- gint width, height, has_alpha, src_row_stride, dst_row_stride;
- gint red_value, green_value, blue_value;
- guchar *target_pixels;
- guchar *original_pixels;
- guchar *pixsrc;
- guchar *pixdest;
- GdkPixbuf *dest;
-
- red_value = new_color->red / 255.0;
- green_value = new_color->green / 255.0;
- blue_value = new_color->blue / 255.0;
-
- dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
- gdk_pixbuf_get_has_alpha (src),
- gdk_pixbuf_get_bits_per_sample (src),
- gdk_pixbuf_get_width (src),
- gdk_pixbuf_get_height (src));
-
- has_alpha = gdk_pixbuf_get_has_alpha (src);
- width = gdk_pixbuf_get_width (src);
- height = gdk_pixbuf_get_height (src);
- src_row_stride = gdk_pixbuf_get_rowstride (src);
- dst_row_stride = gdk_pixbuf_get_rowstride (dest);
- target_pixels = gdk_pixbuf_get_pixels (dest);
- original_pixels = gdk_pixbuf_get_pixels (src);
-
- for (i = 0; i < height; i++) {
- pixdest = target_pixels + i*dst_row_stride;
- pixsrc = original_pixels + i*src_row_stride;
- for (j = 0; j < width; j++) {
- *pixdest++ = (*pixsrc++ * red_value) >> 8;
- *pixdest++ = (*pixsrc++ * green_value) >> 8;
- *pixdest++ = (*pixsrc++ * blue_value) >> 8;
- if (has_alpha) {
- *pixdest++ = *pixsrc++;
- }
- }
- }
- return dest;
-}
-
-
-static void
-gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
- GtkWidget *widget,
- GdkRectangle *cell_area,
- gint *x_offset,
- gint *y_offset,
- gint *width,
- gint *height)