ImageProtocol
public protocol ImageProtocol : MiscProtocolThe 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:
(C Language Example):
  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.
GtkImage is a subclass of GtkMisc, which implies that you can
align it (center, left, right) and add padding to it, using
GtkMisc methods.
GtkImage is a “no window” widget (has no GdkWindow of its own),
so by default does not receive events. If you want to receive events
on the image, such as button clicks, place the image inside a
GtkEventBox, then connect to the event signals on the event box.
Handling button press events on a GtkImage.
(C Language Example):
  static gboolean
  button_press_callback (GtkWidget      *event_box,
                         GdkEventButton *event,
                         gpointer        data)
  {
    g_print ("Event box clicked at coordinates %f,%f\n",
             event->x, event->y);
    // Returning TRUE means we handled the event, so the signal
    // emission should be stopped (don’t call any further callbacks
    // that may be connected). Return FALSE to continue invoking callbacks.
    return TRUE;
  }
  static GtkWidget*
  create_image (void)
  {
    GtkWidget *image;
    GtkWidget *event_box;
    image = gtk_image_new_from_file ("myfile.png");
    event_box = gtk_event_box_new ();
    gtk_container_add (GTK_CONTAINER (event_box), image);
    g_signal_connect (G_OBJECT (event_box),
                      "button_press_event",
                      G_CALLBACK (button_press_callback),
                      image);
    return image;
  }
When handling events on the event box, keep in mind that coordinates
in the image may be different from event box coordinates due to
the alignment and padding settings on the image (see GtkMisc).
The simplest way to solve this is to set the alignment to 0.0
(left/top), and set the padding to zero. Then the origin of
the image will be the same as the origin of the event box.
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().
CSS nodes
GtkImage has a single CSS node with the name image. The style classes may appear on image CSS nodes: .icon-dropshadow, .lowres-icon.
The ImageProtocol protocol exposes the methods and properties of an underlying GtkImage instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Image.
Alternatively, use ImageRef as a lighweight, unowned reference if you already have an instance you just want to use.
- 
                  
                  Untyped pointer to the underlying GtkImageinstance.DeclarationSwift var ptr: UnsafeMutableRawPointer! { get }
- 
                  image_ptrDefault implementationTyped pointer to the underlying GtkImageinstance.Default ImplementationReturn the stored, untyped pointer as a typed pointer to the GtkImageinstance.DeclarationSwift var image_ptr: UnsafeMutablePointer<GtkImage>! { get }
- 
                  
                  Required Initialiser for types conforming to ImageProtocolDeclarationSwift init(raw: UnsafeMutableRawPointer)
