Class: Gtk::IconInfo

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#base_scaleInteger

Gets the base scale for the icon. The base scale is a scale for the icon that was specified by the icon theme creator. For instance an icon drawn for a high-dpi screen with window scale 2 for a base size of 32 will be 64 pixels tall and have a base scale of 2.

Returns:

  • (Integer)

    the base scale

#base_sizeInteger

Gets the base size for the icon. The base size is a size for the icon that was specified by the icon theme creator. This may be different than the actual size of image; an example of this is small emblem icons that can be attached to a larger icon. These icons will be given the same base size as the larger icons to which they are attached.

Note that for scaled icons the base size does not include the base scale.

Returns:

  • (Integer)

    the base size, or 0, if no base size is known for the icon.

#builtin_pixbufGdkPixbuf::Pixbuf

Gets the built-in image for this icon, if any. To allow GTK+ to use built in icon images, you must pass the %GTK_ICON_LOOKUP_USE_BUILTIN to gtk_icon_theme_lookup_icon().

Returns:

  • (GdkPixbuf::Pixbuf)

    the built-in image pixbuf, or nil. No extra reference is added to the returned pixbuf, so if you want to keep it around, you must use g_object_ref(). The returned image must not be modified.

#copyGtk::IconInfo

Make a copy of a Gtk::IconInfo.

Returns:

#display_nameString

This function is deprecated and always returns nil.

Returns:

  • (String)

    nil

#filenameGtk::filename

Gets the filename for the icon. If the %GTK_ICON_LOOKUP_USE_BUILTIN flag was passed to gtk_icon_theme_lookup_icon(), there may be no filename if a builtin icon is returned; in this case, you should use gtk_icon_info_get_builtin_pixbuf().

Returns:

  • (Gtk::filename)

    the filename for the icon, or nil if gtk_icon_info_get_builtin_pixbuf() should be used instead. The return value is owned by GTK+ and should not be modified or freed.

#freenil

Free a Gtk::IconInfo and associated information

Returns:

  • (nil)

#get_attach_points(points, n_points) ⇒ TrueClass

This function is deprecated and always returns false.

Parameters:

  • points (Array<Gdk::Point>)

    location to store pointer to an array of points, or nil free the array of points with g_free().

  • n_points (Integer)

    location to store the number of points in points, or nil

Returns:

  • (TrueClass)

    false

#get_embedded_rect(rectangle) ⇒ TrueClass

This function is deprecated and always returns false.

Parameters:

  • rectangle (Gdk::Rectangle)

    Gdk::Rectangle in which to store embedded rectangle coordinates; coordinates are only stored when this function returns true.

Returns:

  • (TrueClass)

    false

#is_symbolicTrueClass

Checks if the icon is symbolic or not. This currently uses only the file name and not the file contents for determining this. This behaviour may change in the future.

Returns:

  • (TrueClass)

    true if the icon is symbolic, false otherwise

#load_iconGdkPixbuf::Pixbuf

Renders an icon previously looked up in an icon theme using gtk_icon_theme_lookup_icon(); the size will be based on the size passed to gtk_icon_theme_lookup_icon(). Note that the resulting pixbuf may not be exactly this size; an icon theme may have icons that differ slightly from their nominal sizes, and in addition GTK+ will avoid scaling icons that it considers sufficiently close to the requested size or for which the source image would have to be scaled up too far. (This maintains sharpness.). This behaviour can be changed by passing the %GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining the Gtk::IconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size.

Returns:

  • (GdkPixbuf::Pixbuf)

    the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

#load_icon_async(cancellable, callback, user_data) ⇒ nil

Asynchronously load, render and scale an icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon().

For more details, see gtk_icon_info_load_icon() which is the synchronous version of this call.

Parameters:

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback to call when the request is satisfied

  • user_data (GObject)

    the data to pass to callback function

Returns:

  • (nil)

#load_icon_finish(res) ⇒ GdkPixbuf::Pixbuf

Finishes an async icon load, see gtk_icon_info_load_icon_async().

Parameters:

Returns:

  • (GdkPixbuf::Pixbuf)

    the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

#load_surface(for_window) ⇒ cairo::Surface

Renders an icon previously looked up in an icon theme using gtk_icon_theme_lookup_icon(); the size will be based on the size passed to gtk_icon_theme_lookup_icon(). Note that the resulting surface may not be exactly this size; an icon theme may have icons that differ slightly from their nominal sizes, and in addition GTK+ will avoid scaling icons that it considers sufficiently close to the requested size or for which the source image would have to be scaled up too far. (This maintains sharpness.). This behaviour can be changed by passing the %GTK_ICON_LOOKUP_FORCE_SIZE flag when obtaining the Gtk::IconInfo. If this flag has been specified, the pixbuf returned by this function will be scaled to the exact size.

Parameters:

  • for_window (Gdk::Window)

    Gdk::Window to optimize drawing for, or nil

Returns:

  • (cairo::Surface)

    the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use cairo_surface_destroy() to release your reference to the icon.

#load_symbolic(fg, success_color, warning_color, error_color, was_symbolic) ⇒ GdkPixbuf::Pixbuf

Loads an icon, modifying it to match the system colours for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon().

This allows loading symbolic icons that will match the system theme.

Unless you are implementing a widget, you will want to use g_themed_icon_new_with_default_fallbacks() to load the icon.

As implementation details, the icon loaded needs to be of SVG type, contain the “symbolic” term as the last component of the icon name, and use the “fg”, “success”, “warning” and “error” CSS styles in the SVG file itself.

