-gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
- GtkWidget *widget)
-{
- GtkCellRendererPixbufPriv *priv = cellpixbuf->priv;
-
- if (priv->pixbuf)
- g_object_unref (priv->pixbuf);
-
- priv->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)
-{
- GtkCellRendererPixbufPriv *priv = cellpixbuf->priv;
- GdkScreen *screen;
- GtkIconTheme *icon_theme;
- GtkSettings *settings;
- gint width, height;
- GtkIconInfo *info;
-
- if (priv->pixbuf)
- {
- g_object_unref (priv->pixbuf);
- priv->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)
- info = gtk_icon_theme_lookup_icon (icon_theme,
- priv->icon_name,
- MIN (width, height),
- GTK_ICON_LOOKUP_USE_BUILTIN);
- else if (priv->gicon)
- info = gtk_icon_theme_lookup_by_gicon (icon_theme,
- priv->gicon,
- MIN (width, height),
- GTK_ICON_LOOKUP_USE_BUILTIN);
- else
- info = NULL;
-
- if (info)
- {
- GtkStyle *style;
-
- style = gtk_widget_get_style (GTK_WIDGET (widget));
- priv->pixbuf = gtk_icon_info_load_symbolic_for_style (info,
- style,
- GTK_STATE_NORMAL,
- NULL,
- NULL);
- gtk_icon_info_free (info);
- }
-
- g_object_notify (G_OBJECT (cellpixbuf), "pixbuf");
-}
-
-static GdkPixbuf *
-create_symbolic_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
- GtkWidget *widget,
- GtkStateType state)
-{
- GtkCellRendererPixbufPriv *priv = cellpixbuf->priv;
- GdkScreen *screen;
- GtkIconTheme *icon_theme;
- GtkSettings *settings;
- gint width, height;
- GtkIconInfo *info;
- GdkPixbuf *pixbuf;
-
- /* Not a named symbolic icon? */
- if (priv->icon_name) {
- if (!g_str_has_suffix (priv->icon_name, "-symbolic"))
- return NULL;
- } else if (priv->gicon) {
- const gchar * const *names;
- if (!G_IS_THEMED_ICON (priv->gicon))
- return NULL;
- names = g_themed_icon_get_names (G_THEMED_ICON (priv->gicon));
- if (names == NULL || !g_str_has_suffix (names[0], "-symbolic"))
- return NULL;
- } else {
- return 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)
- info = gtk_icon_theme_lookup_icon (icon_theme,
- priv->icon_name,
- MIN (width, height),
- GTK_ICON_LOOKUP_USE_BUILTIN);
- else if (priv->gicon)
- info = gtk_icon_theme_lookup_by_gicon (icon_theme,
- priv->gicon,
- MIN (width, height),
- GTK_ICON_LOOKUP_USE_BUILTIN);
- else
- return NULL;
-
- if (info)
- {
- GtkStyle *style;
-
- style = gtk_widget_get_style (GTK_WIDGET (widget));
- pixbuf = gtk_icon_info_load_symbolic_for_style (info,
- style, state,
- NULL, NULL);
- gtk_icon_info_free (info);
- return pixbuf;
- }
-
- return NULL;
-}
-
-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)