Class: Gtk::Menu
- Inherits:
-
Object
- Object
- Gtk::Menu
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#accel_group ⇒ Gtk::AccelGroup
The accel group holding accelerators for the menu.
-
#accel_group=(accel_group) ⇒ Gtk::AccelGroup
The accel group holding accelerators for the menu.
-
#accel_path ⇒ String
An accel path used to conveniently construct accel paths of child items.
-
#accel_path=(accel_path) ⇒ String
An accel path used to conveniently construct accel paths of child items.
-
#active ⇒ Integer
The index of the currently selected menu item, or -1 if no menu item is selected.
-
#active=(active) ⇒ Integer
The index of the currently selected menu item, or -1 if no menu item is selected.
-
#anchor_hints ⇒ Gdk::AnchorHints
Positioning hints for aligning the menu relative to a rectangle.
-
#anchor_hints=(anchor_hints) ⇒ Gdk::AnchorHints
Positioning hints for aligning the menu relative to a rectangle.
-
#attach(child, left_attach, right_attach, top_attach, bottom_attach) ⇒ nil
Adds a new Gtk::MenuItem to a (table) menu.
-
#attach_to_widget(attach_widget, detacher) ⇒ nil
Attaches the menu to the widget and provides a callback function that will be invoked when the menu calls gtk_menu_detach() during its destruction.
-
#attach_widget ⇒ Gtk::Widget
The widget the menu is attached to.
-
#attach_widget=(attach_widget) ⇒ Gtk::Widget
The widget the menu is attached to.
-
#detach ⇒ nil
Detaches the menu from the widget to which it had been attached.
-
#menu_type_hint ⇒ Gdk::WindowTypeHint
The Gdk::WindowTypeHint to use for the menu’s #GdkWindow.
-
#menu_type_hint=(menu_type_hint) ⇒ Gdk::WindowTypeHint
The Gdk::WindowTypeHint to use for the menu’s #GdkWindow.
-
#monitor ⇒ Integer
The monitor the menu will be popped up on.
-
#monitor=(monitor) ⇒ Integer
The monitor the menu will be popped up on.
-
#new ⇒ Gtk::Widget
Creates a new Gtk::Menu.
-
#new_from_model(model) ⇒ Gtk::Widget
Creates a Gtk::Menu and populates it with menu items and submenus according to model.
-
#place_on_monitor(monitor) ⇒ nil
Places menu on the given monitor.
-
#popdown ⇒ nil
Removes the menu from the screen.
-
#popup(parent_menu_shell, parent_menu_item, func, data, button, activate_time) ⇒ nil
Displays a menu and makes it available for selection.
-
#popup_at_pointer(trigger_event) ⇒ nil
Displays menu and makes it available for selection.
-
#popup_at_rect(rect_window, rect, rect_anchor, menu_anchor, trigger_event) ⇒ nil
Displays menu and makes it available for selection.
-
#popup_at_widget(widget, widget_anchor, menu_anchor, trigger_event) ⇒ nil
Displays menu and makes it available for selection.
-
#popup_for_device(device, parent_menu_shell, parent_menu_item, func, data, destroy, button, activate_time) ⇒ nil
Displays a menu and makes it available for selection.
-
#rect_anchor_dx ⇒ Integer
Horizontal offset to apply to the menu, i.e.
-
#rect_anchor_dx=(rect_anchor_dx) ⇒ Integer
Horizontal offset to apply to the menu, i.e.
-
#rect_anchor_dy ⇒ Integer
Vertical offset to apply to the menu, i.e.
-
#rect_anchor_dy=(rect_anchor_dy) ⇒ Integer
Vertical offset to apply to the menu, i.e.
-
#reorder_child(child, position) ⇒ nil
Moves child to a new position in the list of menu children.
-
#reposition ⇒ nil
Repositions the menu according to its position function.
-
#reserve_toggle_size ⇒ TrueClass
Returns whether the menu reserves space for toggles and icons, regardless of their actual presence.
-
#reserve_toggle_size=(reserve_toggle_size) ⇒ TrueClass
A boolean that indicates whether the menu reserves space for toggles and icons, regardless of their actual presence.
-
#reserve_toggle_size? ⇒ TrueClass
A boolean that indicates whether the menu reserves space for toggles and icons, regardless of their actual presence.
-
#screen=(screen) ⇒ nil
Sets the Gdk::Screen on which the menu will be displayed.
-
#tearoff_state ⇒ TrueClass
Returns whether the menu is torn off.
-
#tearoff_state=(tearoff_state) ⇒ TrueClass
A boolean that indicates whether the menu is torn-off.
-
#tearoff_state? ⇒ TrueClass
A boolean that indicates whether the menu is torn-off.
-
#tearoff_title ⇒ String
A title that may be displayed by the window manager when this menu is torn-off.
-
#tearoff_title=(tearoff_title) ⇒ String
A title that may be displayed by the window manager when this menu is torn-off.
-
#title ⇒ String
Returns the title of the menu.
-
#title=(title) ⇒ nil
Sets the title string for the menu.
Instance Method Details
#accel_group ⇒ Gtk::AccelGroup
The accel group holding accelerators for the menu.
#accel_group=(accel_group) ⇒ Gtk::AccelGroup
The accel group holding accelerators for the menu.
#accel_path ⇒ String
An accel path used to conveniently construct accel paths of child items.
#accel_path=(accel_path) ⇒ String
An accel path used to conveniently construct accel paths of child items.
#active ⇒ Integer
The index of the currently selected menu item, or -1 if no menu item is selected.
#active=(active) ⇒ Integer
The index of the currently selected menu item, or -1 if no menu item is selected.
#anchor_hints ⇒ Gdk::AnchorHints
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, %GDK_ANCHOR_FLIP_Y will replace %GDK_GRAVITY_NORTH_WEST with %GDK_GRAVITY_SOUTH_WEST and vice versa if the menu extends beyond the bottom edge of the monitor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:rect-anchor-dx, Gtk::Menu:rect-anchor-dy, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
#anchor_hints=(anchor_hints) ⇒ Gdk::AnchorHints
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, %GDK_ANCHOR_FLIP_Y will replace %GDK_GRAVITY_NORTH_WEST with %GDK_GRAVITY_SOUTH_WEST and vice versa if the menu extends beyond the bottom edge of the monitor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:rect-anchor-dx, Gtk::Menu:rect-anchor-dy, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
#attach(child, left_attach, right_attach, top_attach, bottom_attach) ⇒ nil
Adds a new Gtk::MenuItem to a (table) menu. The number of “cells” that an item will occupy is specified by left_attach, right_attach, top_attach and bottom_attach. These each represent the leftmost, rightmost, uppermost and lower column and row numbers of the table. (Columns and rows are indexed from zero).
Note that this function is not related to gtk_menu_detach().
#attach_to_widget(attach_widget, detacher) ⇒ nil
Attaches the menu to the widget and provides a callback function that will be invoked when the menu calls gtk_menu_detach() during its destruction.
If the menu is attached to the widget then it will be destroyed when the widget is destroyed, as if it was a child widget. An attached menu will also move between screens correctly if the widgets moves between screens.
#attach_widget ⇒ Gtk::Widget
The widget the menu is attached to. Setting this property attaches the menu without a Gtk::MenuDetachFunc. If you need to use a detacher, use gtk_menu_attach_to_widget() directly.
#attach_widget=(attach_widget) ⇒ Gtk::Widget
The widget the menu is attached to. Setting this property attaches the menu without a Gtk::MenuDetachFunc. If you need to use a detacher, use gtk_menu_attach_to_widget() directly.
#detach ⇒ nil
Detaches the menu from the widget to which it had been attached. This function will call the callback function, detacher, provided when the gtk_menu_attach_to_widget() function was called.
#menu_type_hint ⇒ Gdk::WindowTypeHint
The Gdk::WindowTypeHint to use for the menu’s #GdkWindow.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:anchor-hints, Gtk::Menu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and #GtkMenu::popped-up.
#menu_type_hint=(menu_type_hint) ⇒ Gdk::WindowTypeHint
The Gdk::WindowTypeHint to use for the menu’s #GdkWindow.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:anchor-hints, Gtk::Menu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and #GtkMenu::popped-up.
#monitor ⇒ Integer
The monitor the menu will be popped up on.
#monitor=(monitor) ⇒ Integer
The monitor the menu will be popped up on.
#new ⇒ Gtk::Widget
Creates a new Gtk::Menu
#new_from_model(model) ⇒ Gtk::Widget
Creates a Gtk::Menu and populates it with menu items and submenus according to model.
The created menu items are connected to actions found in the Gtk::ApplicationWindow to which the menu belongs - typically by means of being attached to a widget (see gtk_menu_attach_to_widget()) that is contained within the Gtk::ApplicationWindows widget hierarchy.
Actions can also be added using gtk_widget_insert_action_group() on the menu’s attach widget or on any of its parent widgets.
#place_on_monitor(monitor) ⇒ nil
Places menu on the given monitor.
#popdown ⇒ nil
Removes the menu from the screen.
#popup(parent_menu_shell, parent_menu_item, func, data, button, activate_time) ⇒ nil
Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus, and will typically supply nil for the parent_menu_shell, parent_menu_item, func and data parameters. The default menu positioning function will position the menu at the current mouse cursor position.
The button parameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress, button should be 0.
The activate_time parameter is used to conflict-resolve initiation of concurrent requests for mouse/keyboard grab requests. To function properly, this needs to be the timestamp of the user event (such as a mouse click or key press) that caused the initiation of the popup. Only if no such event is available, gtk_get_current_event_time() can be used instead.
Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
#popup_at_pointer(trigger_event) ⇒ nil
Displays menu and makes it available for selection.
See gtk_menu_popup_at_widget () to pop up a menu at a widget. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.
menu will be positioned at the pointer associated with trigger_event.
Properties that influence the behaviour of this function are Gtk::Menu:anchor-hints, #GtkMenu:rect-anchor-dx, #GtkMenu:rect-anchor-dy, and Gtk::Menu:menu-type-hint. Connect to the #GtkMenu::popped-up signal to find out how it was actually positioned.
#popup_at_rect(rect_window, rect, rect_anchor, menu_anchor, trigger_event) ⇒ nil
Displays menu and makes it available for selection.
See gtk_menu_popup_at_widget () and gtk_menu_popup_at_pointer (), which handle more common cases for popping up menus.
menu will be positioned at rect, aligning their anchor points. rect is relative to the top-left corner of rect_window. rect_anchor and menu_anchor determine anchor points on rect and menu to pin together. menu can optionally be offset by Gtk::Menu:rect-anchor-dx and Gtk::Menu:rect-anchor-dy.
Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are Gtk::Menu:anchor-hints and #GtkMenu:menu-type-hint. Connect to the Gtk::Menu::popped-up signal to find out how it was actually positioned.
#popup_at_widget(widget, widget_anchor, menu_anchor, trigger_event) ⇒ nil
Displays menu and makes it available for selection.
See gtk_menu_popup_at_pointer () to pop up a menu at the master pointer. gtk_menu_popup_at_rect () also allows you to position a menu at an arbitrary rectangle.

