Action

open class Action : GLibObject.Object, ActionProtocol

> In GTK+ 3.10, GtkAction has been deprecated. Use GAction > instead, and associate actions with GtkActionable widgets. Use > GMenuModel for creating menus with gtk_menu_new_from_model().

Actions represent operations that the user can be perform, along with some information how it should be presented in the interface. Each action provides methods to create icons, menu items and toolbar items representing itself.

As well as the callback that is called when the action gets activated, the following also gets associated with the action:

  • a name (not translated, for path lookup)

  • a label (translated, for display)

  • an accelerator

  • whether label indicates a stock id

  • a tooltip (optional, translated)

  • a toolbar label (optional, shorter than label)

The action will also have some state information:

  • visible (shown/hidden)

  • sensitive (enabled/disabled)

Apart from regular actions, there are toggle actions, which can be toggled between two states and radio actions, of which only one in a group can be in the “active” state. Other actions can be implemented as GtkAction subclasses.

Each action can have one or more proxy widgets. To act as an action proxy, widget needs to implement GtkActivatable interface. Proxies mirror the state of the action and should change when the action’s state changes. Properties that are always mirrored by proxies are GtkAction:sensitive and GtkAction:visible. GtkAction:gicon, GtkAction:icon-name, GtkAction:label, GtkAction:short-label and GtkAction:stock-id properties are only mirorred if proxy widget has GtkActivatable:use-action-appearance property set to true.

When the proxy is activated, it should activate its action.

The Action type acts as a reference-counted owner of an underlying GtkAction instance. It provides the methods that can operate on this data type through ActionProtocol conformance. Use Action as a strong reference or owner of a GtkAction instance.

  • Designated initialiser from the underlying `C` data type.
    

    This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Action instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GtkAction>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Action instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GtkAction>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Action instance.

    Declaration

    Swift

    @inlinable
    override public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Action instance.

    Declaration

    Swift

    @inlinable
    override public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Action instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GtkAction>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Action instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GtkAction>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. Will retain GtkAction. i.e., ownership is transferred to the Action instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GtkAction>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements ActionProtocol Will retain GtkAction.

    Declaration

    Swift

    @inlinable
    public init<T>(action other: T) where T : ActionProtocol

    Parameters

    other

    an instance of a related type that implements ActionProtocol

  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(cPointer p: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    override public init(raw p: UnsafeRawPointer)

    Parameters

    p

    raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingRaw raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    public required init(raw p: UnsafeMutableRawPointer)

    Parameters

    p

    mutable raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    required public init(retainingRaw raw: UnsafeMutableRawPointer)

    Parameters

    raw

    mutable raw pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    override public init(opaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ActionProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingOpaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Creates a new GtkAction object. To add the action to a GtkActionGroup and set the accelerator for the action, call gtk_action_group_add_action_with_accel(). See the UI Definition section for information on allowed action names.

    new is deprecated: Use #GAction instead, associating it to a widget with

    GtkActionable or creating a #GtkMenu with gtk_menu_new_from_model()

    Declaration

    Swift

    @available(*, deprecated)
    @inlinable
    public init(name: UnsafePointer<gchar>!, label: UnsafePointer<gchar>? = nil, tooltip: UnsafePointer<gchar>? = nil, stockID: UnsafePointer<gchar>? = nil)