- 
                  bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a ImagePropertyNamesource property to a given target object.DeclarationSwift @discardableResult @inlinable func bind<Q, T>(property source_property: ImagePropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocolParameterssource_propertythe source property to bind targetthe target object to bind to target_propertythe target property to bind to flagsthe flags to pass to the Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Valuebinding reference or nilin case of an error
- 
                  get(property:Extension method) Get the value of a Image property DeclarationSwift @inlinable func get(property: ImagePropertyName) -> GLibObject.ValueParameterspropertythe property to get the value for Return Valuethe value of the named property 
- 
                  set(property:Extension methodvalue: ) Set the value of a Image property. Note that this will only have an effect on properties that are writable and not construct-only! DeclarationSwift @inlinable func set(property: ImagePropertyName, value v: GLibObject.Value)Parameterspropertythe property to get the value for Return Valuethe value of the named property 
- 
                  clear()Extension methodResets the image to be empty. DeclarationSwift @inlinable func clear()
- 
                  getAnimation()Extension methodGets the GdkPixbufAnimationbeing displayed by theGtkImage. The storage type of the image must beGTK_IMAGE_EMPTYorGTK_IMAGE_ANIMATION(seegtk_image_get_storage_type()). The caller of this function does not own a reference to the returned animation.DeclarationSwift @inlinable func getAnimation() -> PixbufAnimationRef!
- 
                  get(gicon:Extension methodsize: ) Gets the GIconand size being displayed by theGtkImage. The storage type of the image must beGTK_IMAGE_EMPTYorGTK_IMAGE_GICON(seegtk_image_get_storage_type()). The caller of this function does not own a reference to the returnedGIcon.DeclarationSwift @inlinable func get(gicon: UnsafeMutablePointer<UnsafeMutablePointer<GIcon>?>! = nil, size: UnsafeMutablePointer<GtkIconSize>! = nil)
- 
                  get(iconName:Extension methodsize: ) Gets the icon name and size being displayed by the GtkImage. The storage type of the image must beGTK_IMAGE_EMPTYorGTK_IMAGE_ICON_NAME(seegtk_image_get_storage_type()). The returned string is owned by theGtkImageand should not be freed.DeclarationSwift @inlinable func get(iconName: UnsafeMutablePointer<UnsafePointer<gchar>?>! = nil, size: UnsafeMutablePointer<GtkIconSize>! = nil)
- 
                  get(iconSet:Extension methodsize: ) Gets the icon set and size being displayed by the GtkImage. The storage type of the image must beGTK_IMAGE_EMPTYorGTK_IMAGE_ICON_SET(seegtk_image_get_storage_type()).get_icon_set is deprecated: Use gtk_image_get_icon_name() instead. DeclarationSwift @available(*, deprecated) @inlinable func get(iconSet: UnsafeMutablePointer<UnsafeMutablePointer<GtkIconSet>?>! = nil, size: UnsafeMutablePointer<GtkIconSize>! = nil)
- 
                  getPixbuf()Extension methodGets the GdkPixbufbeing displayed by theGtkImage. The storage type of the image must beGTK_IMAGE_EMPTYorGTK_IMAGE_PIXBUF(seegtk_image_get_storage_type()). The caller of this function does not own a reference to the returned pixbuf.DeclarationSwift @inlinable func getPixbuf() -> PixbufRef!
- 
                  getPixelSize()Extension methodGets the pixel size used for named icons. DeclarationSwift @inlinable func getPixelSize() -> Int
- 
                  getStock(stockID:Extension methodsize: ) Gets the stock icon name and size being displayed by the GtkImage. The storage type of the image must beGTK_IMAGE_EMPTYorGTK_IMAGE_STOCK(seegtk_image_get_storage_type()). The returned string is owned by theGtkImageand should not be freed.get_stock is deprecated: Use gtk_image_get_icon_name() instead. DeclarationSwift @available(*, deprecated) @inlinable func getStock(stockID: UnsafeMutablePointer<UnsafeMutablePointer<gchar>?>! = nil, size: UnsafeMutablePointer<GtkIconSize>! = nil)
- 
                  getStorageType()Extension methodGets the type of representation being used by the GtkImageto store image data. If theGtkImagehas no image data, the return value will beGTK_IMAGE_EMPTY.DeclarationSwift @inlinable func getStorageType() -> GtkImageType
- 
                  setFrom(animation:Extension method) Causes the GtkImageto display the given animation (or display nothing, if you set the animation tonil).DeclarationSwift @inlinable func setFrom<PixbufAnimationT>(animation: PixbufAnimationT) where PixbufAnimationT : PixbufAnimationProtocol
- 
                  setFromFile(filename:Extension method) See gtk_image_new_from_file()for details.DeclarationSwift @inlinable func setFromFile(filename: UnsafePointer<gchar>? = nil)
- 
                  setFromIcon(icon:Extension methodsize: ) See gtk_image_new_from_gicon()for details.DeclarationSwift @inlinable func setFromIcon<IconT>(icon: IconT, size: GtkIconSize) where IconT : IconProtocol
- 
                  setFrom(iconName:Extension methodsize: ) See gtk_image_new_from_icon_name()for details.DeclarationSwift @inlinable func setFrom(iconName: UnsafePointer<gchar>? = nil, size: GtkIconSize)
- 
                  setFrom(iconSet:Extension methodsize: ) See gtk_image_new_from_icon_set()for details.set_from_icon_set is deprecated: Use gtk_image_set_from_icon_name() instead. DeclarationSwift @available(*, deprecated) @inlinable func setFrom<IconSetT>(iconSet: IconSetT, size: GtkIconSize) where IconSetT : IconSetProtocol
- 
                  setFrom(pixbuf:Extension method) See gtk_image_new_from_pixbuf()for details.DeclarationSwift @inlinable func setFrom(pixbuf: PixbufRef? = nil)
- 
                  setFrom(pixbuf:Extension method) See gtk_image_new_from_pixbuf()for details.DeclarationSwift @inlinable func setFrom<PixbufT>(pixbuf: PixbufT?) where PixbufT : PixbufProtocol
- 
                  setFrom(resourcePath:Extension method) See gtk_image_new_from_resource()for details.DeclarationSwift @inlinable func setFrom(resourcePath: UnsafePointer<gchar>? = nil)
- 
                  setFromStock(stockID:Extension methodsize: ) See gtk_image_new_from_stock()for details.set_from_stock is deprecated: Use gtk_image_set_from_icon_name() instead. DeclarationSwift @available(*, deprecated) @inlinable func setFromStock(stockID: UnsafePointer<gchar>!, size: GtkIconSize)
- 
                  setFrom(surface:Extension method) See gtk_image_new_from_surface()for details.DeclarationSwift @inlinable func setFrom(surface: Cairo.SurfaceRef? = nil)
- 
                  setFrom(surface:Extension method) See gtk_image_new_from_surface()for details.DeclarationSwift @inlinable func setFrom<SurfaceT>(surface: SurfaceT?) where SurfaceT : SurfaceProtocol
- 
                  set(pixelSize:Extension method) 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().DeclarationSwift @inlinable func set(pixelSize: Int)
- 
                  animationExtension methodGets the GdkPixbufAnimationbeing displayed by theGtkImage. The storage type of the image must beGTK_IMAGE_EMPTYorGTK_IMAGE_ANIMATION(seegtk_image_get_storage_type()). The caller of this function does not own a reference to the returned animation.DeclarationSwift @inlinable var animation: PixbufAnimationRef! { get }
- 
                  pixbufExtension methodUndocumented DeclarationSwift @inlinable var pixbuf: PixbufRef! { get }
- 
                  pixelSizeExtension methodGets the pixel size used for named icons. DeclarationSwift @inlinable var pixelSize: Int { get nonmutating set }
- 
                  storageTypeExtension methodGets the type of representation being used by the GtkImageto store image data. If theGtkImagehas no image data, the return value will beGTK_IMAGE_EMPTY.DeclarationSwift @inlinable var storageType: GtkImageType { get }
- 
                  miscExtension methodUndocumented DeclarationSwift @inlinable var misc: GtkMisc { get }
 View on GitHub
            View on GitHub
           Install in Dash
            Install in Dash
           ImageProtocol Protocol Reference
      ImageProtocol Protocol Reference