Expander
open class Expander : Widget, ExpanderProtocol
GtkExpander allows the user to reveal its child by clicking
on an expander triangle.

This is similar to the triangles used in a GtkTreeView.
Normally you use an expander as you would use a frame; you create
the child widget and use [methodGtk.Expander.set_child] to add it
to the expander. When the expander is toggled, it will take care of
showing and hiding the child automatically.
Special Usage
There are situations in which you may prefer to show and hide the
expanded widget yourself, such as when you want to actually create
the widget at expansion time. In this case, create a GtkExpander
but do not add a child to it. The expander widget has an
[propertyGtk.Expander:expanded[ property which can be used to
monitor its expansion state. You should watch this property with
a signal connection as follows:
static void
expander_callback (GObject *object,
GParamSpec *param_spec,
gpointer user_data)
{
GtkExpander *expander;
expander = GTK_EXPANDER (object);
if (gtk_expander_get_expanded (expander))
{
// Show or create widgets
}
else
{
// Hide or destroy widgets
}
}
static void
create_expander (void)
{
GtkWidget *expander = gtk_expander_new_with_mnemonic ("_More Options");
g_signal_connect (expander, "notify`expanded`",
G_CALLBACK (expander_callback), NULL);
// ...
}
GtkExpander as GtkBuildable
The GtkExpander implementation of the GtkBuildable interface supports
placing a child in the label position by specifying “label” as the
“type” attribute of a <child> element. A normal content child can be
specified without specifying a <child> type attribute.
An example of a UI definition fragment with GtkExpander:
<object class="GtkExpander">
<child type="label">
<object class="GtkLabel" id="expander-label"/>
</child>
<child>
<object class="GtkEntry" id="expander-content"/>
</child>
</object>
CSS nodes
expander
╰── box
├── title
│ ├── arrow
│ ╰── <label widget>
╰── <child>
GtkExpander has three CSS nodes, the main node with the name expander,
a subnode with name title and node below it with name arrow. The arrow of an
expander that is showing its child gets the :checked pseudoclass added to it.
Accessibility
GtkExpander uses the GTK_ACCESSIBLE_ROLE_BUTTON role.
The Expander type acts as a reference-counted owner of an underlying GtkExpander instance.
It provides the methods that can operate on this data type through ExpanderProtocol conformance.
Use Expander as a strong reference or owner of a GtkExpander 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
Expanderinstance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkExpander>)Parameters
oppointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theExpanderinstance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkExpander>)Parameters
oppointer to the underlying object
-
Optional initialiser from a non-mutating
gpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theExpanderinstance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)Parameters
opgpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theExpanderinstance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)Parameters
oppointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theExpanderinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkExpander>?)Parameters
oppointer to the underlying object
-
Optional initialiser from the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theExpanderinstance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkExpander>?)Parameters
oppointer to the underlying object
-
Designated initialiser from the underlying
Cdata type. Will retainGtkExpander. i.e., ownership is transferred to theExpanderinstance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkExpander>)Parameters
oppointer to the underlying object
-
Reference intialiser for a related type that implements
ExpanderProtocolWill retainGtkExpander.Declaration
Swift
@inlinable public init<T>(expander other: T) where T : ExpanderProtocolParameters
otheran instance of a related type that implements
ExpanderProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ExpanderProtocol.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ExpanderProtocol.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ExpanderProtocol.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)Parameters
praw 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
ExpanderProtocol.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
ExpanderProtocol.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)Parameters
pmutable 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
ExpanderProtocol.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)Parameters
rawmutable 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
ExpanderProtocol.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)Parameters
popaque 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
ExpanderProtocol.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Creates a new expander using
labelas the text of the label.Declaration
Swift
@inlinable public init(label: UnsafePointer<CChar>? = nil) -
Creates a new expander using
labelas the text of the label.If characters in
labelare preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic.Pressing Alt and that key activates the button.
Declaration
Swift
@inlinable public init(mnemonic label: UnsafePointer<CChar>? = nil) -
Creates a new expander using
labelas the text of the label.If characters in
labelare preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic.Pressing Alt and that key activates the button.
Declaration
Swift
@inlinable public static func newWith(mnemonic label: UnsafePointer<CChar>? = nil) -> Widget!
View on GitHub
Install in Dash
Expander Class Reference