Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: MenuButtonActivateCallback

[693:7] extends: object

Generated low-level callback wrapper for GIR callback activate.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • MenuButtonActivateCallback (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.

class: MenuButtonMeta

[763:14] static extends: object

Generated metadata helpers for MenuButton class surfaces.

Methods

  • properties ()

    Returns property metadata for MenuButton.

    • @r A list.
  • signals ()

    Returns signal metadata for MenuButton.

    • @r A list.

class: MenuButton

[49:7] extends: object

Displays a popup when clicked. An example GtkMenuButton This popup can be provided either as a GtkPopover or as an abstract GMenuModel. The GtkMenuButton widget can show either an icon (set with the [property@Gtk.MenuButton:icon-name] property) or a label (set with the [property@Gtk.MenuButton:label] property). If neither is explicitly set, a [class@Gtk.Image] is automatically created, using an arrow image oriented according to [property@Gtk.MenuButton:direction] or the generic “open-menu-symbolic” icon if the direction is not set. The positioning of the popup is determined by the [property@Gtk.MenuButton:direction] property of the menu button. For menus, the [property@Gtk.Widget:halign] and [property@Gtk.Widget:valign] properties of the menu are also taken into account. For example, when the direction is %GTK_ARROW_DOWN and the horizontal alignment is %GTK_ALIGN_START, the menu will be positioned below the button, with the starting edge (depending on the text direction) of the menu aligned with the starting edge of the button. If there is not enough space below the button, the menu is popped up above the button instead. If the alignment would move part of the menu offscreen, it is “pushed in”. | | start | center | end | | - | --- | --- | --- | | down | | | | | up | | | | | left | | | | | right | | | | # CSS nodes menubutton ╰── button.toggle ╰── <content> ╰── [arrow] GtkMenuButton has a single CSS node with name menubutton which contains a button node with a .toggle style class. If the button contains an icon, it will have the .image-button style class, if it contains text, it will have .text-button style class. If an arrow is visible in addition to an icon, text or a custom child, it will also have .arrow-button style class. Inside the toggle button content, there is an arrow node for the indicator, which will carry one of the .none, .up, .down, .left or .right style classes to indicate the direction that the menu will appear in. The CSS is expected to provide a suitable image for each of these cases using the -gtk-icon-source property. Optionally, the menubutton node can carry the .circular style class to request a round appearance. # Accessibility GtkMenuButton uses the [enum@Gtk.AccessibleRole.button] role.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • MenuButton ()

    Creates a new GtkMenuButton widget with downwards-pointing arrow as the only child. You can replace the child widget with another GtkWidget should you wish to.

  • 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.
  • asWidget ()

    Wraps this handle as Widget.

    • @r A Widget object.
  • asAccessible ()

    Wraps this handle as Accessible.

    • @r A Accessible 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.
  • setOnActivate (callback Fn, UserData = null)

    Emitted to when the menu button is activated. The ::activate signal on GtkMenuButton is an action signal and emitting it causes the button to pop up its menu.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (MenuButton 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)

    Whether the menu button is active.

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

    Whether to show a dropdown arrow even when using an icon or a custom child.

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

    Whether the size of the button can be made smaller than the natural size of its contents.

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

    The child widget.

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

    The GtkArrowType representing the direction in which the menu or popover will be popped out.

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

    Whether the button has a frame.

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

    The name of the icon used to automatically populate the button.

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

    The label for the button.

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

    The GMenuModel from which the popup will be created. See [method@Gtk.MenuButton.set_menu_model] for the interaction with the [property@Gtk.MenuButton:popover] property.

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

    The GtkPopover that will be popped up when the button is clicked.

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

    Whether the menu button acts as a primary menu. Primary menus can be opened using the F10 key

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

    If set an underscore in the text indicates a mnemonic.

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

    Returns whether the menu button is active.

  • get_always_show_arrow ()

    Gets whether to show a dropdown arrow even when using an icon or a custom child.

  • get_can_shrink ()

    Retrieves whether the button can be smaller than the natural size of its contents.

  • get_child ()

    Gets the child widget of @menu_button.

  • get_direction ()

    Returns the direction the popup will be pointing at when popped up.

  • get_has_frame ()

    Returns whether the button has a frame.

  • get_icon_name ()

    Gets the name of the icon shown in the button.

  • get_label ()

    Gets the label shown in the button

  • get_menu_model ()

    Returns the GMenuModel used to generate the popup.

  • get_popover ()

    Returns the GtkPopover that pops out of the button. If the button is not using a GtkPopover, this function returns %NULL.

  • get_primary ()

    Returns whether the menu button acts as a primary menu.

  • get_use_underline ()

    Returns whether an embedded underline in the text indicates a mnemonic.

  • popdown ()

    Dismiss the menu.

    • @r None.
  • popup ()

    Pop up the menu.

    • @r None.
  • set_active (bool active)

    Sets whether the menu button is active.

    • @p active is whether the menu button is active.
    • @r None.
  • set_always_show_arrow (bool always_show_arrow)

    Sets whether to show a dropdown arrow even when using an icon or a custom child.

    • @p always_show_arrow is whether to show a dropdown arrow even when using an icon or a custom child.
    • @r None.
  • set_can_shrink (bool can_shrink)

    Sets whether the button size can be smaller than the natural size of its contents. For text buttons, setting @can_shrink to true will ellipsize the label. For icon buttons, this function has no effect.

    • @p can_shrink is whether the button can shrink.
    • @r None.
  • set_child (object child)

    Sets the child widget of @menu_button. Setting a child resets [property@Gtk.MenuButton:label] and [property@Gtk.MenuButton:icon-name]. If [property@Gtk.MenuButton:always-show-arrow] is set to TRUE and [property@Gtk.MenuButton:direction] is not GTK_ARROW_NONE, a dropdown arrow will be shown next to the child.

    • @p child is the child widget.
    • @r None.
  • set_direction (string direction)

    Sets the direction in which the popup will be popped up. If the button is automatically populated with an arrow icon, its direction will be changed to match. If the does not fit in the available space in the given direction, GTK will its best to keep it inside the screen and fully visible. If you pass %GTK_ARROW_NONE for a @direction, the popup will behave as if you passed %GTK_ARROW_DOWN (although you won’t see any arrows).

    • @p direction is a GtkArrowType.
    • @r None.
  • set_has_frame (bool has_frame)

    Sets the style of the button.

    • @p has_frame is whether the button should have a visible frame.
    • @r None.
  • set_icon_name (string icon_name)

    Sets the name of an icon to show inside the menu button. Setting icon name resets [property@Gtk.MenuButton:label] and [property@Gtk.MenuButton:child]. If [property@Gtk.MenuButton:always-show-arrow] is set to TRUE and [property@Gtk.MenuButton:direction] is not GTK_ARROW_NONE, a dropdown arrow will be shown next to the icon.

    • @p icon_name is the icon name.
    • @r None.
  • set_label (string label)

    Sets the label to show inside the menu button. Setting a label resets [property@Gtk.MenuButton:icon-name] and [property@Gtk.MenuButton:child]. If [property@Gtk.MenuButton:direction] is not GTK_ARROW_NONE, a dropdown arrow will be shown next to the label.

    • @p label is the label.
    • @r None.
  • set_menu_model (object menu_model)

    Sets the GMenuModel from which the popup will be constructed. If

    • @menu_model is %NULL, the button is disabled. A [class@Gtk.Popover] will be created from the menu model with [ctor@Gtk.PopoverMenu.new_from_model]. Actions will be connected as documented for this function. If [property@Gtk.MenuButton:popover] is already set, it will be dissociated from the @menu_button, and the property is set to %NULL.
    • @p menu_model is a GMenuModel, or %NULL to unset and disable the button.
    • @r None.
  • set_popover (object popover)

    Sets the GtkPopover that will be popped up when the @menu_button is clicked. If @popover is %NULL, the button is disabled. If [property@Gtk.MenuButton:menu-model] is set, the menu model is dissociated from the @menu_button, and the property is set to %NULL.

    • @p popover is a GtkPopover, or %NULL to unset and disable the button.
    • @r None.
  • set_primary (bool primary)

    Sets whether menu button acts as a primary menu. Primary menus can be opened with the F10 key.

    • @p primary is whether the menubutton should act as a primary menu.
    • @r None.
  • set_use_underline (bool use_underline)

    If true, an underline in the text indicates a mnemonic.

    • @p use_underline is %TRUE if underlines in the text indicate mnemonics.
    • @r None.