ExpanderRef

public struct ExpanderRef : ExpanderProtocol, GWeakCapturing

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

Normally you use an expander as you would use a frame; you create the child widget and use [methodGtk.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.

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 GtkExpander but do not add a child to it. The expander widget has an [propertyGtk.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:

&lt;object class="GtkExpander"&gt;
  &lt;child type="label"&gt;
    &lt;object class="GtkLabel" id="expander-label"/&gt;
  &lt;/child&gt;
  &lt;child&gt;
    &lt;object class="GtkEntry" id="expander-content"/&gt;
  &lt;/child&gt;
&lt;/object&gt;

CSS nodes

expander
╰── box
    ├── title
       ├── arrow
       ╰── &lt;label widget&gt;
    ╰── &lt;child&gt;

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.

Accessibility

GtkExpander uses the GTK_ACCESSIBLE_ROLE_BUTTON role.

The ExpanderRef type acts as a lightweight Swift reference to an underlying GtkExpander instance. It exposes methods that can operate on this data type through ExpanderProtocol conformance. Use ExpanderRef only as an unowned reference to an existing GtkExpander instance.

  • ptr
    Untyped pointer to the underlying `GtkExpander` instance.
    

    For type-safe access, use the generated, typed pointer expander_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!

Expander Class

  • Designated initialiser from the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafeMutablePointer<GtkExpander>)
  • Designated initialiser from a constant pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init(_ p: UnsafePointer<GtkExpander>)
  • Conditional initialiser from an optional pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafeMutablePointer<GtkExpander>?)
  • Conditional initialiser from an optional, non-mutable pointer to the underlying C data type

    Declaration

    Swift

    @inlinable
    init!(_ maybePointer: UnsafePointer<GtkExpander>?)
  • Conditional initialiser from an optional gpointer

    Declaration

    Swift

    @inlinable
    init!(gpointer g: gpointer?)
  • Conditional initialiser from an optional, non-mutable gconstpointer

    Declaration

    Swift

    @inlinable
    init!(gconstpointer g: gconstpointer?)
  • Reference intialiser for a related type that implements ExpanderProtocol

    Declaration

    Swift

    @inlinable
    init<T>(_ other: T) where T : ExpanderProtocol
  • This factory is syntactic sugar for setting weak pointers wrapped in GWeak<T>

    Declaration

    Swift

    @inlinable
    static func unowned<T>(_ other: T) -> ExpanderRef where T : ExpanderProtocol
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ExpanderProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(cPointer: UnsafeMutablePointer<T>)
  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ExpanderProtocol.

    Declaration

    Swift

    @inlinable
    init<T>(constPointer: UnsafePointer<T>)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ExpanderProtocol.

    Declaration

    Swift

    @inlinable
    init(mutating raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ExpanderProtocol.

    Declaration

    Swift

    @inlinable
    init(raw: UnsafeMutableRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to ExpanderProtocol.

    Declaration

    Swift

    @inlinable
    init(opaquePointer: OpaquePointer)
  • Creates a new expander using label as the text of the label.

    Declaration

    Swift

    @inlinable
    init(label: UnsafePointer<CChar>? = nil)
  • 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.

    Declaration

    Swift

    @inlinable
    init(mnemonic label: UnsafePointer<CChar>? = nil)
  • 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.

    Declaration

    Swift

    @inlinable
    static func newWith(mnemonic label: UnsafePointer<CChar>? = nil) -> WidgetRef!