Package: gtk

Class gtk:expander

Superclasses

Documented Subclasses

None

Direct Slots

child
The child property of type gtk:widget (Read / Write)
The child widget.
expanded
The expanded property of type :boolean (Read / Write / Construct)
Whether the expander has been opened to reveal the child widget.
Default value: false
label
The label property of type :string (Read / Write / Construct)
Text of the label of the expander.
Default value: nil
label-widget
The label-widget property of type gtk:widget (Read / Write)
A widget to display in place of the usual expander label.
resize-toplevel
The resize-toplevel property of type :boolean (Read / Write)
When this property is true, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
Default value: false
use-markup
The use-markup property of type :boolean (Read / Write / Construct)
The text of the label includes XML Pango markup.
Default value: false
use-underline
The use-underline property of type :boolean (Read / Write / Construct)
If set, an underline in the text indicates the next character should be used for the mnemonic accelerator key.
Default value: false

Details

The gtk:expander widget allows the user to hide or show its child by clicking on an expander triangle.

Figure: GtkExpander

Normally you use an expander as you would use a frame. You create the child widget and use the gtk:expander-child function 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 gtk:expander widget but do not add a child widget 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:
(let ((expander (gtk:expander-new-with-mnemonic "_More Options")))
  (g:signal-connect expander "notify::expanded"
                    (lambda (object param)
                      (if (gtk:expander-expanded object)
                          ;; Show or create widgets
                          ...
                          ;; Hide or destroy widgets
                          ... )))
  ... )  

GtkExpander as GtkBuildable

The gtk:expander implementation of the gtk: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.

Example: A UI definition fragment with a gtk:expander widget.
<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
├── title
│   ├── arrow
│   ╰── <label widget>
╰── <child>    
The gtk:expander implementation 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

The gtk:expander implementation uses the :button role of the gtk:accessible-role enumeration.

Signal Details

The "activate" signal
lambda (expander)   :action      
expander
The gtk:expander widget which receives the signal.
Activates the expander.
 

Returned by

Slot Access Functions

Inherited Slot Access Functions

2024-4-17