1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 A widget displaying an image
7 <!-- ##### SECTION Long_Description ##### -->
9 The #GtkImage widget displays an image. Various kinds of object
10 can be displayed as an image; most typically, you would load a
11 #GdkPixbuf ("pixel buffer") from a file, and then display that.
12 There's a convenience function to do this, gtk_image_new_from_file(),
14 <informalexample><programlisting>
16 image = gtk_image_new_from_file ("myfile.png");
17 </programlisting></informalexample>
18 If the file isn't loaded successfully, the image will contain a
19 "broken image" icon similar to that used in many web browsers.
20 If you want to handle errors in loading the file yourself,
21 for example by displaying an error message, then load the image with
22 gdk_pixbuf_new_from_file(), then create the #GtkImage with
23 gtk_image_new_from_pixbuf().
26 The image file may contain an animation, if so the #GtkImage will
27 display an animation (#GdkPixbufAnimation) instead of a static image.
30 #GtkImage is a subclass of #GtkMisc, which implies that you can
31 align it (center, left, right) and add padding to it, using
35 #GtkImage is a "no window" widget (has no #GdkWindow of its own),
36 so by default does not receive events. If you want to receive events
37 on the image, such as button clicks, place the image inside a
38 #GtkEventBox, then connect to the event signals on the event box.
40 <title>Handling button press events on a
41 <structname>GtkImage</structname>.</title>
44 button_press_callback (GtkWidget *event_box,
45 GdkEventButton *event,
48 g_print ("Event box clicked at coordinates &percent;d,&percent;d\n",
51 /* Returning TRUE means we handled the event, so the signal
52 * emission should be stopped (don't call any further
53 * callbacks that may be connected). Return FALSE
54 * to continue invoking callbacks.
65 image = gtk_image_new_from_file ("myfile.png");
67 event_box = gtk_event_box_new (<!>);
69 gtk_container_add (GTK_CONTAINER (event_box), image);
71 g_signal_connect (G_OBJECT (event_box),
73 G_CALLBACK (button_press_callback),
82 When handling events on the event box, keep in mind that coordinates
83 in the image may be different from event box coordinates due to
84 the alignment and padding settings on the image (see #GtkMisc).
85 The simplest way to solve this is to set the alignment to 0.0
86 (left/top), and set the padding to zero. Then the origin of
87 the image will be the same as the origin of the event box.
91 Sometimes an application will want to avoid depending on external data
92 files, such as image files. GTK+ comes with a program to avoid this,
93 called <application>gdk-pixbuf-csource</application>. This program
94 allows you to convert an image into a C variable declaration, which
95 can then be loaded into a #GdkPixbuf using
96 gdk_pixbuf_new_from_inline().
99 <!-- ##### SECTION See_Also ##### -->
104 <!-- ##### STRUCT GtkImage ##### -->
106 This struct contain private data only and should be accessed by the functions
111 <!-- ##### ENUM GtkImageType ##### -->
113 Describes the image data representation used by a #GtkImage. If you
114 want to get the image from the widget, you can only get the
115 currently-stored representation. e.g. if the
116 gtk_image_get_storage_type() returns #GTK_IMAGE_PIXBUF, then you can
117 call gtk_image_get_pixbuf() but not gtk_image_get_stock(). For empty
118 images, you can request any storage type (call any of the "get"
119 functions), but they will all return %NULL values.
122 @GTK_IMAGE_EMPTY: there is no image displayed by the widget
123 @GTK_IMAGE_PIXMAP: the widget contains a #GdkPixmap
124 @GTK_IMAGE_IMAGE: the widget contains a #GdkImage
125 @GTK_IMAGE_PIXBUF: the widget contains a #GdkPixbuf
126 @GTK_IMAGE_STOCK: the widget contains a stock icon name
127 @GTK_IMAGE_ICON_SET: the widget contains a #GtkIconSet
128 @GTK_IMAGE_ANIMATION: the widget contains a #GdkPixbufAnimation
130 <!-- ##### FUNCTION gtk_image_get_icon_set ##### -->
140 <!-- ##### FUNCTION gtk_image_get_image ##### -->
150 <!-- ##### FUNCTION gtk_image_get_pixbuf ##### -->
159 <!-- ##### FUNCTION gtk_image_get_pixmap ##### -->
169 <!-- ##### FUNCTION gtk_image_get_stock ##### -->
179 <!-- ##### FUNCTION gtk_image_get_animation ##### -->
188 <!-- ##### FUNCTION gtk_image_get_storage_type ##### -->
197 <!-- ##### FUNCTION gtk_image_new_from_file ##### -->
206 <!-- ##### FUNCTION gtk_image_new_from_icon_set ##### -->
216 <!-- ##### FUNCTION gtk_image_new_from_image ##### -->
226 <!-- ##### FUNCTION gtk_image_new_from_pixbuf ##### -->
235 <!-- ##### FUNCTION gtk_image_new_from_pixmap ##### -->
245 <!-- ##### FUNCTION gtk_image_new_from_stock ##### -->
255 <!-- ##### FUNCTION gtk_image_new_from_animation ##### -->
264 <!-- ##### FUNCTION gtk_image_set_from_file ##### -->
273 <!-- ##### FUNCTION gtk_image_set_from_icon_set ##### -->
283 <!-- ##### FUNCTION gtk_image_set_from_image ##### -->
293 <!-- ##### FUNCTION gtk_image_set_from_pixbuf ##### -->
302 <!-- ##### FUNCTION gtk_image_set_from_pixmap ##### -->
312 <!-- ##### FUNCTION gtk_image_set_from_stock ##### -->
322 <!-- ##### FUNCTION gtk_image_set_from_animation ##### -->
331 <!-- ##### FUNCTION gtk_image_new ##### -->
336 @Returns: the #GtkImage
337 <!-- # Unused Parameters # -->
339 @mask: a #GdkBitmap that indicates which parts of the image should be transparent.
342 <!-- ##### FUNCTION gtk_image_set ##### -->
349 @mask: a #GdkBitmap that indicates which parts of the image should be transparent.
352 <!-- ##### FUNCTION gtk_image_get ##### -->
359 @mask: a #GdkBitmap that indicates which parts of the image should be transparent.
362 <!-- ##### ARG GtkImage:pixbuf ##### -->
367 <!-- ##### ARG GtkImage:pixmap ##### -->
372 <!-- ##### ARG GtkImage:image ##### -->
377 <!-- ##### ARG GtkImage:mask ##### -->
382 <!-- ##### ARG GtkImage:file ##### -->
387 <!-- ##### ARG GtkImage:stock ##### -->
392 <!-- ##### ARG GtkImage:icon-set ##### -->
397 <!-- ##### ARG GtkImage:icon-size ##### -->
402 <!-- ##### ARG GtkImage:pixbuf-animation ##### -->
407 <!-- ##### ARG GtkImage:storage-type ##### -->