Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | None |
Language | Haskell2010 |
- Exported types
- Methods
- Overloaded methods
- attach
- attachToWidget
- detach
- getAccelGroup
- getAccelPath
- getActive
- getAttachWidget
- getForAttachWidget
- getMonitor
- getReserveToggleSize
- getTearoffState
- getTitle
- new
- newFromModel
- placeOnMonitor
- popdown
- popup
- popupAtPointer
- popupAtRect
- popupAtWidget
- popupForDevice
- reorderChild
- reposition
- setAccelGroup
- setAccelPath
- setActive
- setMonitor
- setReserveToggleSize
- setScreen
- setTearoffState
- setTitle
- Properties
- Signals
A Menu
is a MenuShell
that implements a drop down menu
consisting of a list of MenuItem
objects which can be navigated
and activated by the user to perform application functions.
A Menu
is most commonly dropped down by activating a
MenuItem
in a MenuBar
or popped up by activating a
MenuItem
in another Menu
.
A Menu
can also be popped up by activating a ComboBox
.
Other composite widgets such as the Notebook
can pop up a
Menu
as well.
Applications can display a Menu
as a popup menu by calling the
menuPopup
function. The example below shows how an application
can pop up a menu when the 3rd mouse button is pressed.
Connecting the popup signal handler.
C code
// connect our handler which will popup the menu g_signal_connect_swapped (window, "button_press_event", G_CALLBACK (my_popup_handler), menu);
Signal handler which displays a popup menu.
C code
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
plain code
menu ├── arrow.top ├── <child> ┊ ├── <child> ╰── arrow.bottom
The main CSS node of GtkMenu has name menu, and there are two subnodes with name arrow, for scrolling menu arrows. These subnodes get the .top and .bottom style classes.
Synopsis
- newtype Menu = Menu (ManagedPtr Menu)
- class (GObject o, IsDescendantOf Menu o) => IsMenu o
- toMenu :: (MonadIO m, IsMenu o) => o -> m Menu
- menuAttach :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Word32 -> Word32 -> Word32 -> Word32 -> m ()
- menuAttachToWidget :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Maybe MenuDetachFunc -> m ()
- menuDetach :: (HasCallStack, MonadIO m, IsMenu a) => a -> m ()
- menuGetAccelGroup :: (HasCallStack, MonadIO m, IsMenu a) => a -> m AccelGroup
- menuGetAccelPath :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Text
- menuGetActive :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Widget
- menuGetAttachWidget :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Widget
- menuGetForAttachWidget :: (HasCallStack, MonadIO m, IsWidget a) => a -> m [Widget]
- menuGetMonitor :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Int32
- menuGetReserveToggleSize :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Bool
- menuGetTearoffState :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Bool
- menuGetTitle :: (HasCallStack, MonadIO m, IsMenu a) => a -> m Text
- menuNew :: (HasCallStack, MonadIO m) => m Menu
- menuNewFromModel :: (HasCallStack, MonadIO m, IsMenuModel a) => a -> m Menu
- menuPlaceOnMonitor :: (HasCallStack, MonadIO m, IsMenu a, IsMonitor b) => a -> b -> m ()
- menuPopdown :: (HasCallStack, MonadIO m, IsMenu a) => a -> m ()
- menuPopup :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b, IsWidget c) => a -> Maybe b -> Maybe c -> Maybe MenuPositionFunc -> Word32 -> Word32 -> m ()
- menuPopupAtPointer :: (HasCallStack, MonadIO m, IsMenu a) => a -> Maybe Event -> m ()
- menuPopupAtRect :: (HasCallStack, MonadIO m, IsMenu a, IsWindow b) => a -> b -> Rectangle -> Gravity -> Gravity -> Maybe Event -> m ()
- menuPopupAtWidget :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Gravity -> Gravity -> Maybe Event -> m ()
- menuPopupForDevice :: (HasCallStack, MonadIO m, IsMenu a, IsDevice b, IsWidget c, IsWidget d) => a -> Maybe b -> Maybe c -> Maybe d -> Maybe MenuPositionFunc -> Word32 -> Word32 -> m ()
- menuReorderChild :: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) => a -> b -> Int32 -> m ()
- menuReposition :: (HasCallStack, MonadIO m, IsMenu a) => a -> m ()
- menuSetAccelGroup :: (HasCallStack, MonadIO m, IsMenu a, IsAccelGroup b) => a -> Maybe b -> m ()
- menuSetAccelPath :: (HasCallStack, MonadIO m, IsMenu a) => a -> Maybe Text -> m ()
- menuSetActive :: (HasCallStack, MonadIO m, IsMenu a) => a -> Word32 -> m ()
- menuSetMonitor :: (HasCallStack, MonadIO m, IsMenu a) => a -> Int32 -> m ()
- menuSetReserveToggleSize :: (HasCallStack, MonadIO m, IsMenu a) => a -> Bool -> m ()
- menuSetScreen :: (HasCallStack, MonadIO m, IsMenu a, IsScreen b) => a -> Maybe b -> m ()
- menuSetTearoffState :: (HasCallStack, MonadIO m, IsMenu a) => a -> Bool -> m ()
- menuSetTitle :: (HasCallStack, MonadIO m, IsMenu a) => a -> Maybe Text -> m ()
- clearMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuAccelGroup :: (IsMenu o, MonadIO m, IsAccelGroup a) => a -> m (GValueConstruct o)
- getMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m AccelGroup
- setMenuAccelGroup :: (MonadIO m, IsMenu o, IsAccelGroup a) => o -> a -> m ()
- clearMenuAccelPath :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuAccelPath :: (IsMenu o, MonadIO m) => Text -> m (GValueConstruct o)
- getMenuAccelPath :: (MonadIO m, IsMenu o) => o -> m Text
- setMenuAccelPath :: (MonadIO m, IsMenu o) => o -> Text -> m ()
- constructMenuActive :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getMenuActive :: (MonadIO m, IsMenu o) => o -> m Int32
- setMenuActive :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- constructMenuAnchorHints :: (IsMenu o, MonadIO m) => [AnchorHints] -> m (GValueConstruct o)
- getMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> m [AnchorHints]
- setMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> [AnchorHints] -> m ()
- clearMenuAttachWidget :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuAttachWidget :: (IsMenu o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- getMenuAttachWidget :: (MonadIO m, IsMenu o) => o -> m Widget
- setMenuAttachWidget :: (MonadIO m, IsMenu o, IsWidget a) => o -> a -> m ()
- constructMenuMenuTypeHint :: (IsMenu o, MonadIO m) => WindowTypeHint -> m (GValueConstruct o)
- getMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> m WindowTypeHint
- setMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> WindowTypeHint -> m ()
- constructMenuMonitor :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getMenuMonitor :: (MonadIO m, IsMenu o) => o -> m Int32
- setMenuMonitor :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- constructMenuRectAnchorDx :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getMenuRectAnchorDx :: (MonadIO m, IsMenu o) => o -> m Int32
- setMenuRectAnchorDx :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- constructMenuRectAnchorDy :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o)
- getMenuRectAnchorDy :: (MonadIO m, IsMenu o) => o -> m Int32
- setMenuRectAnchorDy :: (MonadIO m, IsMenu o) => o -> Int32 -> m ()
- constructMenuReserveToggleSize :: (IsMenu o, MonadIO m) => Bool -> m (GValueConstruct o)
- getMenuReserveToggleSize :: (MonadIO m, IsMenu o) => o -> m Bool
- setMenuReserveToggleSize :: (MonadIO m, IsMenu o) => o -> Bool -> m ()
- constructMenuTearoffState :: (IsMenu o, MonadIO m) => Bool -> m (GValueConstruct o)
- getMenuTearoffState :: (MonadIO m, IsMenu o) => o -> m Bool
- setMenuTearoffState :: (MonadIO m, IsMenu o) => o -> Bool -> m ()
- clearMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> m ()
- constructMenuTearoffTitle :: (IsMenu o, MonadIO m) => Text -> m (GValueConstruct o)
- getMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> m (Maybe Text)
- setMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> Text -> m ()
- type C_MenuMoveScrollCallback = Ptr () -> CUInt -> Ptr () -> IO ()
- type MenuMoveScrollCallback = ScrollType -> IO ()
- afterMenuMoveScroll :: (IsMenu a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId
- genClosure_MenuMoveScroll :: MonadIO m => MenuMoveScrollCallback -> m (GClosure C_MenuMoveScrollCallback)
- mk_MenuMoveScrollCallback :: C_MenuMoveScrollCallback -> IO (FunPtr C_MenuMoveScrollCallback)
- noMenuMoveScrollCallback :: Maybe MenuMoveScrollCallback
- onMenuMoveScroll :: (IsMenu a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId
- wrap_MenuMoveScrollCallback :: MenuMoveScrollCallback -> C_MenuMoveScrollCallback
- type C_MenuPoppedUpCallback = Ptr () -> Ptr () -> Ptr () -> CInt -> CInt -> Ptr () -> IO ()
- type MenuPoppedUpCallback = Ptr () -> Ptr () -> Bool -> Bool -> IO ()
- afterMenuPoppedUp :: (IsMenu a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId
- genClosure_MenuPoppedUp :: MonadIO m => MenuPoppedUpCallback -> m (GClosure C_MenuPoppedUpCallback)
- mk_MenuPoppedUpCallback :: C_MenuPoppedUpCallback -> IO (FunPtr C_MenuPoppedUpCallback)
- noMenuPoppedUpCallback :: Maybe MenuPoppedUpCallback
- onMenuPoppedUp :: (IsMenu a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId
- wrap_MenuPoppedUpCallback :: MenuPoppedUpCallback -> C_MenuPoppedUpCallback
Exported types
Memory-managed wrapper type.
Instances
Eq Menu Source # | |
IsGValue Menu Source # | Convert |
ManagedPtrNewtype Menu Source # | |
Defined in GI.Gtk.Objects.Menu toManagedPtr :: Menu -> ManagedPtr Menu # | |
TypedObject Menu Source # | |
Defined in GI.Gtk.Objects.Menu | |
GObject Menu Source # | |
Defined in GI.Gtk.Objects.Menu | |
HasParentTypes Menu Source # | |
Defined in GI.Gtk.Objects.Menu | |
type ParentTypes Menu Source # | |
Defined in GI.Gtk.Objects.Menu |
class (GObject o, IsDescendantOf Menu o) => IsMenu o Source #
Instances
(GObject o, IsDescendantOf Menu o) => IsMenu o Source # | |
Defined in GI.Gtk.Objects.Menu |
Methods
Overloaded methods
attach
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Word32 |
|
-> Word32 |
|
-> Word32 |
|
-> Word32 |
|
-> m () |
Adds a new MenuItem
to a (table) menu. The number of “cells” that
an item will occupy is specified by leftAttach
, rightAttach
,
topAttach
and bottomAttach
. 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 menuDetach
.
Since: 2.4
attachToWidget
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Maybe MenuDetachFunc |
|
-> m () |
Attaches the menu to the widget and provides a callback function
that will be invoked when the menu calls menuDetach
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.
detach
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m () |
Detaches the menu from the widget to which it had been attached.
This function will call the callback function, detacher
, provided
when the menuAttachToWidget
function was called.
getAccelGroup
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m AccelGroup | Returns: the |
Gets the AccelGroup
which holds global accelerators for the
menu. See menuSetAccelGroup
.
getAccelPath
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Text | Returns: the accelerator path set on the menu. |
Retrieves the accelerator path set on the menu.
Since: 2.14
getActive
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Widget | Returns: the |
Returns the selected menu item from the menu. This is used by the
ComboBox
.
getAttachWidget
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Widget | Returns: the |
Returns the Widget
that the menu is attached to.
getForAttachWidget
menuGetForAttachWidget Source #
:: (HasCallStack, MonadIO m, IsWidget a) | |
=> a |
|
-> m [Widget] | Returns: the list of menus attached to his widget. |
Returns a list of the menus which are attached to this widget. This list is owned by GTK+ and must not be modified.
Since: 2.6
getMonitor
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Int32 | Returns: the number of the monitor on which the menu should be popped up or -1, if no monitor has been set |
Retrieves the number of the monitor on which to show the menu.
Since: 2.14
getReserveToggleSize
menuGetReserveToggleSize Source #
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Bool | Returns: Whether the menu reserves toggle space |
Returns whether the menu reserves space for toggles and icons, regardless of their actual presence.
Since: 2.18
getTearoffState
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Bool | Returns: |
Deprecated: (Since version 3.10)
Returns whether the menu is torn off.
See menuSetTearoffState
.
getTitle
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m Text | Returns: the title of the menu, or |
Deprecated: (Since version 3.10)
Returns the title of the menu. See menuSetTitle
.
new
newFromModel
:: (HasCallStack, MonadIO m, IsMenuModel a) | |
=> a |
|
-> m Menu | Returns: a new |
Creates a Menu
and populates it with menu items and
submenus according to model
.
The created menu items are connected to actions found in the
ApplicationWindow
to which the menu belongs - typically
by means of being attached to a widget (see menuAttachToWidget
)
that is contained within the GtkApplicationWindows
widget hierarchy.
Actions can also be added using widgetInsertActionGroup
on the menu's
attach widget or on any of its parent widgets.
Since: 3.4
placeOnMonitor
:: (HasCallStack, MonadIO m, IsMenu a, IsMonitor b) | |
=> a |
|
-> b |
|
-> m () |
Places menu
on the given monitor.
Since: 3.22
popdown
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m () |
Removes the menu from the screen.
popup
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b, IsWidget c) | |
=> a |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe MenuPositionFunc |
|
-> Word32 |
|
-> Word32 |
|
-> m () |
Deprecated: (Since version 3.22)Please use menuPopupAtWidget
, menuPopupAtPointer
. or menuPopupAtRect
instead
Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive
menus, and will typically supply Nothing
for the parentMenuShell
,
parentMenuItem
, 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 activateTime
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, getCurrentEventTime
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.
popupAtPointer
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Maybe Event |
|
-> m () |
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 triggerEvent
.
Properties that influence the behaviour of this function are
Menu
:anchor-hints
, Menu
:rect-anchor-dx
, Menu
:rect-anchor-dy
, and
Menu
:menu-type-hint
. Connect to the poppedUp signal to find
out how it was actually positioned.
Since: 3.22
popupAtRect
:: (HasCallStack, MonadIO m, IsMenu a, IsWindow b) | |
=> a |
|
-> b |
|
-> Rectangle |
|
-> Gravity |
|
-> Gravity |
|
-> Maybe Event |
|
-> m () |
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 rectWindow
. rectAnchor
and
menuAnchor
determine anchor points on rect
and menu
to pin together.
menu
can optionally be offset by Menu
:rect-anchor-dx
and
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
Menu
:anchor-hints
and Menu
:menu-type-hint
. Connect to the
poppedUp signal to find out how it was actually positioned.
Since: 3.22
popupAtWidget
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Gravity |
|
-> Gravity |
|
-> Maybe Event |
|
-> m () |
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.
widgetAnchor
and menuAnchor
determine anchor points on widget
and menu
to pin together. menu
can optionally be offset by Menu
:rect-anchor-dx
and 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
Menu
:anchor-hints
and Menu
:menu-type-hint
. Connect to the
poppedUp signal to find out how it was actually positioned.
Since: 3.22
popupForDevice
:: (HasCallStack, MonadIO m, IsMenu a, IsDevice b, IsWidget c, IsWidget d) | |
=> a |
|
-> Maybe b |
|
-> Maybe c |
|
-> Maybe d |
|
-> Maybe MenuPositionFunc |
|
-> Word32 |
|
-> Word32 |
|
-> m () |
Deprecated: (Since version 3.22)Please use menuPopupAtWidget
, menuPopupAtPointer
. or menuPopupAtRect
instead
Displays a menu and makes it available for selection.
Applications can use this function to display context-sensitive menus,
and will typically supply Nothing
for the parentMenuShell
,
parentMenuItem
, 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 activateTime
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, getCurrentEventTime
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.
Since: 3.0
reorderChild
:: (HasCallStack, MonadIO m, IsMenu a, IsWidget b) | |
=> a |
|
-> b |
|
-> Int32 |
|
-> m () |
Moves child
to a new position
in the list of menu
children.
reposition
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> m () |
Repositions the menu according to its position function.
setAccelGroup
:: (HasCallStack, MonadIO m, IsMenu a, IsAccelGroup b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Set the AccelGroup
which holds global accelerators for the
menu. This accelerator group needs to also be added to all windows
that this menu is being used in with windowAddAccelGroup
,
in order for those windows to support all the accelerators
contained in this group.
setAccelPath
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Sets an accelerator path for this menu from which accelerator paths
for its immediate children, its menu items, can be constructed.
The main purpose of this function is to spare the programmer the
inconvenience of having to call menuItemSetAccelPath
on
each menu item that should support runtime user changable accelerators.
Instead, by just calling menuSetAccelPath
on their parent,
each menu item of this menu, that contains a label describing its
purpose, automatically gets an accel path assigned.
For example, a menu containing menu items “New” and “Exit”, will, after
gtk_menu_set_accel_path (menu, "<Gnumeric-Sheet>/File");
has been
called, assign its items the accel paths: "<Gnumeric-Sheet>/File/New"
and "<Gnumeric-Sheet>/File/Exit"
.
Assigning accel paths to menu items then enables the user to change
their accelerators at runtime. More details about accelerator paths
and their default setups can be found at accelMapAddEntry
.
Note that accelPath
string will be stored in a GQuark
. Therefore,
if you pass a static string, you can save some memory by interning
it first with internStaticString
.
setActive
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Word32 |
|
-> m () |
Selects the specified menu item within the menu. This is used by
the ComboBox
and should not be used by anyone else.
setMonitor
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Int32 |
|
-> m () |
Informs GTK+ on which monitor a menu should be popped up.
See monitorGetGeometry
.
This function should be called from a MenuPositionFunc
if the menu should not appear on the same monitor as the pointer.
This information can’t be reliably inferred from the coordinates
returned by a MenuPositionFunc
, since, for very long menus,
these coordinates may extend beyond the monitor boundaries or even
the screen boundaries.
Since: 2.4
setReserveToggleSize
menuSetReserveToggleSize Source #
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether the menu should reserve space for drawing toggles or icons, regardless of their actual presence.
Since: 2.18
setScreen
:: (HasCallStack, MonadIO m, IsMenu a, IsScreen b) | |
=> a |
|
-> Maybe b |
|
-> m () |
Sets the Screen
on which the menu will be displayed.
Since: 2.2
setTearoffState
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Bool |
|
-> m () |
Deprecated: (Since version 3.10)
Changes the tearoff state of the menu. A menu is normally displayed as drop down menu which persists as long as the menu is active. It can also be displayed as a tearoff menu which persists until it is closed or reattached.
setTitle
:: (HasCallStack, MonadIO m, IsMenu a) | |
=> a |
|
-> Maybe Text |
|
-> m () |
Deprecated: (Since version 3.10)
Sets the title string for the menu.
The title is displayed when the menu is shown as a tearoff
menu. If title
is Nothing
, 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.
Properties
accelGroup
The accel group holding accelerators for the menu.
Since: 2.14
clearMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m () Source #
Set the value of the “accel-group
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#accelGroup
constructMenuAccelGroup :: (IsMenu o, MonadIO m, IsAccelGroup a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “accel-group
” property. This is rarely needed directly, but it is used by new
.
getMenuAccelGroup :: (MonadIO m, IsMenu o) => o -> m AccelGroup Source #
Get the value of the “accel-group
” property.
When overloading is enabled, this is equivalent to
get
menu #accelGroup
setMenuAccelGroup :: (MonadIO m, IsMenu o, IsAccelGroup a) => o -> a -> m () Source #
Set the value of the “accel-group
” property.
When overloading is enabled, this is equivalent to
set
menu [ #accelGroup:=
value ]
accelPath
An accel path used to conveniently construct accel paths of child items.
Since: 2.14
clearMenuAccelPath :: (MonadIO m, IsMenu o) => o -> m () Source #
Set the value of the “accel-path
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#accelPath
constructMenuAccelPath :: (IsMenu o, MonadIO m) => Text -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “accel-path
” property. This is rarely needed directly, but it is used by new
.
getMenuAccelPath :: (MonadIO m, IsMenu o) => o -> m Text Source #
Get the value of the “accel-path
” property.
When overloading is enabled, this is equivalent to
get
menu #accelPath
setMenuAccelPath :: (MonadIO m, IsMenu o) => o -> Text -> m () Source #
Set the value of the “accel-path
” property.
When overloading is enabled, this is equivalent to
set
menu [ #accelPath:=
value ]
active
The index of the currently selected menu item, or -1 if no menu item is selected.
Since: 2.14
constructMenuActive :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “active
” property. This is rarely needed directly, but it is used by new
.
getMenuActive :: (MonadIO m, IsMenu o) => o -> m Int32 Source #
Get the value of the “active
” property.
When overloading is enabled, this is equivalent to
get
menu #active
setMenuActive :: (MonadIO m, IsMenu o) => o -> Int32 -> m () Source #
Set the value of the “active
” property.
When overloading is enabled, this is equivalent to
set
menu [ #active:=
value ]
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, AnchorHintsFlipY
will replace GravityNorthWest
with
GravitySouthWest
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 (), Menu
:rect-anchor-dx
,
Menu
:rect-anchor-dy
, Menu
:menu-type-hint
, and poppedUp.
Since: 3.22
constructMenuAnchorHints :: (IsMenu o, MonadIO m) => [AnchorHints] -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “anchor-hints
” property. This is rarely needed directly, but it is used by new
.
getMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> m [AnchorHints] Source #
Get the value of the “anchor-hints
” property.
When overloading is enabled, this is equivalent to
get
menu #anchorHints
setMenuAnchorHints :: (MonadIO m, IsMenu o) => o -> [AnchorHints] -> m () Source #
Set the value of the “anchor-hints
” property.
When overloading is enabled, this is equivalent to
set
menu [ #anchorHints:=
value ]
attachWidget
The widget the menu is attached to. Setting this property attaches
the menu without a MenuDetachFunc
. If you need to use a detacher,
use menuAttachToWidget
directly.
Since: 2.14
clearMenuAttachWidget :: (MonadIO m, IsMenu o) => o -> m () Source #
Set the value of the “attach-widget
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#attachWidget
constructMenuAttachWidget :: (IsMenu o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “attach-widget
” property. This is rarely needed directly, but it is used by new
.
getMenuAttachWidget :: (MonadIO m, IsMenu o) => o -> m Widget Source #
Get the value of the “attach-widget
” property.
When overloading is enabled, this is equivalent to
get
menu #attachWidget
setMenuAttachWidget :: (MonadIO m, IsMenu o, IsWidget a) => o -> a -> m () Source #
Set the value of the “attach-widget
” property.
When overloading is enabled, this is equivalent to
set
menu [ #attachWidget:=
value ]
menuTypeHint
The WindowTypeHint
to use for the menu's Window
.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), Menu
:anchor-hints
,
Menu
:rect-anchor-dx
, Menu
:rect-anchor-dy
, and poppedUp.
Since: 3.22
constructMenuMenuTypeHint :: (IsMenu o, MonadIO m) => WindowTypeHint -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “menu-type-hint
” property. This is rarely needed directly, but it is used by new
.
getMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> m WindowTypeHint Source #
Get the value of the “menu-type-hint
” property.
When overloading is enabled, this is equivalent to
get
menu #menuTypeHint
setMenuMenuTypeHint :: (MonadIO m, IsMenu o) => o -> WindowTypeHint -> m () Source #
Set the value of the “menu-type-hint
” property.
When overloading is enabled, this is equivalent to
set
menu [ #menuTypeHint:=
value ]
monitor
The monitor the menu will be popped up on.
Since: 2.14
constructMenuMonitor :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “monitor
” property. This is rarely needed directly, but it is used by new
.
getMenuMonitor :: (MonadIO m, IsMenu o) => o -> m Int32 Source #
Get the value of the “monitor
” property.
When overloading is enabled, this is equivalent to
get
menu #monitor
setMenuMonitor :: (MonadIO m, IsMenu o) => o -> Int32 -> m () Source #
Set the value of the “monitor
” property.
When overloading is enabled, this is equivalent to
set
menu [ #monitor:=
value ]
rectAnchorDx
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 (), Menu
:anchor-hints
,
Menu
:rect-anchor-dy
, Menu
:menu-type-hint
, and poppedUp.
Since: 3.22
constructMenuRectAnchorDx :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “rect-anchor-dx
” property. This is rarely needed directly, but it is used by new
.
getMenuRectAnchorDx :: (MonadIO m, IsMenu o) => o -> m Int32 Source #
Get the value of the “rect-anchor-dx
” property.
When overloading is enabled, this is equivalent to
get
menu #rectAnchorDx
setMenuRectAnchorDx :: (MonadIO m, IsMenu o) => o -> Int32 -> m () Source #
Set the value of the “rect-anchor-dx
” property.
When overloading is enabled, this is equivalent to
set
menu [ #rectAnchorDx:=
value ]
rectAnchorDy
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 (), Menu
:anchor-hints
,
Menu
:rect-anchor-dx
, Menu
:menu-type-hint
, and poppedUp.
Since: 3.22
constructMenuRectAnchorDy :: (IsMenu o, MonadIO m) => Int32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “rect-anchor-dy
” property. This is rarely needed directly, but it is used by new
.
getMenuRectAnchorDy :: (MonadIO m, IsMenu o) => o -> m Int32 Source #
Get the value of the “rect-anchor-dy
” property.
When overloading is enabled, this is equivalent to
get
menu #rectAnchorDy
setMenuRectAnchorDy :: (MonadIO m, IsMenu o) => o -> Int32 -> m () Source #
Set the value of the “rect-anchor-dy
” property.
When overloading is enabled, this is equivalent to
set
menu [ #rectAnchorDy:=
value ]
reserveToggleSize
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.
Since: 2.18
constructMenuReserveToggleSize :: (IsMenu o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “reserve-toggle-size
” property. This is rarely needed directly, but it is used by new
.
getMenuReserveToggleSize :: (MonadIO m, IsMenu o) => o -> m Bool Source #
Get the value of the “reserve-toggle-size
” property.
When overloading is enabled, this is equivalent to
get
menu #reserveToggleSize
setMenuReserveToggleSize :: (MonadIO m, IsMenu o) => o -> Bool -> m () Source #
Set the value of the “reserve-toggle-size
” property.
When overloading is enabled, this is equivalent to
set
menu [ #reserveToggleSize:=
value ]
tearoffState
A boolean that indicates whether the menu is torn-off.
Since: 2.6
constructMenuTearoffState :: (IsMenu o, MonadIO m) => Bool -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “tearoff-state
” property. This is rarely needed directly, but it is used by new
.
getMenuTearoffState :: (MonadIO m, IsMenu o) => o -> m Bool Source #
Get the value of the “tearoff-state
” property.
When overloading is enabled, this is equivalent to
get
menu #tearoffState
setMenuTearoffState :: (MonadIO m, IsMenu o) => o -> Bool -> m () Source #
Set the value of the “tearoff-state
” property.
When overloading is enabled, this is equivalent to
set
menu [ #tearoffState:=
value ]
tearoffTitle
A title that may be displayed by the window manager when this menu is torn-off.
clearMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> m () Source #
Set the value of the “tearoff-title
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#tearoffTitle
constructMenuTearoffTitle :: (IsMenu o, MonadIO m) => Text -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “tearoff-title
” property. This is rarely needed directly, but it is used by new
.
getMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> m (Maybe Text) Source #
Get the value of the “tearoff-title
” property.
When overloading is enabled, this is equivalent to
get
menu #tearoffTitle
setMenuTearoffTitle :: (MonadIO m, IsMenu o) => o -> Text -> m () Source #
Set the value of the “tearoff-title
” property.
When overloading is enabled, this is equivalent to
set
menu [ #tearoffTitle:=
value ]
Signals
moveScroll
type C_MenuMoveScrollCallback = Ptr () -> CUInt -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type MenuMoveScrollCallback Source #
= ScrollType |
|
-> IO () |
No description available in the introspection data.
afterMenuMoveScroll :: (IsMenu a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId Source #
Connect a signal handler for the moveScroll signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
menu #moveScroll callback
genClosure_MenuMoveScroll :: MonadIO m => MenuMoveScrollCallback -> m (GClosure C_MenuMoveScrollCallback) Source #
Wrap the callback into a GClosure
.
mk_MenuMoveScrollCallback :: C_MenuMoveScrollCallback -> IO (FunPtr C_MenuMoveScrollCallback) Source #
Generate a function pointer callable from C code, from a C_MenuMoveScrollCallback
.
noMenuMoveScrollCallback :: Maybe MenuMoveScrollCallback Source #
A convenience synonym for
.Nothing
:: Maybe
MenuMoveScrollCallback
onMenuMoveScroll :: (IsMenu a, MonadIO m) => a -> MenuMoveScrollCallback -> m SignalHandlerId Source #
Connect a signal handler for the moveScroll signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
menu #moveScroll callback
wrap_MenuMoveScrollCallback :: MenuMoveScrollCallback -> C_MenuMoveScrollCallback Source #
Wrap a MenuMoveScrollCallback
into a C_MenuMoveScrollCallback
.
poppedUp
type C_MenuPoppedUpCallback = Ptr () -> Ptr () -> Ptr () -> CInt -> CInt -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type MenuPoppedUpCallback Source #
= Ptr () |
|
-> Ptr () |
|
-> Bool |
|
-> Bool |
|
-> IO () |
Emitted when the position of menu
is finalized after being popped up
using gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (), or
gtk_menu_popup_at_pointer ().
menu
might be flipped over the anchor rectangle in order to keep it
on-screen, in which case flippedX
and flippedY
will be set to True
accordingly.
flippedRect
is the ideal position of menu
after any possible flipping,
but before any possible sliding. finalRect
is flippedRect
, 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 flippedRect
,
and the red menu is finalRect
.
See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
gtk_menu_popup_at_pointer (), Menu
:anchor-hints
,
Menu
:rect-anchor-dx
, Menu
:rect-anchor-dy
, and
Menu
:menu-type-hint
.
Since: 3.22
afterMenuPoppedUp :: (IsMenu a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId Source #
Connect a signal handler for the poppedUp signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
menu #poppedUp callback
genClosure_MenuPoppedUp :: MonadIO m => MenuPoppedUpCallback -> m (GClosure C_MenuPoppedUpCallback) Source #
Wrap the callback into a GClosure
.
mk_MenuPoppedUpCallback :: C_MenuPoppedUpCallback -> IO (FunPtr C_MenuPoppedUpCallback) Source #
Generate a function pointer callable from C code, from a C_MenuPoppedUpCallback
.
noMenuPoppedUpCallback :: Maybe MenuPoppedUpCallback Source #
A convenience synonym for
.Nothing
:: Maybe
MenuPoppedUpCallback
onMenuPoppedUp :: (IsMenu a, MonadIO m) => a -> MenuPoppedUpCallback -> m SignalHandlerId Source #
Connect a signal handler for the poppedUp signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
menu #poppedUp callback