Gnome::Gtk4::Expander
Description
Gnome::Gtk4::Expander allows the user to reveal its child by clicking on an expander triangle.
This is similar to the triangles used in a Gnome::Gtk4::TreeView.
Normally you use an expander as you would use a frame; you create the child widget and use .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 Gnome::Gtk4::Expander but do not add a child to it. The expander widget has an expanded property which can be used to monitor its expansion state. You should watch this property with a signal connection as follows:
GtkExpander as GtkBuildable
The Gnome::Gtk4::Expander implementation of the Gnome::Gtk4::R-Buildable 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:
CSS nodes
Gnome::Gtk4::Expander has a main node expander-widget`, and subnode box containing the title and child widget. The box subnode title contains node expander, i.e. the expand/collapse arrow; then the label widget if any. The arrow of an expander that is showing its child gets the `:checked` pseudoclass set on it.
Accessibility
Gnome::Gtk4::Expander uses the GTK_ACCESSIBLE_ROLE_BUTTON
role.
Class initialization
new
:native-object
Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object :$native-object! )
new-expander
Creates a new expander using $label
as the text of the label.
method new-expander ( Str $label --> Gnome::Gtk4::Expander \)
$label; the text of the label.
new-with-mnemonic
Creates a new expander using $label
as the text of the label.
If characters in $label
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.
method new-with-mnemonic ( Str $label --> Gnome::Gtk4::Expander \)
$label; the text of the label with an underscore in front of the mnemonic character.
Methods
get-child
Gets the child widget of $expander
.
method get-child (--> N-Object )
Return value; the child widget of $expander
.
get-expanded
Queries a Gnome::Gtk4::Expander and returns its current state.
Returns True
if the child widget is revealed.
method get-expanded (--> Bool )
Return value; the current state of the expander.
get-label
Fetches the text from a label widget.
This is including any embedded underlines indicating mnemonics and Pango markup, as set by .set-label()
. If the label text has not been set the return value will be undefined. This will be the case if you create an empty button with gtk_button_new() to use as a container.
method get-label (--> Str )
Return value; The text of the label widget. This string is owned by the widget and must not be modified or freed..
get-label-widget
Retrieves the label widget for the frame.
method get-label-widget (--> N-Object )
Return value; the label widget.
get-resize-toplevel
Returns whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing.
method get-resize-toplevel (--> Bool )
Return value; the “resize toplevel” setting..
get-use-markup
Returns whether the label’s text is interpreted as Pango markup.
method get-use-markup (--> Bool )
Return value; True
if the label’s text will be parsed for markup.
get-use-underline
Returns whether an underline in the text indicates a mnemonic.
method get-use-underline (--> Bool )
Return value; True
if an embedded underline in the expander label indicates the mnemonic accelerator keys.
set-child
Sets the child widget of $expander
.
method set-child ( N-Object() $child )
$child; the child widget.
set-expanded
Sets the state of the expander.
Set to True
, if you want the child widget to be revealed, and False
if you want the child widget to be hidden.
method set-expanded ( Bool() $expanded )
$expanded; whether the child widget is revealed.
set-label
Sets the text of the label of the expander to $label
.
This will also clear any previously set labels.
method set-label ( Str $label )
$label; a string.
set-label-widget
Set the label widget for the expander.
This is the widget that will appear embedded alongside the expander arrow.
method set-label-widget ( N-Object() $label-widget )
$label-widget; the new label widget.
set-resize-toplevel
Sets whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing.
method set-resize-toplevel ( Bool() $resize-toplevel )
$resize-toplevel; whether to resize the toplevel.
set-use-markup
Sets whether the text of the label contains Pango markup.
method set-use-markup ( Bool() $use-markup )
$use-markup;
True
if the label’s text should be parsed for markup.
set-use-underline
If true, an underline in the text indicates a mnemonic.
method set-use-underline ( Bool() $use-underline )
$use-underline;
True
if underlines in the text indicate mnemonics.
Signals
activate
Activates the Gnome::Gtk4::Expander.
method handler ( Int :$_handle_id, N-GObject :$_native-object, Gnome::Gtk4::Expander :$_widget, *C<user>-options )
$_handle_id; The registered event handler id.
$_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Expander object.
$_widget; The object which registered the signal. User code may have left the object going out of scope.
user
-options; A list of named arguments provided at the.register-signal()
method from Gnome::GObject::Object.