Expander
open class Expander : Bin, ExpanderProtocol
A GtkExpander
allows the user to hide or show its child by clicking
on an expander triangle similar to the triangles used in a GtkTreeView
.
Normally you use an expander as you would use any other descendant
of GtkBin
; you create the child widget and use gtk_container_add()
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
GtkExpander:expanded
property which can be used to monitor
its expansion state. You should watch this property with a signal
connection as follows:
(C Language Example):
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
(plain Language Example):
expander
├── 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.
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
Expander
instance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkExpander>)
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 theExpander
instance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkExpander>)
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 theExpander
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 theExpander
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 theExpander
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkExpander>?)
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 theExpander
instance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkExpander>?)
Parameters
op
pointer to the underlying object
-
Designated initialiser from the underlying
C
data type. Will retainGtkExpander
. i.e., ownership is transferred to theExpander
instance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkExpander>)
Parameters
op
pointer to the underlying object
-
Reference intialiser for a related type that implements
ExpanderProtocol
Will retainGtkExpander
.Declaration
Swift
@inlinable public init<T>(expander other: T) where T : ExpanderProtocol
Parameters
other
an 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
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
ExpanderProtocol
.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
ExpanderProtocol
.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
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
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
ExpanderProtocol
.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
ExpanderProtocol
.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
ExpanderProtocol
.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)
Parameters
p
opaque pointer to the underlying object
-
Creates a new expander using
label
as the text of the label.Declaration
Swift
@inlinable public init(label: UnsafePointer<gchar>? = nil)
-
Creates a new expander using
label
as the text of the label. If characters inlabel
are 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<gchar>? = nil)
-
Creates a new expander using
label
as the text of the label. If characters inlabel
are 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<gchar>? = nil) -> Widget!