Package: gtk

Class gtk-menu

Superclasses

gtk-menu-shell, gtk-container, gtk-widget, g-initially-unowned, gtk-buildable, g-object, common-lisp:standard-object, common-lisp:t

Documented Subclasses

Direct Slots

accel-group
The accel-group property of type gtk-accel-group (Read / Write)
The accel group holding accelerators for the menu.
accel-path
The accel-path property of type :string (Read / Write)
An accel path used to conveniently construct accel paths of child items.
Default value: nil
active
The active property of type :int (Read / Write)
The index of the currently selected menu item, or -1 if no menu item is selected.
Allowed values: >= -1
Default value: -1
anchor-hints
The anchor-hints property of type gdk-anchor-hints (Read / Write / Construct)
Positioning hints for aligning the menu relative to a rectangle. These hints determine how the menu should be positioned in the case that the menu would fall off-screen if placed in its ideal position. For example, :flip-y will replace :north-west with :south-west and vice versa if the menu extends beyond the bottom edge of the monitor. See the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, gtk-menu-popup-at-pointer functions, and the rect-anchor-dx, rect-anchor-dy, menu-type-hint, and popped-up properties.
Default value: :flib-x | :flip-y | :slide-x | :slide-y | :resize-x | :resize-y
Since 3.22
attach-widget
The attach-widget property of type gtk-widget (Read / Write)
The widget the menu is attached to. Setting this property attaches the menu without a GtkMenuDetachFunc. If you need to use a detacher, use gtk-menu-attach-to-widget directly.
menu-type-hint
The menu-type-hint property of type gdk-window-type-hint (Read / Write / Construct)
The gdk-window-type-hint value to use for the menu's gdk-window object. See the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, gtk-menu-popup-at-pointer functions, and the anchor-hints, rect-anchor-dx, rect-anchor-dy, and popped-up properties.
Default value: :popup-menu
Since 3.22
monitor
The monitor property of type :int (Read / Write)
The monitor the menu will be popped up on.
Allowed values: >= -1
Default value: -1
rect-anchor-dx
The rect-anchor-dx property of type :int (Read / Write / Construct)
Horizontal offset to apply to the menu, i. e. the rectangle or widget anchor. See the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, gtk-menu-popup-at-pointer functions, and the anchor-hints, rect-anchor-dy, menu-type-hint, and popped-up properties.
Default value: 0
Since 3.22
rect-anchor-dy
The rect-anchor-dy property of type :int (Read / Write / Construct)
Vertical offset to apply to the menu, i. e. the rectangle or widget anchor. See the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, gtk-menu-popup-at-pointer functions, and the anchor-hints, rect-anchor-dx, menu-type-hint, and popped-up properties.
Default value: 0
Since 3.22
reserve-toggle-size
The reserve-toggle-size property of type :boolean (Read / Write)
A boolean that indicates whether the menu reserves space for toggles and icons, regardless of their actual presence. This property should only be changed from its default value for special-purposes such as tabular menus. Regular menus that are connected to a menu bar or context menus should reserve toggle space for consistency.
Default value: true
tearoff-state
The tearoff-state property of type :boolean (Read / Write)
A boolean that indicates whether the menu is torn-off.
Warning: tearoff-state has been deprecated since version 3.10 and should not be used in newly-written code.
Default value: nil
tearoff-title
The tearoff-title property of type :string (Read / Write)
A title that may be displayed by the window manager when this menu is torn-off.
Warning: tearoff-title has been deprecated since version 3.10 and should not be used in newly-written code.
Default value: nil

Details

A gtk-menu is a gtk-menu-shell that implements a drop down menu consisting of a list of gtk-menu-item objects which can be navigated and activated by the user to perform application functions.

A gtk-menu is most commonly dropped down by activating a gtk-menu-item in a gtk-menu-bar or popped up by activating a gtk-menu-item in another gtk-menu.

A gtk-menu can also be popped up by activating a gtk-combo-box widget. Other composite widgets such as the gtk-notebook can pop up a gtk-menu as well.

Applications can display a gtk-menu as a popup menu by calling the gtk-menu-popup function. The example below shows how an application can pop up a menu when the 3rd mouse button is pressed.

Example: Connecting the popup signal handler
 /* connect our handler which will popup the menu */
 g_signal_connect_swapped (window, "button_press_event",
 G_CALLBACK (my_popup_handler), menu);  


Example: Signal handler which displays a popup menu
 static gint
 my_popup_handler (GtkWidget *widget, GdkEvent *event)
 {
   GtkMenu *menu;
   GdkEventButton *event_button;

g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE);

