IconThemeProtocol

public protocol IconThemeProtocol : ObjectProtocol

GtkIconTheme provides a facility for loading themed icons.

The main reason for using a name rather than simply providing a filename is to allow different icons to be used depending on what “icon theme” is selected by the user. The operation of icon themes on Linux and Unix follows the Icon Theme Specification There is a fallback icon theme, named hicolor, where applications should install their icons, but additional icon themes can be installed as operating system vendors and users choose.

In many cases, named themes are used indirectly, via [classGtk.Image] rather than directly, but looking up icons directly is also simple. The GtkIconTheme object acts as a database of all the icons in the current theme. You can create new GtkIconTheme objects, but it’s much more efficient to use the standard icon theme of the GtkWidget so that the icon information is shared with other people looking up icons.

GtkIconTheme *icon_theme;
GtkIconPaintable *icon;
GdkPaintable *paintable;

icon_theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (my_widget));
icon = gtk_icon_theme_lookup_icon (icon_theme,
                                   "my-icon-name", // icon name
                                   48, // icon size
                                   1,  // scale
                                   0,  // flags);
paintable = GDK_PAINTABLE (icon);
// Use the paintable
g_object_unref (icon);

The IconThemeProtocol protocol exposes the methods and properties of an underlying GtkIconTheme 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 IconTheme. Alternatively, use IconThemeRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkIconTheme instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • icon_theme_ptr Default implementation

    Typed pointer to the underlying GtkIconTheme instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkIconTheme instance.

    Declaration

    Swift

    var icon_theme_ptr: UnsafeMutablePointer<GtkIconTheme>! { get }
  • Required Initialiser for types conforming to IconThemeProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

IconTheme Class

  • Bind a IconThemePropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: IconThemePropertyName, 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 : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a IconTheme property

    Declaration

    Swift

    @inlinable
    func get(property: IconThemePropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a IconTheme property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: IconThemePropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

IconTheme signals

  • Connect a Swift signal handler to the given, typed IconThemeSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: IconThemeSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    handler

    The Swift signal handler (function or callback) to invoke on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • Connect a C signal handler to the given, typed IconThemeSignalName signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func connect(signal s: IconThemeSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int

    Parameters

    signal

    The signal to connect

    flags

    The connection flags to use

    data

    A pointer to user data to provide to the callback

    destroyData

    A GClosureNotify C function to destroy the data pointed to by userData

    signalHandler

    The C function to be called on the given signal

    Return Value

    The signal handler ID (always greater than 0 for successful connections)

  • onChanged(flags:handler:) Extension method

    Emitted when the icon theme changes.

    This can happen becuase current icon theme is switched or because GTK detects that a change has occurred in the contents of the current icon theme.

    Note

    This represents the underlying changed signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onChanged(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: IconThemeRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    handler

    The signal handler to call Run the given callback whenever the changed signal is emitted

  • changedSignal Extension method

    Typed changed signal for using the connect(signal:) methods

    Declaration

    Swift

    static var changedSignal: IconThemeSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::display signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyDisplay(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: IconThemeRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyDisplay signal is emitted

  • notifyDisplaySignal Extension method

    Typed notify::display signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyDisplaySignal: IconThemeSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::icon-names signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyIconNames(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: IconThemeRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyIconNames signal is emitted

  • notifyIconNamesSignal Extension method

    Typed notify::icon-names signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyIconNamesSignal: IconThemeSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::resource-path signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyResourcePath(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: IconThemeRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyResourcePath signal is emitted

  • notifyResourcePathSignal Extension method

    Typed notify::resource-path signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyResourcePathSignal: IconThemeSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::search-path signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifySearchPath(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: IconThemeRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifySearchPath signal is emitted

  • notifySearchPathSignal Extension method

    Typed notify::search-path signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifySearchPathSignal: IconThemeSignalName { get }
  • The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

    Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with G_PARAM_EXPLICIT_NOTIFY, then any call to g_object_set_property() results in notify being emitted, even if the new value is the same as the old. If they did pass G_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly call g_object_notify() or g_object_notify_by_pspec(), and common practice is to do that only when the value has actually changed.

    This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the g_signal_connect() call, like this:

    (C Language Example):

    g_signal_connect (text_view->buffer, "notify::paste-target-list",
                      G_CALLBACK (gtk_text_view_target_list_notify),
                      text_view)
    

    It is important to note that you must use canonical parameter names as detail strings for the notify signal.

    Note

    This represents the underlying notify::theme-name signal

    Declaration

    Swift

    @discardableResult
    @inlinable
    func onNotifyThemeName(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: IconThemeRef, _ pspec: ParamSpecRef) -> Void) -> Int

    Parameters

    flags

    Flags

    unownedSelf

    Reference to instance of self

    pspec

    the GParamSpec of the property which changed.

    handler

    The signal handler to call Run the given callback whenever the notifyThemeName signal is emitted

  • notifyThemeNameSignal Extension method

    Typed notify::theme-name signal for using the connect(signal:) methods

    Declaration

    Swift

    static var notifyThemeNameSignal: IconThemeSignalName { get }

IconTheme Class: IconThemeProtocol extension (methods and fields)

  • addResource(path:) Extension method

    Adds a resource path that will be looked at when looking for icons, similar to search paths.

    See [methodGtk.IconTheme.set_resource_path].

    This function should be used to make application-specific icons available as part of the icon theme.

    Declaration

    Swift

    @inlinable
    func addResource(path: UnsafePointer<CChar>!)
  • addSearch(path:) Extension method

    Appends a directory to the search path.

    See [methodGtk.IconTheme.set_search_path].

    Declaration

    Swift

    @inlinable
    func addSearch(path: UnsafePointer<CChar>!)
  • getDisplay() Extension method

    Returns the display that the GtkIconTheme object was created for.

    Declaration

    Swift

    @inlinable
    func getDisplay() -> Gdk.DisplayRef!
  • getIconNames() Extension method

    Lists the names of icons in the current icon theme.

    Declaration

    Swift

    @inlinable
    func getIconNames() -> UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>!
  • getIconSizes(iconName:) Extension method

    Returns an array of integers describing the sizes at which the icon is available without scaling.

    A size of -1 means that the icon is available in a scalable format. The array is zero-terminated.

    Declaration

    Swift

    @inlinable
    func getIconSizes(iconName: UnsafePointer<CChar>!) -> UnsafeMutablePointer<CInt>!
  • getResourcePath() Extension method

    Gets the current resource path.

    See [methodGtk.IconTheme.set_resource_path].

    Declaration

    Swift

    @inlinable
    func getResourcePath() -> UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>!
  • getSearchPath() Extension method

    Gets the current search path.

    See [methodGtk.IconTheme.set_search_path].

    Declaration

    Swift

    @inlinable
    func getSearchPath() -> UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>!
  • getThemeName() Extension method

    Gets the current icon theme name.

    Returns (transfer full): the current icon theme name,

    Declaration

    Swift

    @inlinable
    func getThemeName() -> String!
  • has(gicon:) Extension method

    Checks whether an icon theme includes an icon for a particular GIcon.

    Declaration

    Swift

    @inlinable
    func has<IconT>(gicon: IconT) -> Bool where IconT : IconProtocol
  • hasIcon(iconName:) Extension method

    Checks whether an icon theme includes an icon for a particular name.

    Declaration

    Swift

    @inlinable
    func hasIcon(iconName: UnsafePointer<CChar>!) -> Bool
  • Looks up a icon for a desired size and window scale.

    The icon can then be rendered by using it as a GdkPaintable, or you can get information such as the filename and size.

    Declaration

    Swift

    @inlinable
    func lookupByGicon<IconT>(icon: IconT, size: Int, scale: Int, direction: GtkTextDirection, flags: IconLookupFlags) -> IconPaintableRef! where IconT : IconProtocol
  • Looks up a named icon for a desired size and window scale, returning a GtkIconPaintable.

    The icon can then be rendered by using it as a GdkPaintable, or you can get information such as the filename and size.

    If the available icon_name is not available and fallbacks are provided, they will be tried in order.

    If no matching icon is found, then a paintable that renders the “missing icon” icon is returned. If you need to do something else for missing icons you need to use [methodGtk.IconTheme.has_icon].

    Note that you probably want to listen for icon theme changes and update the icon. This is usually done by overriding the GtkWidgetClass.css-changed() function.

    Declaration

    Swift

    @inlinable
    func lookupIcon(iconName: UnsafePointer<CChar>!, fallbacks: UnsafeMutablePointer<UnsafePointer<CChar>?>! = nil, size: Int, scale: Int, direction: GtkTextDirection, flags: IconLookupFlags) -> IconPaintableRef!
  • setResource(path:) Extension method

    Sets the resource paths that will be looked at when looking for icons, similar to search paths.

    The resources are considered as part of the hicolor icon theme and must be located in subdirectories that are defined in the hicolor icon theme, such as path`/16x16/actions/run.png` orpath/scalable/actions/run.svg.

    Icons that are directly placed in the resource path instead of a subdirectory are also considered as ultimate fallback, but they are treated like unthemed icons.

    Declaration

    Swift

    @inlinable
    func setResource(path: UnsafePointer<UnsafePointer<CChar>?>! = nil)
  • setSearch(path:) Extension method

    Sets the search path for the icon theme object.

    When looking for an icon theme, GTK will search for a subdirectory of one or more of the directories in path with the same name as the icon theme containing an index.theme file. (Themes from multiple of the path elements are combined to allow themes to be extended by adding icons in the user’s home directory.)

    In addition if an icon found isn’t found either in the current icon theme or the default icon theme, and an image file with the right name is found directly in one of the elements of path, then that image will be used for the icon name. (This is legacy feature, and new icons should be put into the fallback icon theme, which is called hicolor, rather than directly on the icon path.)

    Declaration

    Swift

    @inlinable
    func setSearch(path: UnsafePointer<UnsafePointer<CChar>?>! = nil)
  • set(themeName:) Extension method

    Sets the name of the icon theme that the GtkIconTheme object uses overriding system configuration.

    This function cannot be called on the icon theme objects returned from [funcGtk.IconTheme.get_for_display].

    Declaration

    Swift

    @inlinable
    func set(themeName: UnsafePointer<CChar>? = nil)
  • display Extension method

    The display that this icon theme object is attached to.

    Declaration

    Swift

    @inlinable
    var display: Gdk.DisplayRef! { get }
  • iconNames Extension method

    Lists the names of icons in the current icon theme.

    Declaration

    Swift

    @inlinable
    var iconNames: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! { get }
  • resourcePath Extension method

    Gets the current resource path.

    See [methodGtk.IconTheme.set_resource_path].

    Declaration

    Swift

    @inlinable
    var resourcePath: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! { get nonmutating set }
  • searchPath Extension method

    Gets the current search path.

    See [methodGtk.IconTheme.set_search_path].

    Declaration

    Swift

    @inlinable
    var searchPath: UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>! { get nonmutating set }
  • themeName Extension method

    Gets the current icon theme name.

    Returns (transfer full): the current icon theme name,

    Declaration

    Swift

    @inlinable
    var themeName: String! { get nonmutating set }