gi-gtk-3.0.31: Gtk bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (inaki@blueleaf.cc)
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.MenuShell

Contents

Description

A MenuShell is the abstract base class used to derive the Menu and MenuBar subclasses.

A MenuShell is a container of MenuItem objects arranged in a list which can be navigated, selected, and activated by the user to perform application functions. A MenuItem can have a submenu associated with it, allowing for nested hierarchical menus.

Terminology

A menu item can be “selected”, this means that it is displayed in the prelight state, and if it has a submenu, that submenu will be popped up.

A menu is “active” when it is visible onscreen and the user is selecting from it. A menubar is not active until the user clicks on one of its menuitems. When a menu is active, passing the mouse over a submenu will pop it up.

There is also is a concept of the current menu and a current menu item. The current menu item is the selected menu item that is furthest down in the hierarchy. (Every active menu shell does not necessarily contain a selected menu item, but if it does, then the parent menu shell must also contain a selected menu item.) The current menu is the menu that contains the current menu item. It will always have a GTK grab and receive all key presses.

Synopsis

Exported types

newtype MenuShell Source #

Memory-managed wrapper type.

Instances
GObject MenuShell Source # 
Instance details

Defined in GI.Gtk.Objects.MenuShell

Methods

gobjectType :: IO GType #

HasParentTypes MenuShell Source # 
Instance details

Defined in GI.Gtk.Objects.MenuShell

type ParentTypes MenuShell Source # 
Instance details

Defined in GI.Gtk.Objects.MenuShell

type ParentTypes MenuShell = Container ': (Widget ': (Object ': (ImplementorIface ': (Buildable ': ([] :: [Type])))))

class (GObject o, IsDescendantOf MenuShell o) => IsMenuShell o Source #

Type class for types which can be safely cast to MenuShell, for instance with toMenuShell.

Instances
(GObject o, IsDescendantOf MenuShell o) => IsMenuShell o Source # 
Instance details

Defined in GI.Gtk.Objects.MenuShell

toMenuShell :: (MonadIO m, IsMenuShell o) => o -> m MenuShell Source #

Cast to MenuShell, for types for which this is known to be safe. For general casts, use castTo.

noMenuShell :: Maybe MenuShell Source #

A convenience alias for Nothing :: Maybe MenuShell.

Methods

activateItem

menuShellActivateItem Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a, IsWidget b) 
=> a

menuShell: a MenuShell

-> b

menuItem: the MenuItem to activate

-> Bool

forceDeactivate: if True, force the deactivation of the menu shell after the menu item is activated

-> m () 

Activates the menu item within the menu shell.

append

menuShellAppend Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a, IsMenuItem b) 
=> a

menuShell: a MenuShell

-> b

child: The MenuItem to add

-> m () 

Adds a new MenuItem to the end of the menu shell's item list.

bindModel

menuShellBindModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a, IsMenuModel b) 
=> a

menuShell: a MenuShell

-> Maybe b

model: the MenuModel to bind to or Nothing to remove binding

-> Maybe Text

actionNamespace: the namespace for actions in model

-> Bool

withSeparators: True if toplevel items in shell should have separators between them

-> m () 

Establishes a binding between a MenuShell and a MenuModel.

The contents of shell are removed and then refilled with menu items according to model. When model changes, shell is updated. Calling this function twice on shell with different model will cause the first binding to be replaced with a binding to the new model. If model is Nothing then any previous binding is undone and all children are removed.

withSeparators determines if toplevel items (eg: sections) have separators inserted between them. This is typically desired for menus but doesn’t make sense for menubars.

If actionNamespace is non-Nothing then the effect is as if all actions mentioned in the model have their names prefixed with the namespace, plus a dot. For example, if the action “quit” is mentioned and actionNamespace is “app” then the effective action name is “app.quit”.

This function uses Actionable to define the action name and target values on the created menu items. If you want to use an action group other than “app” and “win”, or if you want to use a MenuShell outside of a ApplicationWindow, then you will need to attach your own action group to the widget hierarchy using widgetInsertActionGroup. As an example, if you created a group with a “quit” action and inserted it with the name “mygroup” then you would use the action name “mygroup.quit” in your MenuModel.

For most cases you are probably better off using menuNewFromModel or menuBarNewFromModel or just directly passing the MenuModel to applicationSetAppMenu or applicationSetMenubar.

Since: 3.6

cancel

menuShellCancel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> m () 

Cancels the selection within the menu shell.

Since: 2.4

deactivate

menuShellDeactivate Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> m () 

Deactivates the menu shell.

Typically this results in the menu shell being erased from the screen.

deselect

menuShellDeselect Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> m () 

Deselects the currently selected item from the menu shell, if any.