/* The "widget" is the menu that was supplied when * g_signal_connect_swapped() was called. */ menu = GTK_MENU (widget);

if (event->type == GDK_BUTTON_PRESS) { event_button = (GdkEventButton *) event; if (event_button->button == GDK_BUTTON_SECONDARY) { gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event_button->button, event_button->time); return TRUE; } }

return FALSE; }

CSS nodes

 menu
 ├── arrow.top
 ├── <child>
 ┊
 ├── <child>
 ╰── arrow.bottom    
The main CSS node of gtk-menu has name menu, and there are two subnodes with name arrow, for scrolling menu arrows. These subnodes get the .top and .bottom style classes.

Child Property Details

bottom-attach
The bottom-attach child property of type :int (Read / Write)
The row number to attach the bottom of the child to.
Allowed values: >= -1
Default value: -1
left-attach
The left-attach child property of type :int (Read / Write)
The column number to attach the left side of the child to.
Allowed values: >= -1
Default value: -1
right-attach
The right-attach child property of type :int (Read / Write)
The column number to attach the right side of the child to.
Allowed values: >= -1
Default value: -1
top-attach
The top-attach child property of type :int (Read / Write)
The row number to attach the top of the child to.
Allowed values: >= -1
Default value: -1

Style Property Details

arrow-placement
The arrow-placement style property of type gtk-arrow-placement (Read)
Indicates where scroll arrows should be placed.
Warning: arrow-placement has been deprecated since version 3.20 and should not be used in newly-written code. The value of this style property is ignored.
Default value: :boths
code
The arrow-scaling style property of type :float (Read)
Arbitrary constant to scale down the size of the scroll arrow.
Warning: arrow-scaling has been deprecated since version 3.20 and should not be used in newly-written code. Use the standard min-width/min-height CSS properties on the arrow node; the value of this style property is ignored.
Allowed values: [0,1]
Default value: 0.7
double-arrows
The double-arrows style property of type :boolean (Read)
When scrolling, always show both arrows.
Warning: double-arrows has been deprecated since version 3.20 and should not be used in newly-written code. The value of this style property is ignored.
Default value: true
code
The horizontal-offset style property of type :int (Read)
When the menu is a submenu, position it this number of pixels offset horizontally.
Default value: -2
horizontal-padding
The horizontal-padding style property of type :int (Read)
Extra space at the left and right edges of the menu.
Warning: The horizontal-padding style property has been deprecated since version 3.8 and should not be used in newly-written code. use the standard padding CSS property, through objects like gtk-style-context and gtk-css-provider; the value of this style property is ignored.
Allowed values: >= 0
Default value: 0
vertical-offset
The vertical-offset style property of type :int (Read)
When the menu is a submenu, position it this number of pixels offset vertically.
Default value: 0
vertical-padding
The vertical-padding style property of type :int (Read)
Extra space at the top and bottom of the menu.
Warning: The vertical-padding style property has been deprecated since version 3.8 and should not be used in newly-written code. Use the standard padding CSS property, through objects like gtk-style-context and gtk-css-provider; the value of this style property is ignored.
Allowed values: >= 0
Default value: 1

Signal Details

The "move-scroll" signal
 lambda (menu scroll-type)   : Action      
menu
a gtk-menu widget
scroll-type
a gtk-scroll-type
The "popped-up" signal
 lambda (menu flipped-rect final-rect flipped-x flipped-y)    : Run First      
Emitted when the position of menu is finalized after being popped up using the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, or gtk-menu-popup-at-pointer functions.

menu might be flipped over the anchor rectangle in order to keep it on-screen, in which case flipped-x and flipped-y will be set to true accordingly.

flipped-rect is the ideal position of menu after any possible flipping, but before any possible sliding. final-rect is flipped-rect, but possibly translated in the case that flipping is still ineffective in keeping menu on-screen.



The blue menu is menu's ideal position, the green menu is flipped-rect, and the red menu is final-rect.

See the gtk-menu-popup-at-rect, gtk-menu-popup-at-widget, gtk-menu-popup-at-pointer functions, "anchor-hints", "rect-anchor-dx", "rect-anchor-dy", and "menu-type-hint".
menu
a gtk-menu widget that popped up
flipped-rect
The position of menu after any possible flipping or nil if the backend can't obtain it.
final-rect
The final position of menu or nil if the backend can't obtain it.
flipped-x
True if the anchors were flipped horizontally.
flipped-y
True if the anchors were flipped vertically.
Since 3.22
 

Slot Access Functions

Inherited Slot Access Functions

2013-6-1