Gtk.Expander

Entities

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

A Gtk.Expander.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.Tree_View.Gtk_Tree_View.

Normally you use an expander as you would use any other descendant of Gtk.Bin.Gtk_Bin; you create the child widget and use Gtk.Container.Add 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.Gtk_Expander but do not add a child to it. The expander widget has an Gtk.Expander.Gtk_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 GtkExpander implementation of the GtkBuildable 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
├── title
│   ├── arrow
│   ╰── <label widget>
╰── <child>

GtkExpander 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.

<screenshot>gtk-expanded</screenshot> <group>Layout containers</group>

"+"

function "+"
  (Widget : access Gtk_Expander_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Expander
Parameters
Interf
Return Value

Cb_GObject_Void

type Cb_GObject_Void is not null access procedure
  (Self : access Glib.Object.GObject_Record'Class);
Parameters
Self

Cb_Gtk_Expander_Void

type Cb_Gtk_Expander_Void is not null access procedure (Self : access Gtk_Expander_Record'Class);
Parameters
Self

Expanded_Property

Expanded_Property : constant Glib.Properties.Property_Boolean;

Get_Expanded

function Get_Expanded
   (Expander : not null access Gtk_Expander_Record) return Boolean

Queries a Gtk.Expander.Gtk_Expander and returns its current state. Returns True if the child widget is revealed. See Gtk.Expander.Set_Expanded. Since: gtk+ 2.4

Parameters
Expander
Return Value

the current state of the expander

Get_Label

function Get_Label
   (Expander : not null access Gtk_Expander_Record) return UTF8_String

Fetches the text from a label widget including any embedded underlines indicating mnemonics and Pango markup, as set by Gtk.Expander.Set_Label. If the label text has not been set the return value will be null. This will be the case if you create an empty button with gtk_button_new to use as a container. Note that this function behaved differently in versions prior to 2.14 and used to return the label text stripped of embedded underlines indicating mnemonics and Pango markup. This problem can be avoided by fetching the label text directly from the label widget. Since: gtk+ 2.4

Parameters
Expander
Return Value

The text of the label widget. This string is owned by the widget and must not be modified or freed.

Get_Label_Fill

function Get_Label_Fill
   (Expander : not null access Gtk_Expander_Record) return Boolean

Returns whether the label widget will fill all available horizontal space allocated to Expander. Since: gtk+ 2.22

Parameters
Expander
Return Value

True if the label widget will fill all available horizontal space

Get_Label_Widget

function Get_Label_Widget
   (Expander : not null access Gtk_Expander_Record)
    return Gtk.Widget.Gtk_Widget

Retrieves the label widget for the frame. See Gtk.Expander.Set_Label_Widget. Since: gtk+ 2.4

Parameters
Expander
Return Value

the label widget, or null if there is none

Get_Resize_Toplevel

function Get_Resize_Toplevel
   (Expander : not null access Gtk_Expander_Record) return Boolean

Returns whether the expander will resize the toplevel widget containing the expander upon resizing and collpasing. Since: gtk+ 3.2

Parameters
Expander
Return Value

the "resize toplevel" setting.

Get_Spacing

function Get_Spacing
   (Expander : not null access Gtk_Expander_Record) return Glib.Gint

Gets the value set by Gtk.Expander.Set_Spacing. Since: gtk+ 2.4 Deprecated since 3.20, 1

Parameters
Expander
Return Value

spacing between the expander and child

Get_Type

function Get_Type return Glib.GType
Return Value

Get_Use_Markup

function Get_Use_Markup
   (Expander : not null access Gtk_Expander_Record) return Boolean

Returns whether the label's text is interpreted as marked up with the [Pango text markup language][PangoMarkupFormat]. See Gtk.Expander.Set_Use_Markup. Since: gtk+ 2.4

Parameters
Expander
Return Value

True if the label's text will be parsed for markup

Get_Use_Underline

function Get_Use_Underline
   (Expander : not null access Gtk_Expander_Record) return Boolean

Returns whether an embedded underline in the expander label indicates a mnemonic. See Gtk.Expander.Set_Use_Underline. Since: gtk+ 2.4

Parameters
Expander
Return Value

True if an embedded underline in the expander label indicates the mnemonic accelerator keys

Gtk_Expander

type Gtk_Expander is access all Gtk_Expander_Record'Class;

Gtk_Expander_New

function Gtk_Expander_New (Label : UTF8_String := "") return Gtk_Expander

Creates a new expander using Label as the text of the label. Since: gtk+ 2.4

Parameters
Label

the text of the label

Return Value

Gtk_Expander_New_With_Mnemonic

function Gtk_Expander_New_With_Mnemonic
   (Label : UTF8_String := "") return Gtk_Expander

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. Since: gtk+ 2.4

Parameters
Label

the text of the label with an underscore in front of the mnemonic character

Return Value

Gtk_Expander_Record

type Gtk_Expander_Record is new Gtk_Bin_Record with null record;

Gtk_New

procedure Gtk_New
   (Expander : out Gtk_Expander;
    Label    : UTF8_String := "")

Creates a new expander using Label as the text of the label. Since: gtk+ 2.4 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Expander
Label

the text of the label

Gtk_New_With_Mnemonic

procedure Gtk_New_With_Mnemonic
   (Expander : out Gtk_Expander;
    Label    : UTF8_String := "")

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. Since: gtk+ 2.4 Initialize_With_Mnemonic does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Expander
Label

the text of the label with an underscore in front of the mnemonic character

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Expander_Record, Gtk_Expander);

Initialize

procedure Initialize
   (Expander : not null access Gtk_Expander_Record'Class;
    Label    : UTF8_String := "")

Creates a new expander using Label as the text of the label. Since: gtk+ 2.4 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Expander
Label

the text of the label

Initialize_With_Mnemonic

procedure Initialize_With_Mnemonic
   (Expander : not null access Gtk_Expander_Record'Class;
    Label    : UTF8_String := "")

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. Since: gtk+ 2.4 Initialize_With_Mnemonic does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Expander
Label

the text of the label with an underscore in front of the mnemonic character

Label_Fill_Property

Label_Fill_Property : constant Glib.Properties.Property_Boolean;

Whether the label widget should fill all available horizontal space.

Note that this property is ignored since 3.20.

Label_Property

Label_Property : constant Glib.Properties.Property_String;

Label_Widget_Property

Label_Widget_Property : constant Glib.Properties.Property_Object;

Type: Gtk.Widget.Gtk_Widget

On_Activate

procedure On_Activate
   (Self  : not null access Gtk_Expander_Record;
    Call  : Cb_GObject_Void;
    Slot  : not null access Glib.Object.GObject_Record'Class;
    After : Boolean := False)
Parameters
Self
Call
Slot
After

On_Activate

procedure On_Activate
   (Self  : not null access Gtk_Expander_Record;
    Call  : Cb_Gtk_Expander_Void;
    After : Boolean := False)
Parameters
Self
Call
After

Resize_Toplevel_Property

Resize_Toplevel_Property : constant Glib.Properties.Property_Boolean;

When this property is True, the expander will resize the toplevel widget containing the expander upon expanding and collapsing.

Set_Expanded

procedure Set_Expanded
   (Expander : not null access Gtk_Expander_Record;
    Expanded : Boolean)

Sets the state of the expander. Set to True, if you want the child widget to be revealed, and False if you want the child widget to be hidden. Since: gtk+ 2.4

Parameters
Expander
Expanded

whether the child widget is revealed

Set_Label

procedure Set_Label
   (Expander : not null access Gtk_Expander_Record;
    Label    : UTF8_String := "")

Sets the text of the label of the expander to Label. This will also clear any previously set labels. Since: gtk+ 2.4

Parameters
Expander
Label

a string

Set_Label_Fill

procedure Set_Label_Fill
   (Expander   : not null access Gtk_Expander_Record;
    Label_Fill : Boolean)

Sets whether the label widget should fill all available horizontal space allocated to Expander. Note that this function has no effect since 3.20. Since: gtk+ 2.22

Parameters
Expander
Label_Fill

True if the label should should fill all available horizontal space

Set_Label_Widget

procedure Set_Label_Widget
   (Expander     : not null access Gtk_Expander_Record;
    Label_Widget : access Gtk.Widget.Gtk_Widget_Record'Class)

Set the label widget for the expander. This is the widget that will appear embedded alongside the expander arrow. Since: gtk+ 2.4

Parameters
Expander
Label_Widget

the new label widget

Set_Resize_Toplevel

procedure Set_Resize_Toplevel
   (Expander        : not null access Gtk_Expander_Record;
    Resize_Toplevel : Boolean)

Sets whether the expander will resize the toplevel widget containing the expander upon resizing and collpasing. Since: gtk+ 3.2

Parameters
Expander
Resize_Toplevel

whether to resize the toplevel

Set_Spacing

procedure Set_Spacing
   (Expander : not null access Gtk_Expander_Record;
    Spacing  : Glib.Gint)

Sets the spacing field of Expander, which is the number of pixels to place between expander and the child. Since: gtk+ 2.4 Deprecated since 3.20, 1

Parameters
Expander
Spacing

distance between the expander and child in pixels

Set_Use_Markup

procedure Set_Use_Markup
   (Expander   : not null access Gtk_Expander_Record;
    Use_Markup : Boolean)

Sets whether the text of the label contains markup in [Pango's text markup language][PangoMarkupFormat]. See Gtk.Label.Set_Markup. Since: gtk+ 2.4

Parameters
Expander
Use_Markup

True if the label's text should be parsed for markup

Set_Use_Underline

procedure Set_Use_Underline
   (Expander      : not null access Gtk_Expander_Record;
    Use_Underline : Boolean)

If true, an underline in the text of the expander label indicates the next character should be used for the mnemonic accelerator key. Since: gtk+ 2.4

Parameters
Expander
Use_Underline

True if underlines in the text indicate mnemonics

Signal_Activate

Signal_Activate : constant Glib.Signal_Name := "activate";

Spacing_Property

Spacing_Property : constant Glib.Properties.Property_Int;

Space to put between the label and the child when the expander is expanded.

Use_Markup_Property

Use_Markup_Property : constant Glib.Properties.Property_Boolean;

Use_Underline_Property

Use_Underline_Property : constant Glib.Properties.Property_Boolean;