See the [Symbolic Icons Specification](www.freedesktop.org/wiki/SymbolicIcons) for more information about symbolic icons.

Parameters:

  • fg (Gdk::RGBA)

    a Gdk::RGBA representing the foreground color of the icon

  • success_color (Gdk::RGBA)

    a Gdk::RGBA representing the warning color of the icon or nil to use the default color

  • warning_color (Gdk::RGBA)

    a Gdk::RGBA representing the warning color of the icon or nil to use the default color

  • error_color (Gdk::RGBA)

    a Gdk::RGBA representing the error color of the icon or nil to use the default color (allow-none)

  • was_symbolic (TrueClass)

    a #gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

Returns:

#load_symbolic_async(fg, success_color, warning_color, error_color, cancellable, callback, user_data) ⇒ nil

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon().

For more details, see gtk_icon_info_load_symbolic() which is the synchronous version of this call.

Parameters:

  • fg (Gdk::RGBA)

    a Gdk::RGBA representing the foreground color of the icon

  • success_color (Gdk::RGBA)

    a Gdk::RGBA representing the warning color of the icon or nil to use the default color

  • warning_color (Gdk::RGBA)

    a Gdk::RGBA representing the warning color of the icon or nil to use the default color

  • error_color (Gdk::RGBA)

    a Gdk::RGBA representing the error color of the icon or nil to use the default color (allow-none)

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback to call when the request is satisfied

  • user_data (GObject)

    the data to pass to callback function

Returns:

  • (nil)

#load_symbolic_finish(res, was_symbolic) ⇒ GdkPixbuf::Pixbuf

Finishes an async icon load, see gtk_icon_info_load_symbolic_async().

Parameters:

  • res (Gio::AsyncResult)

    a GAsync::Result

  • was_symbolic (TrueClass)

    a #gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

Returns:

  • (GdkPixbuf::Pixbuf)

    the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

#load_symbolic_for_context(context, was_symbolic) ⇒ GdkPixbuf::Pixbuf

Loads an icon, modifying it to match the system colors for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon(). This function uses the regular foreground color and the symbolic colors with the names “success_color”, “warning_color” and “error_color” from the context.

This allows loading symbolic icons that will match the system theme.

See gtk_icon_info_load_symbolic() for more details.

Parameters:

  • context (Gtk::StyleContext)

    a Gtk::StyleContext

  • was_symbolic (TrueClass)

    a #gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

Returns:

#load_symbolic_for_context_async(context, cancellable, callback, user_data) ⇒ nil

Asynchronously load, render and scale a symbolic icon previously looked up from the icon theme using gtk_icon_theme_lookup_icon().

For more details, see gtk_icon_info_load_symbolic_for_context() which is the synchronous version of this call.

Parameters:

  • context (Gtk::StyleContext)

    a Gtk::StyleContext

  • cancellable (Gio::Cancellable)

    optional #GCancellable object, nil to ignore

  • callback (Gio::AsyncReadyCallback)

    a GAsync::ReadyCallback to call when the request is satisfied

  • user_data (GObject)

    the data to pass to callback function

Returns:

  • (nil)

#load_symbolic_for_context_finish(res, was_symbolic) ⇒ GdkPixbuf::Pixbuf

Finishes an async icon load, see gtk_icon_info_load_symbolic_for_context_async().

Parameters:

  • res (Gio::AsyncResult)

    a GAsync::Result

  • was_symbolic (TrueClass)

    a #gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

Returns:

  • (GdkPixbuf::Pixbuf)

    the rendered icon; this may be a newly created icon or a new reference to an internal icon, so you must not modify the icon. Use g_object_unref() to release your reference to the icon.

#load_symbolic_for_style(style, state, was_symbolic) ⇒ GdkPixbuf::Pixbuf

Loads an icon, modifying it to match the system colours for the foreground, success, warning and error colors provided. If the icon is not a symbolic one, the function will return the result from gtk_icon_info_load_icon().

This allows loading symbolic icons that will match the system theme.

See gtk_icon_info_load_symbolic() for more details.

Parameters:

  • style (Gtk::Style)

    a Gtk::Style to take the colors from

  • state (Gtk::StateType)

    the widget state to use for colors

  • was_symbolic (TrueClass)

    a #gboolean, returns whether the loaded icon was a symbolic one and whether the fg color was applied to it.

Returns:

#new_for_pixbuf(icon_theme, pixbuf) ⇒ Gtk::IconInfo

Creates a Gtk::IconInfo for a #GdkPixbuf.

Parameters:

Returns:

#raw_coordinates=(raw_coordinates) ⇒ nil

Sets whether the coordinates returned by gtk_icon_info_get_embedded_rect() and gtk_icon_info_get_attach_points() should be returned in their original form as specified in the icon theme, instead of scaled appropriately for the pixbuf returned by gtk_icon_info_load_icon().

Raw coordinates are somewhat strange; they are specified to be with respect to the unscaled pixmap for PNG and XPM icons, but for SVG icons, they are in a 1000x1000 coordinate space that is scaled to the final size of the icon. You can determine if the icon is an SVG icon by using gtk_icon_info_get_filename(), and seeing if it is non-nil and ends in “.svg”.

This function is provided primarily to allow compatibility wrappers for older API’s, and is not expected to be useful for applications.

Parameters:

  • raw_coordinates (TrueClass)

    whether the coordinates of embedded rectangles and attached points should be returned in their original (unscaled) form.

Returns:

  • (nil)