Gtk.Menu_Button

Entities

Tagged Types

Access Types

Constants

Subprograms

Generic Instantiations

Description

The Gtk.Menu_Button.Gtk_Menu_Button widget is used to display a popup when clicked on. This popup can be provided either as a Gtk.Menu.Gtk_Menu, a Gtk.Popover.Gtk_Popover or an abstract Glib.Menu_Model.Gmenu_Model.

The Gtk.Menu_Button.Gtk_Menu_Button widget can hold any valid child widget. That is, it can hold almost any other standard Gtk.Widget.Gtk_Widget. The most commonly used child is Gtk.Image.Gtk_Image. If no widget is explicitely added to the Gtk.Menu_Button.Gtk_Menu_Button, a Gtk.Image.Gtk_Image is automatically created, using an arrow image oriented according to Gtk.Menu_Button.Gtk_Menu_Button:direction or the generic "open-menu-symbolic" icon if the direction is not set.

The positioning of the popup is determined by the Gtk.Menu_Button.Gtk_Menu_Button:direction property of the menu button.

For menus, the Gtk.Widget.Gtk_Widget:halign and Gtk.Widget.Gtk_Widget:valign properties of the menu are also taken into account. For example, when the direction is Gtk.Enums.Arrow_Down and the horizontal alignment is Gtk.Widget.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".

## Direction = Down

## Direction = Up

## Direction = Left

## Direction = Right

# CSS nodes

GtkMenuButton has a single CSS node with name button. To differentiate it from a plain Gtk.Button.Gtk_Button, it gets the .popup style class.

"+"

