]> Pileus Git - ~andy/gtk/blob - gtk/gtkcellrendererpixbuf.c
remove unused function.
[~andy/gtk] / gtk / gtkcellrendererpixbuf.c
1 /* gtkcellrendererpixbuf.c
2  * Copyright (C) 2000  Red Hat, Inc.,  Jonathan Blandford <jrb@redhat.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <config.h>
21 #include <stdlib.h>
22 #include "gtkalias.h"
23 #include "gtkcellrendererpixbuf.h"
24 #include "gtkiconfactory.h"
25 #include "gtkintl.h"
26
27 static void gtk_cell_renderer_pixbuf_get_property  (GObject                    *object,
28                                                     guint                       param_id,
29                                                     GValue                     *value,
30                                                     GParamSpec                 *pspec);
31 static void gtk_cell_renderer_pixbuf_set_property  (GObject                    *object,
32                                                     guint                       param_id,
33                                                     const GValue               *value,
34                                                     GParamSpec                 *pspec);
35 static void gtk_cell_renderer_pixbuf_init       (GtkCellRendererPixbuf      *celltext);
36 static void gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class);
37 static void gtk_cell_renderer_pixbuf_finalize   (GObject                    *object);
38 static void gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
39                                                           GtkWidget             *widget);
40 static void gtk_cell_renderer_pixbuf_get_size   (GtkCellRenderer            *cell,
41                                                  GtkWidget                  *widget,
42                                                  GdkRectangle               *rectangle,
43                                                  gint                       *x_offset,
44                                                  gint                       *y_offset,
45                                                  gint                       *width,
46                                                  gint                       *height);
47 static void gtk_cell_renderer_pixbuf_render     (GtkCellRenderer            *cell,
48                                                  GdkDrawable                *window,
49                                                  GtkWidget                  *widget,
50                                                  GdkRectangle               *background_area,
51                                                  GdkRectangle               *cell_area,
52                                                  GdkRectangle               *expose_area,
53                                                  GtkCellRendererState        flags);
54
55
56 enum {
57         PROP_ZERO,
58         PROP_PIXBUF,
59         PROP_PIXBUF_EXPANDER_OPEN,
60         PROP_PIXBUF_EXPANDER_CLOSED,
61         PROP_STOCK_ID,
62         PROP_STOCK_SIZE,
63         PROP_STOCK_DETAIL,
64         PROP_FOLLOW_STATE
65 };
66
67 static gpointer parent_class;
68
69
70 #define GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER_PIXBUF, GtkCellRendererPixbufPrivate))
71
72 typedef struct _GtkCellRendererPixbufPrivate GtkCellRendererPixbufPrivate;
73 struct _GtkCellRendererPixbufPrivate
74 {
75   gchar *stock_id;
76   GtkIconSize stock_size;
77   gchar *stock_detail;
78   gboolean follow_state;
79 };
80
81
82 GType
83 gtk_cell_renderer_pixbuf_get_type (void)
84 {
85   static GType cell_pixbuf_type = 0;
86
87   if (!cell_pixbuf_type)
88     {
89       static const GTypeInfo cell_pixbuf_info =
90       {
91         sizeof (GtkCellRendererPixbufClass),
92         NULL,           /* base_init */
93         NULL,           /* base_finalize */
94         (GClassInitFunc) gtk_cell_renderer_pixbuf_class_init,
95         NULL,           /* class_finalize */
96         NULL,           /* class_data */
97         sizeof (GtkCellRendererPixbuf),
98         0,              /* n_preallocs */
99         (GInstanceInitFunc) gtk_cell_renderer_pixbuf_init,
100       };
101
102       cell_pixbuf_type =
103         g_type_register_static (GTK_TYPE_CELL_RENDERER, "GtkCellRendererPixbuf",
104                                 &cell_pixbuf_info, 0);
105     }
106
107   return cell_pixbuf_type;
108 }
109
110 static void
111 gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cellpixbuf)
112 {
113   GtkCellRendererPixbufPrivate *priv;
114
115   priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cellpixbuf);
116   priv->stock_size = GTK_ICON_SIZE_MENU;
117 }
118
119 static void
120 gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
121 {
122   GObjectClass *object_class = G_OBJECT_CLASS (class);
123   GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
124
125   parent_class = g_type_class_peek_parent (class);
126
127   object_class->finalize = gtk_cell_renderer_pixbuf_finalize;
128
129   object_class->get_property = gtk_cell_renderer_pixbuf_get_property;
130   object_class->set_property = gtk_cell_renderer_pixbuf_set_property;
131
132   cell_class->get_size = gtk_cell_renderer_pixbuf_get_size;
133   cell_class->render = gtk_cell_renderer_pixbuf_render;
134
135   g_object_class_install_property (object_class,
136                                    PROP_PIXBUF,
137                                    g_param_spec_object ("pixbuf",
138                                                         P_("Pixbuf Object"),
139                                                         P_("The pixbuf to render"),
140                                                         GDK_TYPE_PIXBUF,
141                                                         G_PARAM_READABLE |
142                                                         G_PARAM_WRITABLE));
143
144   g_object_class_install_property (object_class,
145                                    PROP_PIXBUF_EXPANDER_OPEN,
146                                    g_param_spec_object ("pixbuf_expander_open",
147                                                         P_("Pixbuf Expander Open"),
148                                                         P_("Pixbuf for open expander"),
149                                                         GDK_TYPE_PIXBUF,
150                                                         G_PARAM_READABLE |
151                                                         G_PARAM_WRITABLE));
152
153   g_object_class_install_property (object_class,
154                                    PROP_PIXBUF_EXPANDER_CLOSED,
155                                    g_param_spec_object ("pixbuf_expander_closed",
156                                                         P_("Pixbuf Expander Closed"),
157                                                         P_("Pixbuf for closed expander"),
158                                                         GDK_TYPE_PIXBUF,
159                                                         G_PARAM_READABLE |
160                                                         G_PARAM_WRITABLE));
161
162   g_object_class_install_property (object_class,
163                                    PROP_STOCK_ID,
164                                    g_param_spec_string ("stock_id",
165                                                         P_("Stock ID"),
166                                                         P_("The stock ID of the stock icon to render"),
167                                                         NULL,
168                                                         G_PARAM_READWRITE));
169
170   g_object_class_install_property (object_class,
171                                    PROP_STOCK_SIZE,
172                                    g_param_spec_uint ("stock_size",
173                                                       P_("Size"),
174                                                       P_("The GtkIconSize value that specifies the size of the rendered icon"),
175                                                       0,
176                                                       G_MAXUINT,
177                                                       GTK_ICON_SIZE_MENU,
178                                                       G_PARAM_READWRITE));
179
180   g_object_class_install_property (object_class,
181                                    PROP_STOCK_DETAIL,
182                                    g_param_spec_string ("stock_detail",
183                                                         P_("Detail"),
184                                                         P_("Render detail to pass to the theme engine"),
185                                                         NULL,
186                                                         G_PARAM_READWRITE));
187
188   /**
189    * GtkCellRendererPixbuf:follow-state:
190    *
191    * Specifies whether the rendered pixbuf should be colorized
192    * according to the #GtkCellRendererState.
193    *
194    * Since: 2.8
195    */
196   g_object_class_install_property (object_class,
197                                    PROP_FOLLOW_STATE,
198                                    g_param_spec_boolean ("follow_state",
199                                                          P_("Follow State"),
200                                                          P_("Whether the rendered pixbuf should be "
201                                                             "colorized according to the state"),
202                                                          FALSE,
203                                                          G_PARAM_READWRITE));
204
205
206   g_type_class_add_private (object_class, sizeof (GtkCellRendererPixbufPrivate));
207 }
208
209 static void
210 gtk_cell_renderer_pixbuf_finalize (GObject *object)
211 {
212   GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
213   GtkCellRendererPixbufPrivate *priv;
214
215   priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (object);
216
217   if (cellpixbuf->pixbuf)
218     g_object_unref (cellpixbuf->pixbuf);
219
220   if (priv->stock_id)
221     g_free (priv->stock_id);
222
223   if (priv->stock_detail)
224     g_free (priv->stock_detail);
225
226   (* G_OBJECT_CLASS (parent_class)->finalize) (object);
227 }
228
229 static void
230 gtk_cell_renderer_pixbuf_get_property (GObject        *object,
231                                        guint           param_id,
232                                        GValue         *value,
233                                        GParamSpec     *pspec)
234 {
235   GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
236   GtkCellRendererPixbufPrivate *priv;
237
238   priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (object);
239   
240   switch (param_id)
241     {
242     case PROP_PIXBUF:
243       g_value_set_object (value,
244                           cellpixbuf->pixbuf ? G_OBJECT (cellpixbuf->pixbuf) : NULL);
245       break;
246     case PROP_PIXBUF_EXPANDER_OPEN:
247       g_value_set_object (value,
248                           cellpixbuf->pixbuf_expander_open ? G_OBJECT (cellpixbuf->pixbuf_expander_open) : NULL);
249       break;
250     case PROP_PIXBUF_EXPANDER_CLOSED:
251       g_value_set_object (value,
252                           cellpixbuf->pixbuf_expander_closed ? G_OBJECT (cellpixbuf->pixbuf_expander_closed) : NULL);
253       break;
254     case PROP_STOCK_ID:
255       g_value_set_string (value, priv->stock_id);
256       break;
257     case PROP_STOCK_SIZE:
258       g_value_set_uint (value, priv->stock_size);
259       break;
260     case PROP_STOCK_DETAIL:
261       g_value_set_string (value, priv->stock_detail);
262       break;
263     case PROP_FOLLOW_STATE:
264       g_value_set_boolean (value, priv->follow_state);
265       break;
266     default:
267       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
268       break;
269     }
270 }
271
272
273 static void
274 gtk_cell_renderer_pixbuf_set_property (GObject      *object,
275                                        guint         param_id,
276                                        const GValue *value,
277                                        GParamSpec   *pspec)
278 {
279   GdkPixbuf *pixbuf;
280   GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
281   GtkCellRendererPixbufPrivate *priv;
282
283   priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (object);
284   
285   switch (param_id)
286     {
287     case PROP_PIXBUF:
288       pixbuf = (GdkPixbuf*) g_value_get_object (value);
289       if (pixbuf)
290         g_object_ref (pixbuf);
291       if (cellpixbuf->pixbuf)
292         g_object_unref (cellpixbuf->pixbuf);
293       cellpixbuf->pixbuf = pixbuf;
294       break;
295     case PROP_PIXBUF_EXPANDER_OPEN:
296       pixbuf = (GdkPixbuf*) g_value_get_object (value);
297       if (pixbuf)
298         g_object_ref (pixbuf);
299       if (cellpixbuf->pixbuf_expander_open)
300         g_object_unref (cellpixbuf->pixbuf_expander_open);
301       cellpixbuf->pixbuf_expander_open = pixbuf;
302       break;
303     case PROP_PIXBUF_EXPANDER_CLOSED:
304       pixbuf = (GdkPixbuf*) g_value_get_object (value);
305       if (pixbuf)
306         g_object_ref (pixbuf);
307       if (cellpixbuf->pixbuf_expander_closed)
308         g_object_unref (cellpixbuf->pixbuf_expander_closed);
309       cellpixbuf->pixbuf_expander_closed = pixbuf;
310       break;
311     case PROP_STOCK_ID:
312       if (priv->stock_id)
313         {
314           if (cellpixbuf->pixbuf)
315             {
316               g_object_unref (cellpixbuf->pixbuf);
317               cellpixbuf->pixbuf = NULL;
318             }
319           g_free (priv->stock_id);
320         }
321       priv->stock_id = g_strdup (g_value_get_string (value));
322       break;
323     case PROP_STOCK_SIZE:
324       priv->stock_size = g_value_get_uint (value);
325       break;
326     case PROP_STOCK_DETAIL:
327       if (priv->stock_detail)
328         g_free (priv->stock_detail);
329       priv->stock_detail = g_strdup (g_value_get_string (value));
330       break;
331     case PROP_FOLLOW_STATE:
332       priv->follow_state = g_value_get_boolean (value);
333       break;
334     default:
335       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
336       break;
337     }
338
339   if (cellpixbuf->pixbuf && priv->stock_id)
340     {
341       g_object_unref (cellpixbuf->pixbuf);
342       cellpixbuf->pixbuf = NULL;
343     }
344 }
345
346 /**
347  * gtk_cell_renderer_pixbuf_new:
348  * 
349  * Creates a new #GtkCellRendererPixbuf. Adjust rendering
350  * parameters using object properties. Object properties can be set
351  * globally (with g_object_set()). Also, with #GtkTreeViewColumn, you
352  * can bind a property to a value in a #GtkTreeModel. For example, you
353  * can bind the "pixbuf" property on the cell renderer to a pixbuf value
354  * in the model, thus rendering a different image in each row of the
355  * #GtkTreeView.
356  * 
357  * Return value: the new cell renderer
358  **/
359 GtkCellRenderer *
360 gtk_cell_renderer_pixbuf_new (void)
361 {
362   return g_object_new (GTK_TYPE_CELL_RENDERER_PIXBUF, NULL);
363 }
364
365 static void
366 gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
367                                               GtkWidget             *widget)
368 {
369   GtkCellRendererPixbufPrivate *priv;
370
371   priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cellpixbuf);
372
373   if (cellpixbuf->pixbuf)
374     g_object_unref (cellpixbuf->pixbuf);
375
376   cellpixbuf->pixbuf = gtk_widget_render_icon (widget,
377                                                priv->stock_id,
378                                                priv->stock_size,
379                                                priv->stock_detail);
380 }
381
382 static GdkPixbuf *
383 create_colorized_pixbuf (GdkPixbuf *src, 
384                          GdkColor  *new_color)
385 {
386   gint i, j;
387   gint width, height, has_alpha, src_row_stride, dst_row_stride;
388   gint red_value, green_value, blue_value;
389   guchar *target_pixels;
390   guchar *original_pixels;
391   guchar *pixsrc;
392   guchar *pixdest;
393   GdkPixbuf *dest;
394   
395   red_value = new_color->red / 255.0;
396   green_value = new_color->green / 255.0;
397   blue_value = new_color->blue / 255.0;
398   
399   dest = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src),
400                          gdk_pixbuf_get_has_alpha (src),
401                          gdk_pixbuf_get_bits_per_sample (src),
402                          gdk_pixbuf_get_width (src),
403                          gdk_pixbuf_get_height (src));
404   
405   has_alpha = gdk_pixbuf_get_has_alpha (src);
406   width = gdk_pixbuf_get_width (src);
407   height = gdk_pixbuf_get_height (src);
408   src_row_stride = gdk_pixbuf_get_rowstride (src);
409   dst_row_stride = gdk_pixbuf_get_rowstride (dest);
410   target_pixels = gdk_pixbuf_get_pixels (dest);
411   original_pixels = gdk_pixbuf_get_pixels (src);
412   
413   for (i = 0; i < height; i++) {
414     pixdest = target_pixels + i*dst_row_stride;
415     pixsrc = original_pixels + i*src_row_stride;
416     for (j = 0; j < width; j++) {               
417       *pixdest++ = (*pixsrc++ * red_value) >> 8;
418       *pixdest++ = (*pixsrc++ * green_value) >> 8;
419       *pixdest++ = (*pixsrc++ * blue_value) >> 8;
420       if (has_alpha) {
421         *pixdest++ = *pixsrc++;
422       }
423     }
424   }
425   return dest;
426 }
427
428
429 static void
430 gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
431                                    GtkWidget       *widget,
432                                    GdkRectangle    *cell_area,
433                                    gint            *x_offset,
434                                    gint            *y_offset,
435                                    gint            *width,
436                                    gint            *height)
437 {
438   GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
439   GtkCellRendererPixbufPrivate *priv;
440   gint pixbuf_width  = 0;
441   gint pixbuf_height = 0;
442   gint calc_width;
443   gint calc_height;
444
445   priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell);
446
447   if (!cellpixbuf->pixbuf && priv->stock_id)
448     gtk_cell_renderer_pixbuf_create_stock_pixbuf (cellpixbuf, widget);
449
450   if (cellpixbuf->pixbuf)
451     {
452       pixbuf_width  = gdk_pixbuf_get_width (cellpixbuf->pixbuf);
453       pixbuf_height = gdk_pixbuf_get_height (cellpixbuf->pixbuf);
454     }
455   if (cellpixbuf->pixbuf_expander_open)
456     {
457       pixbuf_width  = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_open));
458       pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_open));
459     }
460   if (cellpixbuf->pixbuf_expander_closed)
461     {
462       pixbuf_width  = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_closed));
463       pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_closed));
464     }
465   
466   calc_width  = (gint) cell->xpad * 2 + pixbuf_width;
467   calc_height = (gint) cell->ypad * 2 + pixbuf_height;
468   
469   if (x_offset) *x_offset = 0;
470   if (y_offset) *y_offset = 0;
471
472   if (cell_area && pixbuf_width > 0 && pixbuf_height > 0)
473     {
474       if (x_offset)
475         {
476           *x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
477                         1.0 - cell->xalign : cell->xalign) * 
478                        (cell_area->width - calc_width - 2 * cell->xpad));
479           *x_offset = MAX (*x_offset, 0) + cell->xpad;
480         }
481       if (y_offset)
482         {
483           *y_offset = (cell->yalign *
484                        (cell_area->height - calc_height - 2 * cell->ypad));
485           *y_offset = MAX (*y_offset, 0) + cell->ypad;
486         }
487     }
488
489   if (width)
490     *width = calc_width;
491   
492   if (height)
493     *height = calc_height;
494 }
495
496 static void
497 gtk_cell_renderer_pixbuf_render (GtkCellRenderer      *cell,
498                                  GdkWindow            *window,
499                                  GtkWidget            *widget,
500                                  GdkRectangle         *background_area,
501                                  GdkRectangle         *cell_area,
502                                  GdkRectangle         *expose_area,
503                                  GtkCellRendererState  flags)
504
505 {
506   GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
507   GtkCellRendererPixbufPrivate *priv;
508   GdkPixbuf *pixbuf;
509   GdkPixbuf *invisible = NULL;
510   GdkPixbuf *colorized = NULL;
511   GdkRectangle pix_rect;
512   GdkRectangle draw_rect;
513   gboolean stock_pixbuf = FALSE;
514
515   priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell);
516
517   pixbuf = cellpixbuf->pixbuf;
518   if (cell->is_expander)
519     {
520       if (cell->is_expanded &&
521           cellpixbuf->pixbuf_expander_open != NULL)
522         pixbuf = cellpixbuf->pixbuf_expander_open;
523       else if (! cell->is_expanded &&
524                cellpixbuf->pixbuf_expander_closed != NULL)
525         pixbuf = cellpixbuf->pixbuf_expander_closed;
526     }
527
528   if (!pixbuf && !priv->stock_id)
529     return;
530   else if (!pixbuf && priv->stock_id)
531     stock_pixbuf = TRUE;
532
533   gtk_cell_renderer_pixbuf_get_size (cell, widget, cell_area,
534                                      &pix_rect.x,
535                                      &pix_rect.y,
536                                      &pix_rect.width,
537                                      &pix_rect.height);
538
539   if (stock_pixbuf)
540     pixbuf = cellpixbuf->pixbuf;
541   
542   pix_rect.x += cell_area->x;
543   pix_rect.y += cell_area->y;
544   pix_rect.width  -= cell->xpad * 2;
545   pix_rect.height -= cell->ypad * 2;
546
547   if (!gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect) ||
548       !gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect))
549     return;
550
551   if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE || !cell->sensitive)
552     {
553       GtkIconSource *source;
554       
555       source = gtk_icon_source_new ();
556       gtk_icon_source_set_pixbuf (source, pixbuf);
557       /* The size here is arbitrary; since size isn't
558        * wildcarded in the souce, it isn't supposed to be
559        * scaled by the engine function
560        */
561       gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
562       gtk_icon_source_set_size_wildcarded (source, FALSE);
563       
564      invisible = gtk_style_render_icon (widget->style,
565                                         source,
566                                         gtk_widget_get_direction (widget),
567                                         GTK_STATE_INSENSITIVE,
568                                         /* arbitrary */
569                                         (GtkIconSize)-1,
570                                         widget,
571                                         "gtkcellrendererpixbuf");
572      
573      gtk_icon_source_free (source);
574      
575      pixbuf = invisible;
576     }
577   else if (priv->follow_state && 
578            (flags & (GTK_CELL_RENDERER_SELECTED|GTK_CELL_RENDERER_PRELIT)) != 0)
579     {
580       GtkStateType state;
581
582       if ((flags & GTK_CELL_RENDERER_SELECTED) != 0)
583         {
584           if (GTK_WIDGET_HAS_FOCUS (widget))
585             state = GTK_STATE_SELECTED;
586           else
587             state = GTK_STATE_ACTIVE;
588         }
589       else
590         state = GTK_STATE_PRELIGHT;
591
592       colorized = create_colorized_pixbuf (pixbuf,
593                                            &widget->style->base[state]);
594
595       pixbuf = colorized;
596     }
597
598   gdk_draw_pixbuf (window,
599                    widget->style->black_gc,
600                    pixbuf,
601                    /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */
602                    draw_rect.x - pix_rect.x,
603                    draw_rect.y - pix_rect.y,
604                    draw_rect.x,
605                    draw_rect.y,
606                    draw_rect.width,
607                    draw_rect.height,
608                    GDK_RGB_DITHER_NORMAL,
609                    0, 0);
610   
611   if (invisible)
612     g_object_unref (invisible);
613
614   if (colorized)
615     g_object_unref (colorized);
616 }