getParentShell

menuShellGetParentShell Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> m Widget

Returns: the parent MenuShell

Gets the parent menu shell.

The parent menu shell of a submenu is the Menu or MenuBar from which it was opened up.

Since: 3.0

getSelectedItem

menuShellGetSelectedItem Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> m Widget

Returns: the currently selected item

Gets the currently selected item.

Since: 3.0

getTakeFocus

menuShellGetTakeFocus Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> m Bool

Returns: True if the menu shell will take the keyboard focus on popup.

Returns True if the menu shell will take the keyboard focus on popup.

Since: 2.8

insert

menuShellInsert Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a, IsWidget b) 
=> a

menuShell: a MenuShell

-> b

child: The MenuItem to add

-> Int32

position: The position in the item list where child is added. Positions are numbered from 0 to n-1

-> m () 

Adds a new MenuItem to the menu shell’s item list at the position indicated by position.

prepend

menuShellPrepend Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a, IsWidget b) 
=> a

menuShell: a MenuShell

-> b

child: The MenuItem to add

-> m () 

Adds a new MenuItem to the beginning of the menu shell's item list.

selectFirst

menuShellSelectFirst Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> Bool

searchSensitive: if True, search for the first selectable menu item, otherwise select nothing if the first item isn’t sensitive. This should be False if the menu is being popped up initially.

-> m () 

Select the first visible or selectable child of the menu shell; don’t select tearoff items unless the only item is a tearoff item.

Since: 2.2

selectItem

menuShellSelectItem Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a, IsWidget b) 
=> a

menuShell: a MenuShell

-> b

menuItem: The MenuItem to select

-> m () 

Selects the menu item from the menu shell.

setTakeFocus

menuShellSetTakeFocus Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuShell a) 
=> a

menuShell: a MenuShell

-> Bool

takeFocus: True if the menu shell should take the keyboard focus on popup

-> m () 

If takeFocus is True (the default) the menu shell will take the keyboard focus so that it will receive all keyboard events which is needed to enable keyboard navigation in menus.

Setting takeFocus to False is useful only for special applications like virtual keyboard implementations which should not take keyboard focus.

The takeFocus state of a menu or menu bar is automatically propagated to submenus whenever a submenu is popped up, so you don’t have to worry about recursively setting it for your entire menu hierarchy. Only when programmatically picking a submenu and popping it up manually, the takeFocus property of the submenu needs to be set explicitly.

Note that setting it to False has side-effects:

If the focus is in some other app, it keeps the focus and keynav in the menu doesn’t work. Consequently, keynav on the menu will only work if the focus is on some toplevel owned by the onscreen keyboard.

To avoid confusing the user, menus with takeFocus set to False should not display mnemonics or accelerators, since it cannot be guaranteed that they will work.

See also keyboardGrab

Since: 2.8

Properties

takeFocus

A boolean that determines whether the menu and its submenus grab the keyboard focus. See menuShellSetTakeFocus and menuShellGetTakeFocus.

Since: 2.8