menu will be positioned at widget, aligning their anchor points. widget_anchor and menu_anchor determine anchor points on widget and menu to pin together. menu can optionally be offset by Gtk::Menu:rect-anchor-dx and Gtk::Menu:rect-anchor-dy.
Anchors should be specified under the assumption that the text direction is left-to-right; they will be flipped horizontally automatically if the text direction is right-to-left.
Other properties that influence the behaviour of this function are Gtk::Menu:anchor-hints and #GtkMenu:menu-type-hint. Connect to the Gtk::Menu::popped-up signal to find out how it was actually positioned.
#popup_for_device(device, parent_menu_shell, parent_menu_item, func, data, destroy, button, activate_time) ⇒ nil
Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus, and will typically supply nil for the parent_menu_shell, parent_menu_item, func, data and destroy parameters. The default menu positioning function will position the menu at the current position of device (or its corresponding pointer).
The button parameter should be the mouse button pressed to initiate the menu popup. If the menu popup was initiated by something other than a mouse button press, such as a mouse button release or a keypress, button should be 0.
The activate_time parameter is used to conflict-resolve initiation of concurrent requests for mouse/keyboard grab requests. To function properly, this needs to be the time stamp of the user event (such as a mouse click or key press) that caused the initiation of the popup. Only if no such event is available, gtk_get_current_event_time() can be used instead.
Note that this function does not work very well on GDK backends that do not have global coordinates, such as Wayland or Mir. You should probably use one of the gtk_menu_popup_at_ variants, which do not have this problem.
#rect_anchor_dx ⇒ Integer
Horizontal offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:anchor-hints, Gtk::Menu:rect-anchor-dy, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
#rect_anchor_dx=(rect_anchor_dx) ⇒ Integer
Horizontal offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:anchor-hints, Gtk::Menu:rect-anchor-dy, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
#rect_anchor_dy ⇒ Integer
Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:anchor-hints, Gtk::Menu:rect-anchor-dx, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
#rect_anchor_dy=(rect_anchor_dy) ⇒ Integer
Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), gtk_menu_popup_at_pointer (), Gtk::Menu:anchor-hints, Gtk::Menu:rect-anchor-dx, #GtkMenu:menu-type-hint, and #GtkMenu::popped-up.
#reorder_child(child, position) ⇒ nil
Moves child to a new position in the list of menu children.
#reposition ⇒ nil
Repositions the menu according to its position function.
#reserve_toggle_size ⇒ TrueClass
Returns whether the menu reserves space for toggles and icons, regardless of their actual presence.
#reserve_toggle_size=(reserve_toggle_size) ⇒ TrueClass
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.
#reserve_toggle_size? ⇒ TrueClass
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.
#screen=(screen) ⇒ nil
Sets the Gdk::Screen on which the menu will be displayed.
#tearoff_state ⇒ TrueClass
Returns whether the menu is torn off. See gtk_menu_set_tearoff_state().
#tearoff_state=(tearoff_state) ⇒ TrueClass
A boolean that indicates whether the menu is torn-off.
#tearoff_state? ⇒ TrueClass
A boolean that indicates whether the menu is torn-off.
#tearoff_title ⇒ String
A title that may be displayed by the window manager when this menu is torn-off.
#tearoff_title=(tearoff_title) ⇒ String
A title that may be displayed by the window manager when this menu is torn-off.
#title ⇒ String
Returns the title of the menu. See gtk_menu_set_title().
#title=(title) ⇒ nil
Sets the title string for the menu.
The title is displayed when the menu is shown as a tearoff menu. If title is nil, the menu will see if it is attached to a parent menu item, and if so it will try to use the same text as that menu item’s label.