Package: gtk

Class gtk-expander

Superclasses

gtk-bin, gtk-container, gtk-widget, gtk-buildable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

None

Direct Slots

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 g-string (Read / Write / Construct)
Text of the label of the expander.
Default value: nil
label-fill
The label-fill property of type :boolean (Read / Write / Construct)
Whether the label widget should fill all available horizontal space.
Default value: false
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
spacing
The spacing property of type :int (Read / Write)
Space to put between the label and the child.
Warning: The spacing property has been deprecated since version 3.20 and should not be used in newly written code. This property is deprecated and ignored. Use margins on the child instead.
Allowed values: >= 0
Default value: 0
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

A gtk-expander widget allows the user to hide or show its child by clicking on an expander triangle similar to the triangles used in a gtk-tree-view widget.

Normally you use an expander as you would use any other descendant of the gtk-bin class. You create the child widget and use the gtk-container-add 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.

Style Property Details

expander-size
The expander-size style property of type :int (Read)
Size of the expander arrow.
Warning: The expander-size style property has been deprecated since version 3.20 and should not be used in newly written code. Use CSS min-width and min-height instead.
Allowed values: >= 0
Default value: 10
expander-spacing
The expander-spacing style property of type :int (Read)
Spacing around expander arrow.
Warning: The expander-spacing style property has been deprecated since version 3.20 and should not be used in newly written code. Use CSS margins instead, the value of this style property is ignored.
Allowed values: >= 0
Default value: 2

Signal Details

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

Slot Access Functions

Inherited Slot Access Functions

See also

2021-12-17