Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ToggleButtonMeta

[408:14] static extends: object

Generated metadata helpers for ToggleButton class surfaces.

Methods

  • properties ()

    Returns property metadata for ToggleButton.

    • @r A list.
  • signals ()

    Returns signal metadata for ToggleButton.

    • @r A list.

class: ToggleButton

[43:7] extends: object

Shows a button which remains “pressed-in” when clicked. Example GtkToggleButtons Clicking again will cause the toggle button to return to its normal state. A toggle button is created by calling either [ctor@Gtk.ToggleButton.new] or [ctor@Gtk.ToggleButton.new_with_label]. If using the former, it is advisable to pack a widget, (such as a GtkLabel and/or a GtkImage), into the toggle button’s container. (See [class@Gtk.Button] for more information). The state of a GtkToggleButton can be set specifically using [method@Gtk.ToggleButton.set_active], and retrieved using [method@Gtk.ToggleButton.get_active]. ## Grouping Toggle buttons can be grouped together, to form mutually exclusive groups - only one of the buttons can be toggled at a time, and toggling another one will switch the currently toggled one off. To add a GtkToggleButton to a group, use [method@Gtk.ToggleButton.set_group]. ## CSS nodes GtkToggleButton has a single CSS node with name button. To differentiate it from a plain GtkButton, it gets the .toggle style class. ## Accessibility GtkToggleButton uses the [enum@Gtk.AccessibleRole.toggle_button] role. ## Creating two GtkToggleButton widgets. c static void output_state (GtkToggleButton *source, gpointer user_data) { g_print ("Toggle button "%s" is active: %s", gtk_button_get_label (GTK_BUTTON (source)), gtk_toggle_button_get_active (source) ? "Yes" : "No"); } static void make_toggles (void) { GtkWidget *window, *toggle1, *toggle2; GtkWidget *box; const char *text; window = gtk_window_new (); box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); text = "Hi, I’m toggle button one"; toggle1 = gtk_toggle_button_new_with_label (text); g_signal_connect (toggle1, "toggled", G_CALLBACK (output_state), NULL); gtk_box_append (GTK_BOX (box), toggle1); text = "Hi, I’m toggle button two"; toggle2 = gtk_toggle_button_new_with_label (text); g_signal_connect (toggle2, "toggled", G_CALLBACK (output_state), NULL); gtk_box_append (GTK_BOX (box), toggle2); gtk_window_set_child (GTK_WINDOW (window), box); gtk_window_present (GTK_WINDOW (window)); }

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • ToggleButton (label = null)

    Creates a new toggle button. A widget should be packed into the button, as in [ctor@Gtk.Button.new].

    • @p label is a string containing the message to be placed in the toggle button..
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • asButton ()

    Wraps this handle as Button.

    • @r A Button object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible object.
  • asActionable ()

    Wraps this handle as Actionable.

    • @r A Actionable object.
  • asBuildable ()

    Wraps this handle as Buildable.

    • @r A Buildable object.
  • asConstraintTarget ()

    Wraps this handle as ConstraintTarget.

    • @r A ConstraintTarget object.
  • connectSignal (string Name, CallbackObj)

    Connects one generated callback wrapper to a named signal.

    • @p Name is the signal name.
    • @p CallbackObj is the generated callback wrapper to connect.
    • @r The connected handler id.
  • disconnectSignalHandler (int HandlerId)

    Disconnects one retained signal handler id.

    • @p HandlerId is the signal handler id to disconnect.
    • @r None.
  • setOnToggled (callback Fn, UserData = null)

    Emitted whenever the GtkToggleButton's state is changed.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (ToggleButton Self).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • getProperty (string Name)

    Reads one generated property by name.

  • setProperty (string Name, Value)

    Writes one generated property by name.

  • setActive (bool Value)

    If the toggle button should be pressed in.

    • @p Value is the new property value.
    • @r None.
  • setGroup (object Value)

    The toggle button whose group this widget belongs to.

    • @p Value is the new property value.
    • @r None.
  • get_active ()

    Queries a GtkToggleButton and returns its current state. Returns %TRUE if the toggle button is pressed in and %FALSE if it is raised.

  • set_active (bool is_active)

    Sets the status of the toggle button. Set to %TRUE if you want the GtkToggleButton to be “pressed in”, and %FALSE to raise it. If the status of the button changes, this action causes the [signal@Gtk.ToggleButton::toggled] signal to be emitted.

    • @p is_active is %TRUE or %FALSE..
    • @r None.
  • set_group (object group)

    Adds @self to the group of @group. In a group of multiple toggle buttons, only one button can be active at a time. Setting up groups in a cycle leads to undefined behavior. Note that the same effect can be achieved via the [iface@Gtk.Actionable] API, by using the same action with parameter type and state type 's' for all buttons in the group, and giving each button its own target value.

    • @p group is another GtkToggleButton to form a group with.
    • @r None.
  • toggled ()

    Emits the ::toggled signal on the GtkToggleButton.

    • @r None.

class: ToggleButtonCtors

[316:14] static extends: object

Alternate constructors for ToggleButton. Usage: ToggleButtonCtors.<name>(...). The primary constructor lives directly on ToggleButton.

Methods

  • newWithMnemonic (string label)

    Creates a new GtkToggleButton containing a label. The label will be created using [ctor@Gtk.Label.new_with_mnemonic], so underscores in

    • @label indicate the mnemonic for the button.
    • @p label is the text of the button, with an underscore in front of the mnemonic character.
    • @r A new ToggleButton.

class: ToggleButtonToggledCallback

[338:7] extends: object

Generated low-level callback wrapper for GIR callback toggled.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • ToggleButtonToggledCallback (callback Fn, UserData = null)

    Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking Fn.

    • @p Fn is the Aussom callback implementation.
    • @p UserData is retained and passed through to Fn on each invocation when provided.
  • trampoline (nativeSelf, nativeUserData)

    Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.

  • callback ()

    Returns the wrapped NativeCallback.

  • handle ()

    Returns the callback as a NativeHandle.

  • close ()

    Closes the underlying NativeCallback.

  • isClosed ()

    Returns true when the callback has been closed.