MenuButton Tiffany Antopolski tiffany.antopolski@gmail.com 2012 Marta Maria Casetti mmcasetti@gmail.com 2012 A widget that shows a menu when clicked on MenuButton

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.

You need to be running GNOME 3.6 for the MenuButton to work.

Code used to generate this example
Useful methods for a MenuButton widget

In line 33 the signal "activate" from the action about_action is connected to the callback function about_callback() using action.connect(signal, callback function). See for a more detailed explanation.

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.ArrowType.DOWN (other option: UP) and the horizontal alignment is Gtk.Align.START (other options: CENTER and END), 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'.

In the case of vertical alignment, the possible ArrowType directions are LEFT and RIGHT and the vertical alignment is again START, CENTER or END.

set_align_widget(alignment) and set_direction(direction) can be used to set these properties.

API References

In this sample we used the following:

MenuButton