constructMenuShellTakeFocus :: IsMenuShell o => Bool -> IO (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “take-focus” property. This is rarely needed directly, but it is used by new.

getMenuShellTakeFocus :: (MonadIO m, IsMenuShell o) => o -> m Bool Source #

Get the value of the “take-focus” property. When overloading is enabled, this is equivalent to

get menuShell #takeFocus

setMenuShellTakeFocus :: (MonadIO m, IsMenuShell o) => o -> Bool -> m () Source #

Set the value of the “take-focus” property. When overloading is enabled, this is equivalent to

set menuShell [ #takeFocus := value ]

Signals

activateCurrent

type C_MenuShellActivateCurrentCallback = Ptr () -> CInt -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuShellActivateCurrentCallback Source #

Arguments

 = Bool

forceHide: if True, hide the menu after activating the menu item

-> IO () 

An action signal that activates the current menu item within the menu shell.

afterMenuShellActivateCurrent :: (IsMenuShell a, MonadIO m) => a -> MenuShellActivateCurrentCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate-current” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #activateCurrent callback

onMenuShellActivateCurrent :: (IsMenuShell a, MonadIO m) => a -> MenuShellActivateCurrentCallback -> m SignalHandlerId Source #

Connect a signal handler for the “activate-current” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #activateCurrent callback

cancel

type C_MenuShellCancelCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuShellCancelCallback = IO () Source #

An action signal which cancels the selection within the menu shell. Causes the MenuShell::selection-done signal to be emitted.

afterMenuShellCancel :: (IsMenuShell a, MonadIO m) => a -> MenuShellCancelCallback -> m SignalHandlerId Source #

Connect a signal handler for the “cancel” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #cancel callback

onMenuShellCancel :: (IsMenuShell a, MonadIO m) => a -> MenuShellCancelCallback -> m SignalHandlerId Source #

Connect a signal handler for the “cancel” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #cancel callback

cycleFocus

type C_MenuShellCycleFocusCallback = Ptr () -> CUInt -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuShellCycleFocusCallback Source #

Arguments

 = DirectionType

direction: the direction to cycle in

-> IO () 

A keybinding signal which moves the focus in the given direction.

afterMenuShellCycleFocus :: (IsMenuShell a, MonadIO m) => a -> MenuShellCycleFocusCallback -> m SignalHandlerId Source #

Connect a signal handler for the “cycle-focus” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #cycleFocus callback

onMenuShellCycleFocus :: (IsMenuShell a, MonadIO m) => a -> MenuShellCycleFocusCallback -> m SignalHandlerId Source #

Connect a signal handler for the “cycle-focus” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #cycleFocus callback

deactivate

type C_MenuShellDeactivateCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuShellDeactivateCallback = IO () Source #

This signal is emitted when a menu shell is deactivated.

afterMenuShellDeactivate :: (IsMenuShell a, MonadIO m) => a -> MenuShellDeactivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “deactivate” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #deactivate callback

onMenuShellDeactivate :: (IsMenuShell a, MonadIO m) => a -> MenuShellDeactivateCallback -> m SignalHandlerId Source #

Connect a signal handler for the “deactivate” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #deactivate callback

insert

type C_MenuShellInsertCallback = Ptr () -> Ptr Widget -> Int32 -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuShellInsertCallback Source #

Arguments

 = Widget

child: the MenuItem that is being inserted

-> Int32

position: the position at which the insert occurs

-> IO () 

The ::insert signal is emitted when a new MenuItem is added to a MenuShell. A separate signal is used instead of GtkContainer::add because of the need for an additional position parameter.

The inverse of this signal is the GtkContainer::removed signal.

Since: 3.2

afterMenuShellInsert :: (IsMenuShell a, MonadIO m) => a -> MenuShellInsertCallback -> m SignalHandlerId Source #

Connect a signal handler for the “insert” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #insert callback

onMenuShellInsert :: (IsMenuShell a, MonadIO m) => a -> MenuShellInsertCallback -> m SignalHandlerId Source #

Connect a signal handler for the “insert” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #insert callback

moveCurrent

type C_MenuShellMoveCurrentCallback = Ptr () -> CUInt -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuShellMoveCurrentCallback Source #

Arguments

 = MenuDirectionType

direction: the direction to move

-> IO () 

An keybinding signal which moves the current menu item in the direction specified by direction.

afterMenuShellMoveCurrent :: (IsMenuShell a, MonadIO m) => a -> MenuShellMoveCurrentCallback -> m SignalHandlerId Source #

Connect a signal handler for the “move-current” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #moveCurrent callback

onMenuShellMoveCurrent :: (IsMenuShell a, MonadIO m) => a -> MenuShellMoveCurrentCallback -> m SignalHandlerId Source #

Connect a signal handler for the “move-current” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #moveCurrent callback

moveSelected

type C_MenuShellMoveSelectedCallback = Ptr () -> Int32 -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

type MenuShellMoveSelectedCallback Source #

Arguments

 = Int32

distance: +1 to move to the next item, -1 to move to the previous

-> IO Bool

Returns: True to stop the signal emission, False to continue

The ::move-selected signal is emitted to move the selection to another item.

Since: 2.12

afterMenuShellMoveSelected :: (IsMenuShell a, MonadIO m) => a -> MenuShellMoveSelectedCallback -> m SignalHandlerId Source #

Connect a signal handler for the “move-selected” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #moveSelected callback

onMenuShellMoveSelected :: (IsMenuShell a, MonadIO m) => a -> MenuShellMoveSelectedCallback -> m SignalHandlerId Source #

Connect a signal handler for the “move-selected” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #moveSelected callback

selectionDone

type C_MenuShellSelectionDoneCallback = Ptr () -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MenuShellSelectionDoneCallback = IO () Source #

This signal is emitted when a selection has been completed within a menu shell.

afterMenuShellSelectionDone :: (IsMenuShell a, MonadIO m) => a -> MenuShellSelectionDoneCallback -> m SignalHandlerId Source #

Connect a signal handler for the “selection-done” signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after menuShell #selectionDone callback

onMenuShellSelectionDone :: (IsMenuShell a, MonadIO m) => a -> MenuShellSelectionDoneCallback -> m SignalHandlerId Source #

Connect a signal handler for the “selection-done” signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on menuShell #selectionDone callback