Gtk.Expander

const Gtk = imports.gi.Gtk;

let expander = new Gtk.Expander({
    expanded: value,
    label: value,
    label_fill: value,
    label_widget: value,
    resize_toplevel: value,
    spacing: value,
    use_markup: value,
    use_underline: value,
});
  

A Gtk.Expander allows the user to hide or show its child by clicking on an expander triangle similar to the triangles used in a Gtk.TreeView.

Normally you use an expander as you would use any other descendant of Gtk.Bin; you create the child widget and use Gtk.Container.prototype.add to add it to the expander. When the expander is toggled, it will take care of showing and hiding the child automatically.

<refsect2 id="expander-special-usage"> <title>Special Usage</title> <para> 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 but do not add a child to it. The expander widget has an Gtk.expanded property which can be used to monitor its expansion state. You should watch this property with a signal connection as follows: </para> <informalexample> <programlisting id="expander-callback-example"> expander = gtk_expander_new_with_mnemonic ("_More Options"); g_signal_connect (expander, "notify::expanded", G_CALLBACK (expander_callback), NULL);

...

static void expander_callback (GObject *object, GParamSpec *param_spec, gpointer user_data) { GtkExpander *expander;

expander = GTK_EXPANDER (object);

if (gtk_expander_get_expanded (expander)) { /&ast; Show or create widgets &ast;/ } else { /&ast; Hide or destroy widgets &ast;/ } } </programlisting> </informalexample> </refsect2> <refsect2 id="GtkExpander-BUILDER-UI"> <title>GtkExpander as GtkBuildable</title> <para> The GtkExpander implementation of the GtkBuildable interface supports placing a child in the label position by specifying "label" as the "type" attribute of a &lt;child&gt; element. A normal content child can be specified without specifying a &lt;child&gt; type attribute. </para> <example> <title>A UI definition fragment with GtkExpander</title> <programlisting><![CDATA[ <object class="GtkExpander"> <child type="label"> <object class="GtkLabel" id="expander-label"/> </child> <child> <object class="GtkEntry" id="expander-content"/> </child> </object> ]]></programlisting> </example> </refsect2>

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.Widget
        • Gtk.Container
          • Gtk.Bin
            • Gtk.Expander