1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser 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.
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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser 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.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #include "gtkcontainer.h"
29 #include "gtkiconfactory.h"
32 static void gtk_image_class_init (GtkImageClass *klass);
33 static void gtk_image_init (GtkImage *image);
34 static gint gtk_image_expose (GtkWidget *widget,
35 GdkEventExpose *event);
36 static void gtk_image_size_request (GtkWidget *widget,
37 GtkRequisition *requisition);
38 static void gtk_image_destroy (GtkObject *object);
39 static void gtk_image_clear (GtkImage *image);
40 static void gtk_image_reset (GtkImage *image);
41 static void gtk_image_update_size (GtkImage *image,
45 static gpointer parent_class;
48 gtk_image_get_type (void)
50 static GtkType image_type = 0;
54 static const GtkTypeInfo image_info =
58 sizeof (GtkImageClass),
59 (GtkClassInitFunc) gtk_image_class_init,
60 (GtkObjectInitFunc) gtk_image_init,
61 /* reserved_1 */ NULL,
62 /* reserved_2 */ NULL,
63 (GtkClassInitFunc) NULL,
66 image_type = gtk_type_unique (GTK_TYPE_MISC, &image_info);
73 gtk_image_class_init (GtkImageClass *class)
75 GtkObjectClass *object_class;
76 GtkWidgetClass *widget_class;
78 parent_class = g_type_class_peek_parent (class);
80 object_class = (GtkObjectClass *) class;
82 object_class->destroy = gtk_image_destroy;
84 widget_class = (GtkWidgetClass*) class;
86 widget_class->expose_event = gtk_image_expose;
87 widget_class->size_request = gtk_image_size_request;
91 gtk_image_init (GtkImage *image)
93 GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW);
95 image->storage_type = GTK_IMAGE_EMPTY;
99 gtk_image_destroy (GtkObject *object)
101 GtkImage *image = GTK_IMAGE (object);
103 gtk_image_clear (image);
105 GTK_OBJECT_CLASS (parent_class)->destroy (object);
110 * gtk_image_new_from_pixmap:
111 * @pixmap: a #GdkPixmap, or %NULL
112 * @mask: a #GdkBitmap, or %NULL
114 * Creates a #GtkImage widget displaying @pixmap with a @mask.
115 * A #GdkImage is a server-side image buffer in the pixel format of the
116 * current display. The #GtkImage does not assume a reference to the
117 * pixmap or mask; you still need to unref them if you own references.
118 * #GtkImage will add its own reference rather than adopting yours.
120 * Return value: a new #GtkImage
123 gtk_image_new_from_pixmap (GdkPixmap *pixmap,
128 image = gtk_type_new (GTK_TYPE_IMAGE);
130 gtk_image_set_from_pixmap (image, pixmap, mask);
132 return GTK_WIDGET (image);
136 * gtk_image_new_from_image:
137 * @image: a #GdkImage, or %NULL
138 * @mask: a #GdkBitmap, or %NULL
140 * Creates a #GtkImage widget displaying a @image with a @mask.
141 * A #GdkImage is a client-side image buffer in the pixel format of the
143 * The #GtkImage does not assume a reference to the
144 * image or mask; you still need to unref them if you own references.
145 * #GtkImage will add its own reference rather than adopting yours.
147 * Return value: a new #GtkImage
150 gtk_image_new_from_image (GdkImage *gdk_image,
155 image = gtk_type_new (GTK_TYPE_IMAGE);
157 gtk_image_set_from_image (image, gdk_image, mask);
159 return GTK_WIDGET (image);
163 * gtk_image_new_from_file:
164 * @filename: a filename
166 * Creates a new #GtkImage displaying the file @filename. If the
167 * file isn't found or can't be loaded, the #GtkImage will display
168 * a "broken image" icon. If you need to detect failures to load
169 * the file, use gdk_pixbuf_new_from_file() to load the file yourself,
170 * then create the #GtkImage from the pixbuf.
172 * Return value: a new #GtkImage
175 gtk_image_new_from_file (const gchar *filename)
179 image = gtk_type_new (GTK_TYPE_IMAGE);
181 gtk_image_set_from_file (image, filename);
183 return GTK_WIDGET (image);
187 * gtk_image_new_from_pixbuf:
188 * @pixbuf: a #GdkPixbuf, or %NULL
190 * Creates a new #GtkImage displaying @pixbuf.
191 * The #GtkImage does not assume a reference to the
192 * pixbuf; you still need to unref it if you own references.
193 * #GtkImage will add its own reference rather than adopting yours.
195 * Note that this function just creates an #GtkImage from the pixbuf. The
196 * #GtkImage created will not react to state changes. Should you want that, you
197 * should use @gtk_image_new_from_icon_set.
199 * Return value: a new #GtkImage
202 gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf)
206 image = gtk_type_new (GTK_TYPE_IMAGE);
208 gtk_image_set_from_pixbuf (image, pixbuf);
210 return GTK_WIDGET (image);
214 * gtk_image_new_from_stock:
215 * @stock_id: a stock icon name
216 * @size: a stock icon size
218 * Creates a #GtkImage displaying a stock icon. Sample stock icon
219 * names are #GTK_STOCK_ICON_OPEN, #GTK_STOCK_ICON_EXIT. Sample stock sizes
220 * are #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_SMALL_TOOLBAR. If the stock
221 * icon name isn't known, a "broken image" icon will be displayed instead.
223 * Return value: a new #GtkImage displaying the stock icon
226 gtk_image_new_from_stock (const gchar *stock_id,
231 image = gtk_type_new (GTK_TYPE_IMAGE);
233 gtk_image_set_from_stock (image, stock_id, size);
235 return GTK_WIDGET (image);
239 * gtk_image_new_from_icon_set:
240 * @icon_set: a #GtkIconSet
241 * @size: a stock icon size
243 * Creates a #GtkImage displaying an icon set. Sample stock sizes are
244 * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_SMALL_TOOLBAR. Instead of using
245 * this function, usually it's better to create a #GtkIconFactory, put
246 * your icon sets in the icon factory, add the icon factory to the
247 * list of default factories with gtk_icon_factory_add_default(), and
248 * then use gtk_image_new_from_stock(). This will allow themes to
249 * override the icon you ship with your application.
251 * The #GtkImage does not assume a reference to the
252 * icon set; you still need to unref it if you own references.
253 * #GtkImage will add its own reference rather than adopting yours.
256 * Return value: a new #GtkImage
259 gtk_image_new_from_icon_set (GtkIconSet *icon_set,
264 image = gtk_type_new (GTK_TYPE_IMAGE);
266 gtk_image_set_from_icon_set (image, icon_set, size);
268 return GTK_WIDGET (image);
272 * gtk_image_set_from_pixmap:
273 * @image: a #GtkImage
274 * @pixmap: a #GdkPixmap or %NULL
275 * @mask: a #GdkBitmap or %NULL
277 * See gtk_image_new_from_pixmap() for details.
281 gtk_image_set_from_pixmap (GtkImage *image,
285 g_return_if_fail (GTK_IS_IMAGE (image));
286 g_return_if_fail (pixmap == NULL ||
287 GDK_IS_PIXMAP (pixmap));
288 g_return_if_fail (mask == NULL ||
289 GDK_IS_PIXMAP (mask));
292 g_object_ref (G_OBJECT (pixmap));
295 g_object_ref (G_OBJECT (mask));
297 gtk_image_reset (image);
304 image->storage_type = GTK_IMAGE_PIXMAP;
306 image->data.pixmap.pixmap = pixmap;
307 image->data.pixmap.mask = mask;
309 gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height);
311 gtk_image_update_size (image, width, height);
315 /* Clean up the mask if pixmap was NULL */
317 g_object_unref (G_OBJECT (mask));
322 * gtk_image_set_from_image:
323 * @image: a #GtkImage
324 * @gdk_image: a #GdkImage or %NULL
325 * @mask: a #GdkBitmap or %NULL
327 * See gtk_image_new_from_image() for details.
331 gtk_image_set_from_image (GtkImage *image,
335 g_return_if_fail (GTK_IS_IMAGE (image));
336 g_return_if_fail (gdk_image == NULL ||
337 GDK_IS_IMAGE (gdk_image));
338 g_return_if_fail (mask == NULL ||
339 GDK_IS_PIXMAP (mask));
343 g_object_ref (G_OBJECT (gdk_image));
346 g_object_ref (G_OBJECT (mask));
348 gtk_image_reset (image);
352 image->storage_type = GTK_IMAGE_IMAGE;
354 image->data.image.image = gdk_image;
355 image->data.image.mask = mask;
357 gtk_image_update_size (image, gdk_image->width, gdk_image->height);
361 /* Clean up the mask if gdk_image was NULL */
363 g_object_unref (G_OBJECT (mask));
368 * gtk_image_set_from_file:
369 * @image: a #GtkImage
370 * @filename: a filename or %NULL
372 * See gtk_image_new_from_file() for details.
376 gtk_image_set_from_file (GtkImage *image,
377 const gchar *filename)
381 g_return_if_fail (GTK_IS_IMAGE (image));
382 g_return_if_fail (filename != NULL);
384 gtk_image_reset (image);
386 if (filename == NULL)
389 pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
393 gtk_image_set_from_stock (image,
394 GTK_STOCK_MISSING_IMAGE,
395 GTK_ICON_SIZE_BUTTON);
399 gtk_image_set_from_pixbuf (image, pixbuf);
401 g_object_unref (G_OBJECT (pixbuf));
405 * gtk_image_set_from_pixbuf:
406 * @image: a #GtkImage
407 * @pixbuf: a #GdkPixbuf or %NULL
409 * See gtk_image_new_from_pixbuf() for details.
413 gtk_image_set_from_pixbuf (GtkImage *image,
416 g_return_if_fail (GTK_IS_IMAGE (image));
417 g_return_if_fail (pixbuf == NULL ||
418 GDK_IS_PIXBUF (pixbuf));
421 g_object_ref (G_OBJECT (pixbuf));
423 gtk_image_reset (image);
427 image->storage_type = GTK_IMAGE_PIXBUF;
429 image->data.pixbuf.pixbuf = pixbuf;
431 gtk_image_update_size (image,
432 gdk_pixbuf_get_width (pixbuf),
433 gdk_pixbuf_get_height (pixbuf));
438 * gtk_image_set_from_stock:
439 * @image: a #GtkImage
440 * @stock_id: a stock icon name
441 * @size: a stock icon size
443 * See gtk_image_new_from_stock for details.
447 gtk_image_set_from_stock (GtkImage *image,
448 const gchar *stock_id,
451 g_return_if_fail (GTK_IS_IMAGE (image));
453 gtk_image_reset (image);
457 image->storage_type = GTK_IMAGE_STOCK;
459 image->data.stock.stock_id = g_strdup (stock_id);
460 image->data.stock.size = size;
462 /* Size is demand-computed in size request method
463 * if we're a stock image, since changing the
464 * style impacts the size request
470 * gtk_image_set_from_icon_set:
471 * @image: a #GtkImage
472 * @icon_set: a #GtkIconSet
473 * @size: a stock icon size
475 * See gtk_image_new_from_icon_set() for details.
479 gtk_image_set_from_icon_set (GtkImage *image,
480 GtkIconSet *icon_set,
483 g_return_if_fail (GTK_IS_IMAGE (image));
486 gtk_icon_set_ref (icon_set);
488 gtk_image_reset (image);
492 image->storage_type = GTK_IMAGE_ICON_SET;
494 image->data.icon_set.icon_set = icon_set;
495 image->data.icon_set.size = size;
497 /* Size is demand-computed in size request method
498 * if we're an icon set
504 * gtk_image_get_storage_type:
505 * @image: a #GtkImage
507 * Gets the type of representation being used by the #GtkImage
508 * to store image data. If the #GtkImage has no image data,
509 * the return value will be %GTK_IMAGE_EMPTY.
511 * Return value: image representation being used
514 gtk_image_get_storage_type (GtkImage *image)
516 g_return_val_if_fail (GTK_IS_IMAGE (image), GTK_IMAGE_EMPTY);
518 return image->storage_type;
522 * gtk_image_get_pixmap:
523 * @image: a #GtkImage
524 * @pixmap: location to store the pixmap, or %NULL
525 * @mask: location to store the mask, or %NULL
527 * Gets the pixmap and mask being displayed by the #GtkImage.
528 * The storage type of the image must be %GTK_IMAGE_EMPTY or
529 * %GTK_IMAGE_PIXMAP (see gtk_image_get_storage_type()).
530 * The caller of this function does not own a reference to the
531 * returned pixmap and mask.
535 gtk_image_get_pixmap (GtkImage *image,
539 g_return_if_fail (GTK_IS_IMAGE (image));
540 g_return_if_fail (image->storage_type == GTK_IMAGE_PIXMAP ||
541 image->storage_type == GTK_IMAGE_EMPTY);
544 *pixmap = image->data.pixmap.pixmap;
547 *mask = image->data.pixmap.mask;
551 * gtk_image_get_image:
552 * @image: a #GtkImage
553 * @gdk_image: return location for a #GtkImage
554 * @mask: return location for a #GdkBitmap
556 * Gets the #GdkImage and mask being displayed by the #GtkImage.
557 * The storage type of the image must be %GTK_IMAGE_EMPTY or
558 * %GTK_IMAGE_IMAGE (see gtk_image_get_storage_type()).
559 * The caller of this function does not own a reference to the
560 * returned image and mask.
563 gtk_image_get_image (GtkImage *image,
564 GdkImage **gdk_image,
567 g_return_if_fail (GTK_IS_IMAGE (image));
568 g_return_if_fail (image->storage_type == GTK_IMAGE_IMAGE ||
569 image->storage_type == GTK_IMAGE_EMPTY);
572 *gdk_image = image->data.image.image;
575 *mask = image->data.image.mask;
579 * gtk_image_get_pixbuf:
580 * @image: a #GtkImage
583 * Gets the #GdkPixbuf being displayed by the #GtkImage.
584 * The storage type of the image must be %GTK_IMAGE_EMPTY or
585 * %GTK_IMAGE_PIXBUF (see gtk_image_get_storage_type()).
586 * The caller of this function does not own a reference to the
589 * Return value: the displayed pixbuf, or %NULL if the image is empty
592 gtk_image_get_pixbuf (GtkImage *image)
594 g_return_val_if_fail (GTK_IS_IMAGE (image), NULL);
595 g_return_val_if_fail (image->storage_type == GTK_IMAGE_PIXBUF ||
596 image->storage_type == GTK_IMAGE_EMPTY, NULL);
598 if (image->storage_type == GTK_IMAGE_EMPTY)
599 image->data.pixbuf.pixbuf = NULL;
601 return image->data.pixbuf.pixbuf;
605 * gtk_image_get_stock:
606 * @image: a #GtkImage
607 * @stock_id: place to store a stock icon name
608 * @size: place to store a stock icon size
610 * Gets the stock icon name and size being displayed by the #GtkImage.
611 * The storage type of the image must be %GTK_IMAGE_EMPTY or
612 * %GTK_IMAGE_STOCK (see gtk_image_get_storage_type()).
613 * The returned string is owned by the #GtkImage and should not
618 gtk_image_get_stock (GtkImage *image,
622 g_return_if_fail (GTK_IS_IMAGE (image));
623 g_return_if_fail (image->storage_type == GTK_IMAGE_STOCK ||
624 image->storage_type == GTK_IMAGE_EMPTY);
626 if (image->storage_type == GTK_IMAGE_EMPTY)
627 image->data.stock.stock_id = NULL;
630 *stock_id = image->data.stock.stock_id;
633 *size = image->data.stock.size;
637 * gtk_image_get_icon_set:
638 * @image: a #GtkImage
639 * @icon_set: location to store a #GtkIconSet
640 * @size: location to store a stock icon size
642 * Gets the icon set and size being displayed by the #GtkImage.
643 * The storage type of the image must be %GTK_IMAGE_EMPTY or
644 * %GTK_IMAGE_ICON_SET (see gtk_image_get_storage_type()).
648 gtk_image_get_icon_set (GtkImage *image,
649 GtkIconSet **icon_set,
652 g_return_if_fail (GTK_IS_IMAGE (image));
653 g_return_if_fail (image->storage_type == GTK_IMAGE_ICON_SET ||
654 image->storage_type == GTK_IMAGE_EMPTY);
657 *icon_set = image->data.icon_set.icon_set;
660 *size = image->data.icon_set.size;
664 gtk_image_new (GdkImage *val,
669 g_return_val_if_fail (val != NULL, NULL);
671 image = gtk_type_new (GTK_TYPE_IMAGE);
673 gtk_image_set (image, val, mask);
675 return GTK_WIDGET (image);
679 gtk_image_set (GtkImage *image,
683 g_return_if_fail (GTK_IS_IMAGE (image));
685 gtk_image_set_from_image (image, val, mask);
689 gtk_image_get (GtkImage *image,
693 g_return_if_fail (GTK_IS_IMAGE (image));
695 gtk_image_get_image (image, val, mask);
700 gtk_image_expose (GtkWidget *widget,
701 GdkEventExpose *event)
703 g_return_val_if_fail (widget != NULL, FALSE);
704 g_return_val_if_fail (GTK_IS_IMAGE (widget), FALSE);
705 g_return_val_if_fail (event != NULL, FALSE);
707 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget) &&
708 GTK_IMAGE (widget)->storage_type != GTK_IMAGE_EMPTY)
712 GdkRectangle area, image_bound, intersection;
714 GdkBitmap *mask = NULL;
715 GdkPixbuf *stock_pixbuf = NULL;
717 image = GTK_IMAGE (widget);
718 misc = GTK_MISC (widget);
720 x = (widget->allocation.x * (1.0 - misc->xalign) +
721 (widget->allocation.x + widget->allocation.width
722 - (widget->requisition.width - misc->xpad * 2)) *
724 y = (widget->allocation.y * (1.0 - misc->yalign) +
725 (widget->allocation.y + widget->allocation.height
726 - (widget->requisition.height - misc->ypad * 2)) *
732 switch (image->storage_type)
734 case GTK_IMAGE_PIXMAP:
735 mask = image->data.pixmap.mask;
736 gdk_drawable_get_size (image->data.pixmap.pixmap,
738 &image_bound.height);
741 case GTK_IMAGE_IMAGE:
742 mask = image->data.image.mask;
743 image_bound.width = image->data.image.image->width;
744 image_bound.height = image->data.image.image->height;
747 case GTK_IMAGE_PIXBUF:
748 image_bound.width = gdk_pixbuf_get_width (image->data.pixbuf.pixbuf);
749 image_bound.height = gdk_pixbuf_get_height (image->data.pixbuf.pixbuf);
752 case GTK_IMAGE_STOCK:
753 stock_pixbuf = gtk_widget_render_icon (widget,
754 image->data.stock.stock_id,
755 image->data.stock.size,
759 image_bound.width = gdk_pixbuf_get_width (stock_pixbuf);
760 image_bound.height = gdk_pixbuf_get_height (stock_pixbuf);
764 case GTK_IMAGE_ICON_SET:
766 gtk_icon_set_render_icon (image->data.icon_set.icon_set,
768 gtk_widget_get_direction (widget),
769 GTK_WIDGET_STATE (widget),
770 image->data.icon_set.size,
776 image_bound.width = gdk_pixbuf_get_width (stock_pixbuf);
777 image_bound.height = gdk_pixbuf_get_height (stock_pixbuf);
787 gdk_gc_set_clip_mask (widget->style->black_gc, mask);
788 gdk_gc_set_clip_origin (widget->style->black_gc, x, y);
793 if (gdk_rectangle_intersect (&area, &widget->allocation, &area) &&
794 gdk_rectangle_intersect (&image_bound, &area, &image_bound))
796 switch (image->storage_type)
798 case GTK_IMAGE_PIXMAP:
799 gdk_draw_drawable (widget->window,
800 widget->style->black_gc,
801 image->data.pixmap.pixmap,
802 image_bound.x - x, image_bound.y - y,
803 image_bound.x, image_bound.y,
804 image_bound.width, image_bound.height);
807 case GTK_IMAGE_IMAGE:
808 gdk_draw_image (widget->window,
809 widget->style->black_gc,
810 image->data.image.image,
811 image_bound.x - x, image_bound.y - y,
812 image_bound.x, image_bound.y,
813 image_bound.width, image_bound.height);
816 case GTK_IMAGE_PIXBUF:
817 gdk_pixbuf_render_to_drawable_alpha (image->data.pixbuf.pixbuf,
825 GDK_PIXBUF_ALPHA_FULL,
827 GDK_RGB_DITHER_NORMAL,
831 case GTK_IMAGE_STOCK: /* fall thru */
832 case GTK_IMAGE_ICON_SET:
835 gdk_pixbuf_render_to_drawable_alpha (stock_pixbuf,
843 GDK_PIXBUF_ALPHA_FULL,
845 GDK_RGB_DITHER_NORMAL,
848 g_object_unref (G_OBJECT (stock_pixbuf));
855 } /* if rectangle intersects */
858 gdk_gc_set_clip_mask (widget->style->black_gc, NULL);
859 gdk_gc_set_clip_origin (widget->style->black_gc, 0, 0);
861 } /* if widget is drawable */
867 gtk_image_clear (GtkImage *image)
869 switch (image->storage_type)
871 case GTK_IMAGE_PIXMAP:
873 if (image->data.pixmap.pixmap)
874 g_object_unref (G_OBJECT (image->data.pixmap.pixmap));
876 if (image->data.pixmap.mask)
877 g_object_unref (G_OBJECT (image->data.pixmap.mask));
879 image->data.pixmap.pixmap = NULL;
880 image->data.pixmap.mask = NULL;
884 case GTK_IMAGE_IMAGE:
886 if (image->data.image.image)
887 g_object_unref (G_OBJECT (image->data.image.image));
889 if (image->data.image.mask)
890 g_object_unref (G_OBJECT (image->data.image.mask));
892 image->data.image.image = NULL;
893 image->data.image.mask = NULL;
897 case GTK_IMAGE_PIXBUF:
899 if (image->data.pixbuf.pixbuf)
900 g_object_unref (G_OBJECT (image->data.pixbuf.pixbuf));
902 image->data.pixbuf.pixbuf = NULL;
906 case GTK_IMAGE_STOCK:
908 g_free (image->data.stock.stock_id);
910 image->data.stock.stock_id = NULL;
911 image->data.stock.size = 0;
915 case GTK_IMAGE_ICON_SET:
916 if (image->data.icon_set.icon_set)
917 gtk_icon_set_unref (image->data.icon_set.icon_set);
919 image->data.icon_set.size = 0;
920 image->data.icon_set.icon_set = NULL;
924 case GTK_IMAGE_EMPTY:
930 image->storage_type = GTK_IMAGE_EMPTY;
934 gtk_image_reset (GtkImage *image)
936 gtk_image_clear (image);
938 gtk_image_update_size (image, 0, 0);
942 gtk_image_size_request (GtkWidget *widget,
943 GtkRequisition *requisition)
946 GdkPixbuf *pixbuf = NULL;
948 image = GTK_IMAGE (widget);
950 /* We update stock/icon set on every size request, because
951 * the theme could have affected the size; for other kinds of
952 * image, we just update the requisition when the image data
956 switch (image->storage_type)
958 case GTK_IMAGE_STOCK:
959 pixbuf = gtk_widget_render_icon (GTK_WIDGET (image),
960 image->data.stock.stock_id,
961 image->data.stock.size,
965 case GTK_IMAGE_ICON_SET:
966 pixbuf = gtk_icon_set_render_icon (image->data.icon_set.icon_set,
968 gtk_widget_get_direction (widget),
969 GTK_WIDGET_STATE (widget),
970 image->data.icon_set.size,
981 GTK_WIDGET (image)->requisition.width = gdk_pixbuf_get_width (pixbuf) + GTK_MISC (image)->xpad * 2;
982 GTK_WIDGET (image)->requisition.height = gdk_pixbuf_get_height (pixbuf) + GTK_MISC (image)->ypad * 2;
984 g_object_unref (G_OBJECT (pixbuf));
987 /* Chain up to default that simply reads current requisition */
988 GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
992 gtk_image_update_size (GtkImage *image,
996 GTK_WIDGET (image)->requisition.width = image_width + GTK_MISC (image)->xpad * 2;
997 GTK_WIDGET (image)->requisition.height = image_height + GTK_MISC (image)->ypad * 2;
999 if (GTK_WIDGET_VISIBLE (image))
1000 gtk_widget_queue_resize (GTK_WIDGET (image));