It derives from <GtkWidget>.
Allows the user to reveal or conceal a child widget.
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 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.
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 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);
// ...
}
An example of a UI definition fragment with GtkExpander:
<object class="GtkExpander">
<property name="label-widget">
<object class="GtkLabel" id="expander-label"/>
</property>
<property name="child">
<object class="GtkEntry" id="expander-content"/>
</property>
</object>
expander-widget
╰── box
├── title
│ ├── expander
│ ╰── <label widget>
╰── <child>
<GtkExpander> 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.
<GtkExpander> uses the
Gtk.AccessibleRole.button role.
The child widget.
Its value is a <GtkWidget>, or #f.
Set it with (set! (expander:child self) value).
Whether the expander has been opened to reveal the child.
Its value is a boolean.
Set it with (set! (expander:expanded self) value).
The text of the expanders label.
Its value is a string, or #f.
Set it with (set! (expander:label self) value).
A widget to display instead of the usual expander label.
Its value is a <GtkWidget>, or #f.
Set it with (set! (expander:label-widget self) value).
When this property is #t, the expander will resize the toplevel
widget containing the expander upon expanding and collapsing.
Its value is a boolean.
Set it with (set! (expander:resize-toplevel self) value).
Whether the text in the label is Pango markup.
Its value is a boolean.
Set it with (set! (expander:use-markup self) value).
Whether an underline in the text indicates a mnemonic.
Its value is a boolean.
Set it with (set! (expander:use-underline self) value).
Gets the child widget of self.
Passed: a <GtkExpander>.
Returned: a <GtkWidget>, or #f.
the child widget of self
Queries a <GtkExpander> and returns its current
state.
Returns #t if the child widget is revealed.
Passed: a <GtkExpander>.
Returned: a boolean.
the current state of the expander
Fetches the text from a label widget.
This is including any embedded underlines indicating mnemonics and Pango
markup, as set by expander:set-label.
If the label text has not been set the return value will be #f.
This will be the case if you create an empty button with
button:new to use as a container.
Passed: a <GtkExpander>.
Returned: a string, or #f.
The text of the label widget. This string is owned by the widget and must not be modified or freed.
Retrieves the label widget for the frame.
Passed: a <GtkExpander>.
Returned: a <GtkWidget>, or #f.
the label widget
Returns whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing.
Passed: a <GtkExpander>.
Returned: a boolean.
the “resize toplevel” setting.
Returns whether the label’s text is interpreted as Pango markup.
Passed: a <GtkExpander>.
Returned: a boolean.
#t if the label’s text will be parsed for markup
Returns whether an underline in the text indicates a mnemonic.
Passed: a <GtkExpander>.
Returned: a boolean.
#t if an embedded underline in the expander label indicates the
mnemonic accelerator keys
Creates a new expander using label as the text of the label.
Passed, or left out: a string, or #f.
the text of the label
Returned: a <GtkWidget>.
a new <GtkExpander> widget.
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.
Passed, or left out: a string, or #f.
the text of the label with an underscore in front of the mnemonic character
Returned: a <GtkWidget>.
a new <GtkExpander> widget.
Sets the child widget of self.
Passed: a <GtkExpander>.
Passed, or left out: a <GtkWidget>, or #f.
the child widget
Sets the state of the expander.
Set to #t, if you want the child widget to be revealed, and
#f if you want the child widget to be hidden.
Passed: a <GtkExpander>.
Passed: a boolean.
whether the child widget is revealed
Sets the text of the label of the expander to label.
This will also clear any previously set labels.
Passed: a <GtkExpander>.
Passed, or left out: a string, or #f.
a string
Set the label widget for the expander.
This is the widget that will appear embedded alongside the expander arrow.
Passed: a <GtkExpander>.
Passed, or left out: a <GtkWidget>, or #f.
the new label widget
Sets whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing.
Passed: a <GtkExpander>.
Passed: a boolean.
whether to resize the toplevel
Sets whether the text of the label contains Pango markup.
Passed: a <GtkExpander>.
Passed: a boolean.
#t if the label’s text should be parsed for markup
If true, an underline in the text indicates a mnemonic.
Passed: a <GtkExpander>.
Passed: a boolean.
#t if underlines in the text indicate mnemonics
Connect a handler with (connect object expander:activate
handler). It is called as (handler self).
Activates the <GtkExpander>.
Passed: a <GtkExpander>.