gtk.expander

Module for [Expander] class

Types 3

gtk.expander.Expander allows the user to reveal its child by clicking on an expander triangle.

!An example GtkExpander

This is similar to the triangles used in a gtk.tree_view.TreeView.

Normally you use an expander as you would use a frame; you create the child widget and use gtk.expander.Expander.setChild 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.Expander but do not add a child to it. The expander widget has an gtk.expander.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 gtk.expander.Expander implementation of the gtk.buildable.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:

<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-widget
╰── box
    ├── title
    │   ├── expander
    │   ╰── <label widget>
    ╰── <child>

gtk.expander.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

gtk.expander.Expander uses the gtk.types.AccessibleRole.Button role.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
Expander self() nothrowReturns `this`, for use in `with` statements.
ExpanderGidBuilder builder() static nothrowGet builder for [gtk.expander.Expander] Returns: New builder object
gtk.widget.Widget child() @property nothrowGet `child` property. Returns: The child widget.
void child(gtk.widget.Widget propval) @property nothrowSet `child` property. Params: propval = The child widget.
bool expanded() @property nothrowGet `expanded` property. Returns: Whether the expander has been opened to reveal the child.
void expanded(bool propval) @property nothrowSet `expanded` property. Params: propval = Whether the expander has been opened to reveal the child.
string label() @property nothrowGet `label` property. Returns: The text of the expanders label.
void label(string propval) @property nothrowSet `label` property. Params: propval = The text of the expanders label.
gtk.widget.Widget labelWidget() @property nothrowGet `labelWidget` property. Returns: A widget to display instead of the usual expander label.
void labelWidget(gtk.widget.Widget propval) @property nothrowSet `labelWidget` property. Params: propval = A widget to display instead of the usual expander label.
bool resizeToplevel() @property nothrowGet `resizeToplevel` property. Returns: When this property is true, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
void resizeToplevel(bool propval) @property nothrowSet `resizeToplevel` property. Params: propval = When this property is true, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.
bool useMarkup() @property nothrowGet `useMarkup` property. Returns: Whether the text in the label is Pango markup.
void useMarkup(bool propval) @property nothrowSet `useMarkup` property. Params: propval = Whether the text in the label is Pango markup.
bool useUnderline() @property nothrowGet `useUnderline` property. Returns: Whether an underline in the text indicates a mnemonic.
void useUnderline(bool propval) @property nothrowSet `useUnderline` property. Params: propval = Whether an underline in the text indicates a mnemonic.
gtk.expander.Expander newWithMnemonic(string label = null) static nothrowCreates a new expander using label as the text of the label.
gtk.widget.Widget getChild() nothrowGets the child widget of expander. Returns: the child widget of expander
bool getExpanded() nothrowQueries a [gtk.expander.Expander] and returns its current state.
string getLabel() nothrowFetches the text from a label widget.
gtk.widget.Widget getLabelWidget() nothrowRetrieves the label widget for the frame. Returns: the label widget
bool getResizeToplevel() nothrowReturns whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing. Returns: the “resize toplevel” setting.
bool getUseMarkup() nothrowReturns whether the label’s text is interpreted as Pango markup. Returns: true if the label’s text will be parsed for markup
bool getUseUnderline() nothrowReturns whether an underline in the text indicates a mnemonic. Returns: true if an embedded underline in the expander label indicates the mnemonic accelerator keys
void setChild(gtk.widget.Widget child = null) nothrowSets the child widget of expander.
void setExpanded(bool expanded) nothrowSets the state of the expander.
void setLabel(string label = null) nothrowSets the text of the label of the expander to label.
void setLabelWidget(gtk.widget.Widget labelWidget = null) nothrowSet the label widget for the expander.
void setResizeToplevel(bool resizeToplevel) nothrowSets whether the expander will resize the toplevel widget containing the expander upon resizing and collapsing.
void setUseMarkup(bool useMarkup) nothrowSets whether the text of the label contains Pango markup.
void setUseUnderline(bool useUnderline) nothrowIf true, an underline in the text indicates a mnemonic.
gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.expander.Expander))) && Parameters!T.length < 2) nothrowConnect to `Activate` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this(string label = null)Creates a new expander using label as the text of the label.

Fluent builder implementation template for gtk.expander.Expander

Methods
T child(gtk.widget.Widget propval) nothrowSet `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chaining
T expanded(bool propval) nothrowSet `expanded` property. Params: propval = Whether the expander has been opened to reveal the child. Returns: Builder instance for fluent chaining
T label(string propval) nothrowSet `label` property. Params: propval = The text of the expanders label. Returns: Builder instance for fluent chaining
T labelWidget(gtk.widget.Widget propval) nothrowSet `labelWidget` property. Params: propval = A widget to display instead of the usual expander label. Returns: Builder instance for fluent chaining
T resizeToplevel(bool propval) nothrowSet `resizeToplevel` property. Params: propval = When this property is true, the expander will resize the toplevel widget containing the expander upon expanding and collapsing. Returns: Builder ins...
T useMarkup(bool propval) nothrowSet `useMarkup` property. Params: propval = Whether the text in the label is Pango markup. Returns: Builder instance for fluent chaining
T useUnderline(bool propval) nothrowSet `useUnderline` property. Params: propval = Whether an underline in the text indicates a mnemonic. Returns: Builder instance for fluent chaining

Fluent builder for gtk.expander.Expander

Methods
Expander build() nothrowCreate object from builder. Returns: New object