## GtkMenuButton GtkMenuButton — A widget that shows a menu when clicked on |

## Synopsis

    #include <gtk/gtk.h>

    struct              GtkMenuButton;
    GtkWidget *         gtk_menu_button_new                 (void);
    void                gtk_menu_button_set_popup           (GtkMenuButton *menu_button,
                                                             GtkWidget *popup);
    GtkMenu *           gtk_menu_button_get_popup           (GtkMenuButton *menu_button);
    void                gtk_menu_button_set_menu_model      (GtkMenuButton *menu_button,
                                                             GMenuModel *menu_model);
    GMenuModel *        gtk_menu_button_get_menu_model      (GtkMenuButton *menu_button);
    void                gtk_menu_button_set_direction       (GtkMenuButton *menu_button,
                                                             GtkArrowType direction);
    GtkArrowType        gtk_menu_button_get_direction       (GtkMenuButton *menu_button);
    void                gtk_menu_button_set_align_widget    (GtkMenuButton *menu_button,
                                                             GtkWidget *align_widget);
    GtkWidget *         gtk_menu_button_get_align_widget    (GtkMenuButton *menu_button);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkWidget
                   +----GtkContainer
                         +----GtkBin
                               +----GtkButton
                                     +----GtkToggleButton
                                           +----GtkMenuButton

## Implemented Interfaces

GtkMenuButton implements AtkImplementorIface, GtkBuildable, GtkActionable and GtkActivatable.

## Properties

      "align-widget"             GtkContainer*         : Read / Write
      "direction"                GtkArrowType          : Read / Write
      "menu"                     GtkMenu*              : Read / Write
      "menu-model"               GMenuModel*           : Read / Write
      "popup"                    GtkMenu*              : Read / Write

## Description

The GtkMenuButton widget is used to display a menu when clicked on. This menu can be provided either as a GtkMenu, or an abstract GMenuModel.

The GtkMenuButton widget can hold any valid child widget. That is, it can hold almost any other standard GtkWidget. The most commonly used child is the provided GtkArrow.

The positioning of the menu is determined by the "direction" property of the menu button and the "halign" or "valign" properties of the menu. 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'.

| halign = start | halign = center | halign = end
direction = down |  |  |
direction = up |  |  |

| direction = left | direction = right
valign = start |  |
valign = center |  |
valign = end |  |

## Details

### struct GtkMenuButton

    struct GtkMenuButton;

### gtk_menu_button_new ()

    GtkWidget *         gtk_menu_button_new                 (void);

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.

Returns : | The newly created GtkMenuButton widget.

Since 3.6

### gtk_menu_button_set_popup ()

    void                gtk_menu_button_set_popup           (GtkMenuButton *menu_button,
                                                             GtkWidget *popup);

Sets the GtkMenu that will be popped up when the button is clicked, or `NULL` to disable the button. If "menu-model" is set, it will be set to `NULL`.

`menu_button` : | a GtkMenuButton
`popup` : | a GtkMenu. [allow-none]

Since 3.6

### gtk_menu_button_get_popup ()

    GtkMenu *           gtk_menu_button_get_popup           (GtkMenuButton *menu_button);

Returns the GtkMenu that pops out of the button.

`menu_button` : | a GtkMenuButton
Returns : | a GtkMenu or `NULL`. [transfer none]

Since 3.6

### gtk_menu_button_set_menu_model ()

    void                gtk_menu_button_set_menu_model      (GtkMenuButton *menu_button,
                                                             GMenuModel *menu_model);

Sets the GMenuModel from which the "menu" property will be filled in, or `NULL` to disable the button.

The GtkMenu will be created with `gtk_menu_new_from_model()`, so actions will be connected as documented there.

If you "menu" * is already set, then its content will be lost and replaced by our newly created GtkMenu.

`menu_button` : | a GtkMenuButton
`menu_model` : | a GMenuModel. [allow-none]

Since 3.6

### gtk_menu_button_get_menu_model ()

    GMenuModel *        gtk_menu_button_get_menu_model      (GtkMenuButton *menu_button);

Returns the GMenuModel used to generate the menu.

`menu_button` : | a GtkMenuButton
Returns : | a GMenuModel or `NULL`. [transfer none]

Since 3.6

### gtk_menu_button_set_direction ()

    void                gtk_menu_button_set_direction       (GtkMenuButton *menu_button,
                                                             GtkArrowType direction);

Sets the direction in which the menu 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 menu when popped out would have collided with screen edges, we will do our best to keep it inside the screen and fully visible.

If you pass GTK_ARROW_NONE for a `direction`, the menu will behave as if you passed GTK_ARROW_DOWN (although you won't see any arrows).

`menu_button` : | a GtkMenuButton
`direction` : | a GtkArrowType

Since 3.6

### gtk_menu_button_get_direction ()

    GtkArrowType        gtk_menu_button_get_direction       (GtkMenuButton *menu_button);

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

`menu_button` : | a GtkMenuButton
Returns : | a GtkArrowType value.

Since 3.6

### gtk_menu_button_set_align_widget ()

    void                gtk_menu_button_set_align_widget    (GtkMenuButton *menu_button,
                                                             GtkWidget *align_widget);

Sets the GtkWidget to use to line the menu with when popped up. Note that the `align_widget` must contain the GtkMenuButton itself.

Setting it to `NULL` means that the popup menu will be aligned with the button itself.

`menu_button` : | a GtkMenuButton
`align_widget` : | a GtkWidget. [allow-none]

Since 3.6

### gtk_menu_button_get_align_widget ()

    GtkWidget *         gtk_menu_button_get_align_widget    (GtkMenuButton *menu_button);

Returns the parent GtkWidget to use to line up with menu.

`menu_button` : | a GtkMenuButton
Returns : | a GtkWidget value or `NULL`. [transfer none]

Since 3.6

## Property Details

### The `"align-widget"` property

      "align-widget"             GtkContainer*         : Read / Write

The GtkWidget to use to align the popup menu with.

Since 3.6

### The `"direction"` property

      "direction"                GtkArrowType          : Read / Write

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

Default value: GTK_ARROW_DOWN

Since 3.6

### The `"menu"` property

      "menu"                     GtkMenu*              : Read / Write

The GtkMenu that will be popped up when the button is clicked. This property has been renamed to "popup". "menu" will be removed before 3.6.0.

Since 3.6

### The `"menu-model"` property

      "menu-model"               GMenuModel*           : Read / Write

The GMenuModel from which the menu to pop up will be created. See `gtk_menu_button_set_menu_model()` for the interaction with the "menu" property.

Since 3.6

### The `"popup"` property

      "popup"                    GtkMenu*              : Read / Write

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

Since 3.6