[693:7] extends: object
Generated low-level callback wrapper for GIR callback activate.
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.
Fn is the Aussom callback implementation.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.
[763:14] static extends: object
Generated metadata helpers for MenuButton class surfaces.
properties ()
Returns property metadata for
MenuButton.
A list.signals ()
Returns signal metadata for
MenuButton.
A list.[49:7] extends: object
Displays a popup when clicked.
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.
MenuButton ()
Creates a new
GtkMenuButtonwidget with downwards-pointing arrow as the only child. You can replace the child widget with anotherGtkWidgetshould 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 exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.asWidget ()
Wraps this handle as
Widget.
A Widget object.asAccessible ()
Wraps this handle as
Accessible.
A Accessible object.asBuildable ()
Wraps this handle as
Buildable.
A Buildable object.asConstraintTarget ()
Wraps this handle as
ConstraintTarget.
A ConstraintTarget object.connectSignal (string Name, CallbackObj)
Connects one generated callback wrapper to a named signal.
Name is the signal name.CallbackObj is the generated callback wrapper to connect.The connected handler id.disconnectSignalHandler (int HandlerId)
Disconnects one retained signal handler id.
HandlerId is the signal handler id to disconnect.None.setOnActivate (callback Fn, UserData = null)
Emitted to when the menu button is activated. The
::activatesignal onGtkMenuButtonis an action signal and emitting it causes the button to pop up its menu.
Fn is the Aussom callback.Fn is called with (MenuButton Self).UserData is retained and passed through to the generated callback wrapper when provided.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.
Value is the new property value.None.setAlwaysshowarrow (bool Value)
Whether to show a dropdown arrow even when using an icon or a custom child.
Value is the new property value.None.setCanshrink (bool Value)
Whether the size of the button can be made smaller than the natural size of its contents.
Value is the new property value.None.setChild (object Value)
The child widget.
Value is the new property value.None.setDirection (string Value)
The
GtkArrowTyperepresenting the direction in which the menu or popover will be popped out.
Value is the new property value.None.setHasframe (bool Value)
Whether the button has a frame.
Value is the new property value.None.setIconname (string Value)
The name of the icon used to automatically populate the button.
Value is the new property value.None.setLabel (string Value)
The label for the button.
Value is the new property value.None.setMenumodel (object Value)
The
GMenuModelfrom which the popup will be created. See [method@Gtk.MenuButton.set_menu_model] for the interaction with the [property@Gtk.MenuButton:popover] property.
Value is the new property value.None.setPopover (object Value)
The
GtkPopoverthat will be popped up when the button is clicked.
Value is the new property value.None.setPrimary (bool Value)
Whether the menu button acts as a primary menu. Primary menus can be opened using the F10 key
Value is the new property value.None.setUseunderline (bool Value)
If set an underscore in the text indicates a mnemonic.
Value is the new property value.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
GMenuModelused to generate the popup.
get_popover ()
Returns the
GtkPopoverthat pops out of the button. If the button is not using aGtkPopover, 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.
None.popup ()
Pop up the menu.
None.set_active (bool active)
Sets whether the menu button is active.
active is whether the menu button is active.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.
always_show_arrow is whether to show a dropdown arrow even when using an icon or a custom child.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.
can_shrink is whether the button can shrink.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
TRUEand [property@Gtk.MenuButton:direction] is notGTK_ARROW_NONE, a dropdown arrow will be shown next to the child.
child is the child widget.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).
direction is a GtkArrowType.None.set_has_frame (bool has_frame)
Sets the style of the button.
has_frame is whether the button should have a visible frame.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
TRUEand [property@Gtk.MenuButton:direction] is notGTK_ARROW_NONE, a dropdown arrow will be shown next to the icon.
icon_name is the icon name.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.
label is the label.None.set_menu_model (object menu_model)
Sets the
GMenuModelfrom which the popup will be constructed. If
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.menu_model is a GMenuModel, or %NULL to unset and disable the button.None.set_popover (object popover)
Sets the
GtkPopoverthat 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.
popover is a GtkPopover, or %NULL to unset and disable the button.None.set_primary (bool primary)
Sets whether menu button acts as a primary menu. Primary menus can be opened with the F10 key.
primary is whether the menubutton should act as a primary menu.None.set_use_underline (bool use_underline)
If true, an underline in the text indicates a mnemonic.
use_underline is %TRUE if underlines in the text indicate mnemonics.None.