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_menu            (GtkMenuButton *menu_button,
                                                         GtkWidget *menu);
GtkMenu *           gtk_menu_button_get_menu            (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);

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.

Details

struct GtkMenuButton

struct GtkMenuButton {
  GtkToggleButton parent;
};

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_menu ()

void                gtk_menu_button_set_menu            (GtkMenuButton *menu_button,
                                                         GtkWidget *menu);

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

menu :

a GtkMenu. [allow-none]

Since 3.6


gtk_menu_button_get_menu ()

GtkMenu *           gtk_menu_button_get_menu            (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