Top | ![]() |
![]() |
![]() |
![]() |
GdkPixbuf * | gtk_image_get_pixbuf () |
GdkPixbufAnimation * | gtk_image_get_animation () |
void | gtk_image_get_icon_name () |
void | gtk_image_get_gicon () |
GtkImageType | gtk_image_get_storage_type () |
GtkWidget * | gtk_image_new_from_file () |
GtkWidget * | gtk_image_new_from_pixbuf () |
GtkWidget * | gtk_image_new_from_animation () |
GtkWidget * | gtk_image_new_from_icon_name () |
GtkWidget * | gtk_image_new_from_gicon () |
GtkWidget * | gtk_image_new_from_resource () |
GtkWidget * | gtk_image_new_from_surface () |
void | gtk_image_set_from_file () |
void | gtk_image_set_from_pixbuf () |
void | gtk_image_set_from_animation () |
void | gtk_image_set_from_icon_name () |
void | gtk_image_set_from_gicon () |
void | gtk_image_set_from_resource () |
void | gtk_image_set_from_surface () |
void | gtk_image_clear () |
GtkWidget * | gtk_image_new () |
void | gtk_image_set_pixel_size () |
gint | gtk_image_get_pixel_size () |
The GtkImage widget displays an image. Various kinds of object
can be displayed as an image; most typically, you would load a
GdkPixbuf ("pixel buffer") from a file, and then display that.
There’s a convenience function to do this, gtk_image_new_from_file()
,
used as follows:
1 2 |
GtkWidget *image; image = gtk_image_new_from_file ("myfile.png"); |
If the file isn’t loaded successfully, the image will contain a
“broken image” icon similar to that used in many web browsers.
If you want to handle errors in loading the file yourself,
for example by displaying an error message, then load the image with
gdk_pixbuf_new_from_file()
, then create the GtkImage with
gtk_image_new_from_pixbuf()
.
The image file may contain an animation, if so the GtkImage will display an animation (GdkPixbufAnimation) instead of a static image.
Sometimes an application will want to avoid depending on external data
files, such as image files. GTK+ comes with a program to avoid this,
called “gdk-pixbuf-csource”. This library
allows you to convert an image into a C variable declaration, which
can then be loaded into a GdkPixbuf using
gdk_pixbuf_new_from_inline()
.
GdkPixbuf *
gtk_image_get_pixbuf (GtkImage *image
);
Gets the GdkPixbuf being displayed by the GtkImage.
The storage type of the image must be GTK_IMAGE_EMPTY
or
GTK_IMAGE_PIXBUF
(see gtk_image_get_storage_type()
).
The caller of this function does not own a reference to the
returned pixbuf.
GdkPixbufAnimation *
gtk_image_get_animation (GtkImage *image
);
Gets the GdkPixbufAnimation being displayed by the GtkImage.
The storage type of the image must be GTK_IMAGE_EMPTY
or
GTK_IMAGE_ANIMATION
(see gtk_image_get_storage_type()
).
The caller of this function does not own a reference to the
returned animation.
void gtk_image_get_icon_name (GtkImage *image
,const gchar **icon_name
,GtkIconSize *size
);
Gets the icon name and size being displayed by the GtkImage.
The storage type of the image must be GTK_IMAGE_EMPTY
or
GTK_IMAGE_ICON_NAME
(see gtk_image_get_storage_type()
).
The returned string is owned by the GtkImage and should not
be freed.
Since: 2.6
void gtk_image_get_gicon (GtkImage *image
,GIcon **gicon
,GtkIconSize *size
);
Gets the GIcon and size being displayed by the GtkImage.
The storage type of the image must be GTK_IMAGE_EMPTY
or
GTK_IMAGE_GICON
(see gtk_image_get_storage_type()
).
The caller of this function does not own a reference to the
returned GIcon.
Since: 2.14
GtkImageType
gtk_image_get_storage_type (GtkImage *image
);
Gets the type of representation being used by the GtkImage
to store image data. If the GtkImage has no image data,
the return value will be GTK_IMAGE_EMPTY
.
GtkWidget *
gtk_image_new_from_file (const gchar *filename
);
Creates a new GtkImage displaying the file filename
. If the file
isn’t found or can’t be loaded, the resulting GtkImage will
display a “broken image” icon. This function never returns NULL
,
it always returns a valid GtkImage widget.
If the file contains an animation, the image will contain an animation.
If you need to detect failures to load the file, use
gdk_pixbuf_new_from_file()
to load the file yourself, then create
the GtkImage from the pixbuf. (Or for animations, use
gdk_pixbuf_animation_new_from_file()
).
The storage type (gtk_image_get_storage_type()
) of the returned
image is not defined, it will be whatever is appropriate for
displaying the file.
GtkWidget *
gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf
);
Creates a new GtkImage displaying pixbuf
.
The GtkImage does not assume a reference to the
pixbuf; you still need to unref it if you own references.
GtkImage will add its own reference rather than adopting yours.
Note that this function just creates an GtkImage from the pixbuf. The
GtkImage created will not react to state changes. Should you want that,
you should use gtk_image_new_from_icon_name()
.
GtkWidget *
gtk_image_new_from_animation (GdkPixbufAnimation *animation
);
Creates a GtkImage displaying the given animation. The GtkImage does not assume a reference to the animation; you still need to unref it if you own references. GtkImage will add its own reference rather than adopting yours.
Note that the animation frames are shown using a timeout with G_PRIORITY_DEFAULT. When using animations to indicate busyness, keep in mind that the animation will only be shown if the main loop is not busy with something that has a higher priority.
GtkWidget * gtk_image_new_from_icon_name (const gchar *icon_name
,GtkIconSize size
);
Creates a GtkImage displaying an icon from the current icon theme. If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
icon_name |
an icon name or |
[nullable] |
size |
a stock icon size (GtkIconSize). |
[type int] |
Since: 2.6
GtkWidget * gtk_image_new_from_gicon (GIcon *icon
,GtkIconSize size
);
Creates a GtkImage displaying an icon from the current icon theme. If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
Since: 2.14
GtkWidget *
gtk_image_new_from_resource (const gchar *resource_path
);
Creates a new GtkImage displaying the resource file resource_path
. If the file
isn’t found or can’t be loaded, the resulting GtkImage will
display a “broken image” icon. This function never returns NULL
,
it always returns a valid GtkImage widget.
If the file contains an animation, the image will contain an animation.
If you need to detect failures to load the file, use
gdk_pixbuf_new_from_file()
to load the file yourself, then create
the GtkImage from the pixbuf. (Or for animations, use
gdk_pixbuf_animation_new_from_file()
).
The storage type (gtk_image_get_storage_type()
) of the returned
image is not defined, it will be whatever is appropriate for
displaying the file.
Since: 3.4
GtkWidget *
gtk_image_new_from_surface (cairo_surface_t *surface
);
Creates a new GtkImage displaying surface
.
The GtkImage does not assume a reference to the
surface; you still need to unref it if you own references.
GtkImage will add its own reference rather than adopting yours.
Since: 3.10
void gtk_image_set_from_file (GtkImage *image
,const gchar *filename
);
See gtk_image_new_from_file()
for details.
void gtk_image_set_from_pixbuf (GtkImage *image
,GdkPixbuf *pixbuf
);
See gtk_image_new_from_pixbuf()
for details.
void gtk_image_set_from_animation (GtkImage *image
,GdkPixbufAnimation *animation
);
Causes the GtkImage to display the given animation (or display
nothing, if you set the animation to NULL
).
void gtk_image_set_from_icon_name (GtkImage *image
,const gchar *icon_name
,GtkIconSize size
);
See gtk_image_new_from_icon_name()
for details.
Since: 2.6
void gtk_image_set_from_gicon (GtkImage *image
,GIcon *icon
,GtkIconSize size
);
See gtk_image_new_from_gicon()
for details.
Since: 2.14
void gtk_image_set_from_resource (GtkImage *image
,const gchar *resource_path
);
See gtk_image_new_from_resource()
for details.
void gtk_image_set_from_surface (GtkImage *image
,cairo_surface_t *surface
);
See gtk_image_new_from_surface()
for details.
Since: 3.10
void gtk_image_set_pixel_size (GtkImage *image
,gint pixel_size
);
Sets the pixel size to use for named icons. If the pixel size is set
to a value != -1, it is used instead of the icon size set by
gtk_image_set_from_icon_name()
.
Since: 2.6
struct GtkImage { GtkWidget parent_instance; };
This struct contain private data only and should be accessed by the functions below.
Describes the image data representation used by a GtkImage. If you
want to get the image from the widget, you can only get the
currently-stored representation. e.g. if the
gtk_image_get_storage_type()
returns GTK_IMAGE_PIXBUF, then you can
call gtk_image_get_pixbuf()
. For empty images, you can request any
storage type (call any of the "get" functions), but they will all
return NULL
values.
there is no image displayed by the widget |
||
the widget contains a GdkPixbuf |
||
the widget contains a GdkPixbufAnimation |
||
the widget contains a named icon. This image type was added in GTK+ 2.6 |
||
the widget contains a GIcon. This image type was added in GTK+ 2.14 |
||
the widget contains a cairo_surface_t. This image type was added in GTK+ 3.10 |