ModelButton
open class ModelButton : Button, ModelButtonProtocol
GtkModelButton is a button class that can use a GAction
as its model.
In contrast to GtkToggleButton
or GtkRadioButton
, which can also
be backed by a GAction
via the GtkActionable:action-name
property,
GtkModelButton will adapt its appearance according to the kind of
action it is backed by, and appear either as a plain, check or
radio button.
Model buttons are used when popovers from a menu model with
gtk_popover_new_from_model()
; they can also be used manually in
a GtkPopoverMenu
.
When the action is specified via the GtkActionable:action-name
and GtkActionable:action-target
properties, the role of the button
(i.e. whether it is a plain, check or radio button) is determined by
the type of the action and doesn’t have to be explicitly specified
with the GtkModelButton:role
property.
The content of the button is specified by the GtkModelButton:text
and GtkModelButton:icon
properties.
The appearance of model buttons can be influenced with the
GtkModelButton:centered
and GtkModelButton:iconic
properties.
Model buttons have built-in support for submenus in GtkPopoverMenu
.
To make a GtkModelButton that opens a submenu when activated, set
the GtkModelButton:menu-name
property. To make a button that goes
back to the parent menu, you should set the GtkModelButton:inverted
property to place the submenu indicator at the opposite side.
Example
<object class="GtkPopoverMenu">
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="margin">10</property>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action-name">view.cut</property>
<property name="text" translatable="yes">Cut</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action-name">view.copy</property>
<property name="text" translatable="yes">Copy</property>
</object>
</child>
<child>
<object class="GtkModelButton">
<property name="visible">True</property>
<property name="action-name">view.paste</property>
<property name="text" translatable="yes">Paste</property>
</object>
</child>
</object>
</child>
</object>
CSS nodes
(plain Language Example):
modelbutton
├── <child>
╰── check
(plain Language Example):
modelbutton
├── <child>
╰── radio
(plain Language Example):
modelbutton
├── <child>
╰── arrow
GtkModelButton has a main CSS node with name modelbutton, and a subnode, which will have the name check, radio or arrow, depending on the role of the button and whether it has a menu name set.
The subnode is positioned before or after the content nodes and gets the .left or .right style class, depending on where it is located.
(plain Language Example):
button.model
├── <child>
╰── check
Iconic model buttons (see GtkModelButton:iconic
) change the name of
their main node to button and add a .model style class to it. The indicator
subnode is invisible in this case.
The ModelButton
type acts as a reference-counted owner of an underlying GtkModelButton
instance.
It provides the methods that can operate on this data type through ModelButtonProtocol
conformance.
Use ModelButton
as a strong reference or owner of a GtkModelButton
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
ModelButton
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkModelButton>)
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 theModelButton
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkModelButton>)
Parameters
op
pointer to the underlying object
-
Optional initialiser from a non-mutating
gpointer
to the underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theModelButton
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 underlyingC
data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theModelButton
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 theModelButton
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkModelButton>?)
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 theModelButton
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkModelButton>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkModelButton
. i.e., ownership is transferred to theModelButton
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkModelButton>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
ModelButtonProtocol
Will retainGtkModelButton
.Declaration
Swift
@inlinable public init<T>(modelButton other: T) where T : ModelButtonProtocol
Parameters
other
an instance of a related type that implements
ModelButtonProtocol
-
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ModelButtonProtocol
.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
ModelButtonProtocol
.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
ModelButtonProtocol
.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
ModelButtonProtocol
.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
ModelButtonProtocol
.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
ModelButtonProtocol
.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
ModelButtonProtocol
.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
ModelButtonProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Creates a new
GtkModelButton
.Declaration
Swift
@inlinable override public init()