ExpanderProtocol
public protocol ExpanderProtocol : WidgetProtocol
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 ExpanderProtocol protocol exposes the methods and properties of an underlying GtkExpander 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 Expander.
Alternatively, use ExpanderRef as a lighweight, unowned reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkExpanderinstance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get } -
expander_ptrDefault implementationTyped pointer to the underlying
GtkExpanderinstance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkExpanderinstance.Declaration
Swift
var expander_ptr: UnsafeMutablePointer<GtkExpander>! { get } -
Required Initialiser for types conforming to
ExpanderProtocolDeclaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ExpanderPropertyNamesource property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: ExpanderPropertyName, 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 : ObjectProtocolParameters
source_propertythe source property to bind
targetthe target object to bind to
target_propertythe target property to bind to
flagsthe flags to pass to the
Bindingtransform_fromValueTransformerto use for forward transformationtransform_toValueTransformerto use for backwards transformationReturn Value
binding reference or
nilin case of an error -
get(property:Extension method) Get the value of a Expander property
Declaration
Swift
@inlinable func get(property: ExpanderPropertyName) -> GLibObject.ValueParameters
propertythe property to get the value for
Return Value
the value of the named property
-
set(property:Extension methodvalue: ) Set the value of a Expander property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: ExpanderPropertyName, value v: GLibObject.Value)Parameters
propertythe property to get the value for
Return Value
the value of the named property
-
connect(signal:Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
ExpanderSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ExpanderSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatahandlerThe 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(signal:Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
ExpanderSignalNamesignalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ExpanderSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> IntParameters
signalThe signal to connect
flagsThe connection flags to use
dataA pointer to user data to provide to the callback
destroyDataA
GClosureNotifyC function to destroy the data pointed to byuserDatasignalHandlerThe C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onActivate(flags:Extension methodhandler: ) Activates the
GtkExpander.Note
This represents the underlyingactivatesignalDeclaration
Swift
@discardableResult @inlinable func onActivate(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
handlerThe signal handler to call Run the given callback whenever the
activatesignal is emitted -
activateSignalExtension methodTyped
activatesignal for using theconnect(signal:)methodsDeclaration
Swift
static var activateSignal: ExpanderSignalName { get } -
onNotifyChild(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::childsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyChild(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyChildsignal is emitted -
notifyChildSignalExtension methodTyped
notify::childsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyChildSignal: ExpanderSignalName { get } -
onNotifyExpanded(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::expandedsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyExpanded(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyExpandedsignal is emitted -
notifyExpandedSignalExtension methodTyped
notify::expandedsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyExpandedSignal: ExpanderSignalName { get } -
onNotifyLabel(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::labelsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyLabel(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyLabelsignal is emitted -
notifyLabelSignalExtension methodTyped
notify::labelsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyLabelSignal: ExpanderSignalName { get } -
onNotifyLabelWidget(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::label-widgetsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyLabelWidget(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyLabelWidgetsignal is emitted -
notifyLabelWidgetSignalExtension methodTyped
notify::label-widgetsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyLabelWidgetSignal: ExpanderSignalName { get } -
onNotifyResizeToplevel(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::resize-toplevelsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyResizeToplevel(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyResizeToplevelsignal is emitted -
notifyResizeToplevelSignalExtension methodTyped
notify::resize-toplevelsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyResizeToplevelSignal: ExpanderSignalName { get } -
onNotifyUseMarkup(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::use-markupsignalDeclaration
Swift
@discardableResult @inlinable func onNotifyUseMarkup(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyUseMarkupsignal is emitted -
notifyUseMarkupSignalExtension methodTyped
notify::use-markupsignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyUseMarkupSignal: ExpanderSignalName { get } -
onNotifyUseUnderline(flags:Extension methodhandler: ) 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 tog_object_set_property()results innotifybeing emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY, then this signal is emitted only when they explicitly callg_object_notify()org_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 underlyingnotify::use-underlinesignalDeclaration
Swift
@discardableResult @inlinable func onNotifyUseUnderline(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> IntParameters
flagsFlags
unownedSelfReference to instance of self
pspecthe
GParamSpecof the property which changed.handlerThe signal handler to call Run the given callback whenever the
notifyUseUnderlinesignal is emitted -
notifyUseUnderlineSignalExtension methodTyped
notify::use-underlinesignal for using theconnect(signal:)methodsDeclaration
Swift
static var notifyUseUnderlineSignal: ExpanderSignalName { get }
-
getChild()Extension methodGets the child widget of
expander.Declaration
Swift
@inlinable func getChild() -> WidgetRef! -
getExpanded()Extension methodQueries a
GtkExpanderand returns its current state.Returns
trueif the child widget is revealed.Declaration
Swift
@inlinable func getExpanded() -> Bool -
getLabel()Extension methodFetches the text from a label widget.
This is including any embedded underlines indicating mnemonics and Pango markup, as set by [method
Gtk.Expander.set_label]. If the label text has not been set the return value will benil. This will be the case if you create an empty button withgtk_button_new()to use as a container.Declaration
Swift
@inlinable func getLabel() -> String! -
getLabelWidget()Extension methodRetrieves the label widget for the frame.
Declaration
Swift
@inlinable func getLabelWidget() -> WidgetRef! -
getResizeToplevel()Extension methodReturns whether the expander will resize the toplevel widget containing the expander upon resizing and collpasing.
Declaration
Swift
@inlinable func getResizeToplevel() -> Bool -
getUseMarkup()Extension methodReturns whether the label’s text is interpreted as Pango markup.
Declaration
Swift
@inlinable func getUseMarkup() -> Bool -
getUseUnderline()Extension methodReturns whether an underline in the text indicates a mnemonic.
Declaration
Swift
@inlinable func getUseUnderline() -> Bool -
set(child:Extension method) Sets the child widget of
expander.Declaration
Swift
@inlinable func set(child: WidgetRef? = nil) -
set(child:Extension method) Sets the child widget of
expander.Declaration
Swift
@inlinable func set<WidgetT>(child: WidgetT?) where WidgetT : WidgetProtocol -
set(expanded:Extension method) Sets the state of the expander.
Set to
true, if you want the child widget to be revealed, andfalseif you want the child widget to be hidden.Declaration
Swift
@inlinable func set(expanded: Bool) -
set(label:Extension method) Sets the text of the label of the expander to
label.This will also clear any previously set labels.
Declaration
Swift
@inlinable func set(label: UnsafePointer<CChar>? = nil) -
set(labelWidget:Extension method) Set the label widget for the expander.
This is the widget that will appear embedded alongside the expander arrow.
Declaration
Swift
@inlinable func set(labelWidget: WidgetRef? = nil) -
set(labelWidget:Extension method) Set the label widget for the expander.
This is the widget that will appear embedded alongside the expander arrow.
Declaration
Swift
@inlinable func set<WidgetT>(labelWidget: WidgetT?) where WidgetT : WidgetProtocol -
set(resizeToplevel:Extension method) Sets whether the expander will resize the toplevel widget containing the expander upon resizing and collpasing.
Declaration
Swift
@inlinable func set(resizeToplevel: Bool) -
set(useMarkup:Extension method) Sets whether the text of the label contains Pango markup.
Declaration
Swift
@inlinable func set(useMarkup: Bool) -
set(useUnderline:Extension method) If true, an underline in the text indicates a mnemonic.
Declaration
Swift
@inlinable func set(useUnderline: Bool) -
childExtension methodThe child widget.
Declaration
Swift
@inlinable var child: WidgetRef! { get nonmutating set } -
expandedExtension methodWhether the expander has been opened to reveal the child.
Declaration
Swift
@inlinable var expanded: Bool { get nonmutating set } -
labelExtension methodThe text of the expanders label.
Declaration
Swift
@inlinable var label: String! { get nonmutating set } -
labelWidgetExtension methodRetrieves the label widget for the frame.
Declaration
Swift
@inlinable var labelWidget: WidgetRef! { get nonmutating set } -
resizeToplevelExtension methodReturns whether the expander will resize the toplevel widget containing the expander upon resizing and collpasing.
Declaration
Swift
@inlinable var resizeToplevel: Bool { get nonmutating set } -
useMarkupExtension methodReturns whether the label’s text is interpreted as Pango markup.
Declaration
Swift
@inlinable var useMarkup: Bool { get nonmutating set } -
useUnderlineExtension methodReturns whether an underline in the text indicates a mnemonic.
Declaration
Swift
@inlinable var useUnderline: Bool { get nonmutating set }
View on GitHub
Install in Dash
ExpanderProtocol Protocol Reference