| Top |
| CtkWidget * | ctk_menu_button_new () |
| void | ctk_menu_button_set_popup () |
| CtkMenu * | ctk_menu_button_get_popup () |
| void | ctk_menu_button_set_popover () |
| CtkPopover * | ctk_menu_button_get_popover () |
| void | ctk_menu_button_set_menu_model () |
| GMenuModel * | ctk_menu_button_get_menu_model () |
| void | ctk_menu_button_set_use_popover () |
| gboolean | ctk_menu_button_get_use_popover () |
| void | ctk_menu_button_set_direction () |
| CtkArrowType | ctk_menu_button_get_direction () |
| void | ctk_menu_button_set_align_widget () |
| CtkWidget * | ctk_menu_button_get_align_widget () |
| CtkContainer * | align-widget | Read / Write |
| CtkArrowType | direction | Read / Write |
| GMenuModel * | menu-model | Read / Write |
| CtkPopover * | popover | Read / Write |
| CtkMenu * | popup | Read / Write |
| gboolean | use-popover | Read / Write |
GObject
╰── GInitiallyUnowned
╰── CtkWidget
╰── CtkContainer
╰── CtkBin
╰── CtkButton
╰── CtkToggleButton
╰── CtkMenuButton
CtkMenuButton implements AtkImplementorIface, CtkBuildable, CtkActionable and CtkActivatable.
The CtkMenuButton widget is used to display a popup when clicked on. This popup can be provided either as a CtkMenu, a CtkPopover or an abstract GMenuModel.
The CtkMenuButton widget can hold any valid child widget. That is, it can hold almost any other standard CtkWidget. The most commonly used child is CtkImage. If no widget is explicitely added to the CtkMenuButton, a CtkImage is automatically created, using an arrow image oriented according to “direction” or the generic “open-menu-symbolic” icon if the direction is not set.
The positioning of the popup is determined by the “direction” property of the menu button.
For menus, the “halign” and “valign” properties of the
menu are also taken into account. For example, when the direction is
CTK_ARROW_DOWN and the horizontal alignment is CTK_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”.
CtkMenuButton has a single CSS node with name button. To differentiate it from a plain CtkButton, it gets the .popup style class.
CtkWidget *
ctk_menu_button_new (void);
Creates a new CtkMenuButton widget with downwards-pointing arrow as the only child. You can replace the child widget with another CtkWidget should you wish to.
Since: 3.6
void ctk_menu_button_set_popup (CtkMenuButton *menu_button,CtkWidget *menu);
Sets the CtkMenu that will be popped up when the menu_button
is clicked, or
NULL to dissociate any existing menu and disable the button.
If “menu-model” or “popover” are set, those objects
are dissociated from the menu_button
, and those properties are set to NULL.
Since: 3.6
CtkMenu *
ctk_menu_button_get_popup (CtkMenuButton *menu_button);
Returns the CtkMenu that pops out of the button.
If the button does not use a CtkMenu, this function
returns NULL.
Since: 3.6
void ctk_menu_button_set_popover (CtkMenuButton *menu_button,CtkWidget *popover);
Sets the CtkPopover that will be popped up when the menu_button
is clicked,
or NULL to dissociate any existing popover and disable the button.
If “menu-model” or “popup” are set, those objects
are dissociated from the menu_button
, and those properties are set to NULL.
Since: 3.12
CtkPopover *
ctk_menu_button_get_popover (CtkMenuButton *menu_button);
Returns the CtkPopover that pops out of the button.
If the button is not using a CtkPopover, this function
returns NULL.
Since: 3.12
void ctk_menu_button_set_menu_model (CtkMenuButton *menu_button,GMenuModel *menu_model);
Sets the GMenuModel from which the popup will be constructed,
or NULL to dissociate any existing menu model and disable the button.
Depending on the value of “use-popover”, either a
CtkMenu will be created with ctk_menu_new_from_model(), or a
CtkPopover with ctk_popover_new_from_model(). In either case,
actions will be connected as documented for these functions.
If “popup” or “popover” are already set, those
widgets are dissociated from the menu_button
, and those properties are set
to NULL.
Since: 3.6
GMenuModel *
ctk_menu_button_get_menu_model (CtkMenuButton *menu_button);
Returns the GMenuModel used to generate the popup.
Since: 3.6
void ctk_menu_button_set_use_popover (CtkMenuButton *menu_button,gboolean use_popover);
Sets whether to construct a CtkPopover instead of CtkMenu
when ctk_menu_button_set_menu_model() is called. Note that
this property is only consulted when a new menu model is set.
Since: 3.12
gboolean
ctk_menu_button_get_use_popover (CtkMenuButton *menu_button);
Returns whether a CtkPopover or a CtkMenu will be constructed from the menu model.
Since: 3.12
void ctk_menu_button_set_direction (CtkMenuButton *menu_button,CtkArrowType direction);
Sets the direction in which the popup will be popped up, as well as changing the arrow’s direction. The child will not be changed to an arrow if it was customized.
If the does not fit in the available space in the given direction, CTK+ will its best to keep it inside the screen and fully visible.
If you pass CTK_ARROW_NONE for a direction
, the popup will behave
as if you passed CTK_ARROW_DOWN (although you won’t see any arrows).
Since: 3.6
CtkArrowType
ctk_menu_button_get_direction (CtkMenuButton *menu_button);
Returns the direction the popup will be pointing at when popped up.
Since: 3.6
void ctk_menu_button_set_align_widget (CtkMenuButton *menu_button,CtkWidget *align_widget);
Sets the CtkWidget to use to line the menu with when popped up.
Note that the align_widget
must contain the CtkMenuButton itself.
Setting it to NULL means that the menu will be aligned with the
button itself.
Note that this property is only used with menus currently, and not for popovers.
Since: 3.6
CtkWidget *
ctk_menu_button_get_align_widget (CtkMenuButton *menu_button);
Returns the parent CtkWidget to use to line up with menu.
Since: 3.6
“align-widget” property“align-widget” CtkContainer *
The CtkWidget to use to align the menu with.
Owner: CtkMenuButton
Flags: Read / Write
Since: 3.6
“direction” property“direction” CtkArrowType
The CtkArrowType representing the direction in which the menu or popover will be popped out.
Owner: CtkMenuButton
Flags: Read / Write
Default value: CTK_ARROW_DOWN
Since: 3.6
“menu-model” property “menu-model” GMenuModel *
The GMenuModel from which the popup will be created. Depending on the “use-popover” property, that may be a menu or a popover.
See ctk_menu_button_set_menu_model() for the interaction with the
“popup” property.
Owner: CtkMenuButton
Flags: Read / Write
Since: 3.6
“popover” property“popover” CtkPopover *
The CtkPopover that will be popped up when the button is clicked.
Owner: CtkMenuButton
Flags: Read / Write
Since: 3.12
“popup” property“popup” CtkMenu *
The CtkMenu that will be popped up when the button is clicked.
Owner: CtkMenuButton
Flags: Read / Write
Since: 3.6
“use-popover” property “use-popover” gboolean
Whether to construct a CtkPopover from the menu model, or a CtkMenu.
Owner: CtkMenuButton
Flags: Read / Write
Default value: TRUE
Since: 3.12