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
GtkExpander
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
expander_ptr
Default implementationTyped pointer to the underlying
GtkExpander
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkExpander
instance.Declaration
Swift
var expander_ptr: UnsafeMutablePointer<GtkExpander>! { get }
-
Required Initialiser for types conforming to
ExpanderProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ExpanderPropertyName
source 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 : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a Expander property
Declaration
Swift
@inlinable func get(property: ExpanderPropertyName) -> GLibObject.Value
Parameters
property
the 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
property
the 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
ExpanderSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ExpanderSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The 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
ExpanderSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ExpanderSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The 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 underlyingactivate
signalDeclaration
Swift
@discardableResult @inlinable func onActivate(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
activate
signal is emitted -
activateSignal
Extension methodTyped
activate
signal 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 innotify
being 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::child
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyChild(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyChild
signal is emitted -
notifyChildSignal
Extension methodTyped
notify::child
signal 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 innotify
being 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::expanded
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyExpanded(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyExpanded
signal is emitted -
notifyExpandedSignal
Extension methodTyped
notify::expanded
signal 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 innotify
being 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
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyLabel(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyLabel
signal is emitted -
notifyLabelSignal
Extension methodTyped
notify::label
signal 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 innotify
being 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-widget
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyLabelWidget(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyLabelWidget
signal is emitted -
notifyLabelWidgetSignal
Extension methodTyped
notify::label-widget
signal 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 innotify
being 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-toplevel
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyResizeToplevel(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyResizeToplevel
signal is emitted -
notifyResizeToplevelSignal
Extension methodTyped
notify::resize-toplevel
signal 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 innotify
being 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-markup
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyUseMarkup(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyUseMarkup
signal is emitted -
notifyUseMarkupSignal
Extension methodTyped
notify::use-markup
signal 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 innotify
being 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-underline
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyUseUnderline(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ExpanderRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyUseUnderline
signal is emitted -
notifyUseUnderlineSignal
Extension methodTyped
notify::use-underline
signal 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
GtkExpander
and returns its current state.Returns
true
if 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, andfalse
if 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)
-
child
Extension methodThe child widget.
Declaration
Swift
@inlinable var child: WidgetRef! { get nonmutating set }
-
expanded
Extension methodWhether the expander has been opened to reveal the child.
Declaration
Swift
@inlinable var expanded: Bool { get nonmutating set }
-
label
Extension methodThe text of the expanders label.
Declaration
Swift
@inlinable var label: String! { get nonmutating set }
-
labelWidget
Extension methodRetrieves the label widget for the frame.
Declaration
Swift
@inlinable var labelWidget: WidgetRef! { get nonmutating set }
-
resizeToplevel
Extension 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 }
-
useMarkup
Extension methodReturns whether the label’s text is interpreted as Pango markup.
Declaration
Swift
@inlinable var useMarkup: Bool { get nonmutating set }
-
useUnderline
Extension methodReturns whether an underline in the text indicates a mnemonic.
Declaration
Swift
@inlinable var useUnderline: Bool { get nonmutating set }