function "+"
  (Widget : access Gtk_Menu_Button_Record'Class)
return Gtk.Actionable.Gtk_Actionable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Menu_Button_Record'Class)
return Gtk.Activatable.Gtk_Activatable
Parameters
Widget
Return Value

"+"

function "+"
  (Widget : access Gtk_Menu_Button_Record'Class)
return Gtk.Buildable.Gtk_Buildable
Parameters
Widget
Return Value

"-"

function "-"
  (Interf : Gtk.Actionable.Gtk_Actionable)
return Gtk_Menu_Button
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Activatable.Gtk_Activatable)
return Gtk_Menu_Button
Parameters
Interf
Return Value

"-"

function "-"
  (Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_Menu_Button
Parameters
Interf
Return Value

Align_Widget_Property

Align_Widget_Property : constant Glib.Properties.Property_Object;

Type: Gtk.Container.Gtk_Container The Gtk.Widget.Gtk_Widget to use to align the menu with.

Direction_Property

Direction_Property : constant Gtk.Enums.Property_Gtk_Arrow_Type;

The Gtk.Enums.Gtk_Arrow_Type representing the direction in which the menu or popover will be popped out.

Do_Set_Related_Action

procedure Do_Set_Related_Action
   (Self   : not null access Gtk_Menu_Button_Record;
    Action : not null access Gtk.Action.Gtk_Action_Record'Class)
Parameters
Self
Action

Get_Action_Name

function Get_Action_Name
   (Self : not null access Gtk_Menu_Button_Record) return UTF8_String
Parameters
Self
Return Value

Get_Action_Target_Value

function Get_Action_Target_Value
   (Self : not null access Gtk_Menu_Button_Record)
    return Glib.Variant.Gvariant
Parameters
Self
Return Value

Get_Align_Widget

function Get_Align_Widget
   (Self : not null access Gtk_Menu_Button_Record)
    return Gtk.Widget.Gtk_Widget

Returns the parent Gtk.Widget.Gtk_Widget to use to line up with menu. Since: gtk+ 3.6

Parameters
Self
Return Value

a Gtk.Widget.Gtk_Widget value or null

Get_Direction

function Get_Direction
   (Self : not null access Gtk_Menu_Button_Record)
    return Gtk.Enums.Gtk_Arrow_Type

Returns the direction the popup will be pointing at when popped up. Since: gtk+ 3.6

Parameters
Self
Return Value

a Gtk.Enums.Gtk_Arrow_Type value

Get_Menu_Model

function Get_Menu_Model
   (Self : not null access Gtk_Menu_Button_Record)
    return Glib.Menu_Model.Gmenu_Model

Returns the Glib.Menu_Model.Gmenu_Model used to generate the popup. Since: gtk+ 3.6

Parameters
Self
Return Value

a Glib.Menu_Model.Gmenu_Model or null

Get_Popover

function Get_Popover
   (Self : not null access Gtk_Menu_Button_Record)
    return Gtk.Popover.Gtk_Popover

Returns the Gtk.Popover.Gtk_Popover that pops out of the button. If the button is not using a Gtk.Popover.Gtk_Popover, this function returns null. Since: gtk+ 3.12

Parameters
Self
Return Value

a Gtk.Popover.Gtk_Popover or null

Get_Popup

function Get_Popup
   (Self : not null access Gtk_Menu_Button_Record)
    return Gtk.Menu.Gtk_Menu

Returns the Gtk.Menu.Gtk_Menu that pops out of the button. If the button does not use a Gtk.Menu.Gtk_Menu, this function returns null. Since: gtk+ 3.6

Parameters
Self
Return Value

a Gtk.Menu.Gtk_Menu or null

Get_Related_Action

function Get_Related_Action
   (Self : not null access Gtk_Menu_Button_Record)
    return Gtk.Action.Gtk_Action
Parameters
Self
Return Value

Get_Type

function Get_Type return Glib.GType
Return Value

Get_Use_Action_Appearance

function Get_Use_Action_Appearance
   (Self : not null access Gtk_Menu_Button_Record) return Boolean
Parameters
Self
Return Value

Get_Use_Popover

function Get_Use_Popover
   (Self : not null access Gtk_Menu_Button_Record) return Boolean

Returns whether a Gtk.Popover.Gtk_Popover or a Gtk.Menu.Gtk_Menu will be constructed from the menu model. Since: gtk+ 3.12

Parameters
Self
Return Value

True if using a Gtk.Popover.Gtk_Popover

Gtk_Menu_Button

type Gtk_Menu_Button is access all Gtk_Menu_Button_Record'Class;

Gtk_Menu_Button_New

function Gtk_Menu_Button_New return Gtk_Menu_Button

Creates a new Gtk.Menu_Button.Gtk_Menu_Button widget with downwards-pointing arrow as the only child. You can replace the child widget with another Gtk.Widget.Gtk_Widget should you wish to. Since: gtk+ 3.6

Return Value

Gtk_Menu_Button_Record

type Gtk_Menu_Button_Record is new Gtk_Toggle_Button_Record with null record;

Gtk_New

procedure Gtk_New (Self : out Gtk_Menu_Button)

Creates a new Gtk.Menu_Button.Gtk_Menu_Button widget with downwards-pointing arrow as the only child. You can replace the child widget with another Gtk.Widget.Gtk_Widget should you wish to. Since: gtk+ 3.6 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Implements_Gtk_Actionable

package Implements_Gtk_Actionable is new Glib.Types.Implements
  (Gtk.Actionable.Gtk_Actionable, Gtk_Menu_Button_Record, Gtk_Menu_Button);

Implements_Gtk_Activatable

package Implements_Gtk_Activatable is new Glib.Types.Implements
  (Gtk.Activatable.Gtk_Activatable, Gtk_Menu_Button_Record, Gtk_Menu_Button);

Implements_Gtk_Buildable

package Implements_Gtk_Buildable is new Glib.Types.Implements
  (Gtk.Buildable.Gtk_Buildable, Gtk_Menu_Button_Record, Gtk_Menu_Button);

Initialize

procedure Initialize
   (Self : not null access Gtk_Menu_Button_Record'Class)

Creates a new Gtk.Menu_Button.Gtk_Menu_Button widget with downwards-pointing arrow as the only child. You can replace the child widget with another Gtk.Widget.Gtk_Widget should you wish to. Since: gtk+ 3.6 Initialize does nothing if the object was already created with another call to Initialize* or G_New.

Parameters
Self

Menu_Model_Property

Menu_Model_Property : constant Glib.Properties.Property_Boxed;

Type: Gio.Menu_Model The Glib.Menu_Model.Gmenu_Model from which the popup will be created. Depending on the Gtk.Menu_Button.Gtk_Menu_Button:use-popover property, that may be a menu or a popover.

See Gtk.Menu_Button.Set_Menu_Model for the interaction with the Gtk.Menu_Button.Gtk_Menu_Button:popup property.

Popover_Property

Popover_Property : constant Glib.Properties.Property_Object;

Type: Gtk.Popover.Gtk_Popover The Gtk.Popover.Gtk_Popover that will be popped up when the button is clicked.

Popup_Property

Popup_Property : constant Glib.Properties.Property_Object;

Type: Gtk.Menu.Gtk_Menu The Gtk.Menu.Gtk_Menu that will be popped up when the button is clicked.

Set_Action_Name

procedure Set_Action_Name
   (Self        : not null access Gtk_Menu_Button_Record;
    Action_Name : UTF8_String := "")
Parameters
Self
Action_Name

Set_Action_Target_Value

procedure Set_Action_Target_Value
   (Self         : not null access Gtk_Menu_Button_Record;
    Target_Value : Glib.Variant.Gvariant)
Parameters
Self
Target_Value

Set_Align_Widget

procedure Set_Align_Widget
   (Self         : not null access Gtk_Menu_Button_Record;
    Align_Widget : access Gtk.Widget.Gtk_Widget_Record'Class)

Sets the Gtk.Widget.Gtk_Widget to use to line the menu with when popped up. Note that the Align_Widget must contain the Gtk.Menu_Button.Gtk_Menu_Button 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: gtk+ 3.6

Parameters
Self
Align_Widget

a Gtk.Widget.Gtk_Widget

Set_Detailed_Action_Name

procedure Set_Detailed_Action_Name
   (Self                 : not null access Gtk_Menu_Button_Record;
    Detailed_Action_Name : UTF8_String)
Parameters
Self
Detailed_Action_Name

Set_Direction

procedure Set_Direction
   (Self      : not null access Gtk_Menu_Button_Record;
    Direction : Gtk.Enums.Gtk_Arrow_Type)

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, GTK+ will its best to keep it inside the screen and fully visible. If you pass Gtk.Enums.Arrow_None for a Direction, the popup will behave as if you passed Gtk.Enums.Arrow_Down (although you won't see any arrows). Since: gtk+ 3.6

Parameters
Self
Direction

a Gtk.Enums.Gtk_Arrow_Type

Set_Menu_Model

procedure Set_Menu_Model
   (Self       : not null access Gtk_Menu_Button_Record;
    Menu_Model : access Glib.Menu_Model.Gmenu_Model_Record'Class)

Sets the Glib.Menu_Model.Gmenu_Model from which the popup will be constructed, or null to dissociate any existing menu model and disable the button. Depending on the value of Gtk.Menu_Button.Gtk_Menu_Button:use-popover, either a Gtk.Menu.Gtk_Menu will be created with Gtk.Menu.Gtk_New_From_Model, or a Gtk.Popover.Gtk_Popover with Gtk.Popover.Gtk_New_From_Model. In either case, actions will be connected as documented for these functions. If Gtk.Menu_Button.Gtk_Menu_Button:popup or Gtk.Menu_Button.Gtk_Menu_Button:popover are already set, those widgets are dissociated from the Menu_Button, and those properties are set to null. Since: gtk+ 3.6

Parameters
Self
Menu_Model

a Glib.Menu_Model.Gmenu_Model, or null to unset and disable the button

Set_Popover

procedure Set_Popover
   (Self    : not null access Gtk_Menu_Button_Record;
    Popover : access Gtk.Widget.Gtk_Widget_Record'Class)

Sets the Gtk.Popover.Gtk_Popover that will be popped up when the Menu_Button is clicked, or null to dissociate any existing popover and disable the button. If Gtk.Menu_Button.Gtk_Menu_Button:menu-model or Gtk.Menu_Button.Gtk_Menu_Button:popup are set, those objects are dissociated from the Menu_Button, and those properties are set to null. Since: gtk+ 3.12

Parameters
Self
Popover

a Gtk.Popover.Gtk_Popover, or null to unset and disable the button

Set_Popup

procedure Set_Popup
   (Self : not null access Gtk_Menu_Button_Record;
    Menu : access Gtk.Widget.Gtk_Widget_Record'Class)

Sets the Gtk.Menu.Gtk_Menu that will be popped up when the Menu_Button is clicked, or null to dissociate any existing menu and disable the button. If Gtk.Menu_Button.Gtk_Menu_Button:menu-model or Gtk.Menu_Button.Gtk_Menu_Button:popover are set, those objects are dissociated from the Menu_Button, and those properties are set to null. Since: gtk+ 3.6

Parameters
Self
Menu

a Gtk.Menu.Gtk_Menu, or null to unset and disable the button

Set_Related_Action

procedure Set_Related_Action
   (Self   : not null access Gtk_Menu_Button_Record;
    Action : not null access Gtk.Action.Gtk_Action_Record'Class)
Parameters
Self
Action

Set_Use_Action_Appearance

procedure Set_Use_Action_Appearance
   (Self           : not null access Gtk_Menu_Button_Record;
    Use_Appearance : Boolean)
Parameters
Self
Use_Appearance

Set_Use_Popover

procedure Set_Use_Popover
   (Self        : not null access Gtk_Menu_Button_Record;
    Use_Popover : Boolean)

Sets whether to construct a Gtk.Popover.Gtk_Popover instead of Gtk.Menu.Gtk_Menu when Gtk.Menu_Button.Set_Menu_Model is called. Note that this property is only consulted when a new menu model is set. Since: gtk+ 3.12

Parameters
Self
Use_Popover

True to construct a popover from the menu model

Sync_Action_Properties

procedure Sync_Action_Properties
   (Self   : not null access Gtk_Menu_Button_Record;
    Action : access Gtk.Action.Gtk_Action_Record'Class)
Parameters
Self
Action

Use_Popover_Property

Use_Popover_Property : constant Glib.Properties.Property_Boolean;

Whether to construct a Gtk.Popover.Gtk_Popover from the menu model, or a Gtk.Menu.Gtk_Menu.