| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.Gtk.Objects.PopoverMenu
Description
GtkPopoverMenu is a subclass of GtkPopover that implements menu
behavior.

GtkPopoverMenu treats its children like menus and allows switching
between them. It can open submenus as traditional, nested submenus,
or in a more touch-friendly sliding fashion.
The property PopoverMenu:flags controls this appearance.
GtkPopoverMenu is meant to be used primarily with menu models,
using popoverMenuNewFromModel. If you need to put
other widgets such as a GtkSpinButton or a GtkSwitch into a popover,
you can use popoverMenuAddChild.
For more dialog-like behavior, use a plain GtkPopover.
Menu models
The XML format understood by GtkBuilder for GMenuModel consists
of a toplevel <menu> element, which contains one or more <item>
elements. Each <item> element contains <attribute> and <link>
elements with a mandatory name attribute. <link> elements have the
same content model as <menu>. Instead of <link name="submenu">
or <link name="section">, you can use <submenu> or <section>
elements.
xml code
<menu id='app-menu'>
<section>
<item>
<attribute name='label' translatable='yes'>_New Window</attribute>
<attribute name='action'>app.new</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_About Sunny</attribute>
<attribute name='action'>app.about</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Quit</attribute>
<attribute name='action'>app.quit</attribute>
</item>
</section>
</menu>Attribute values can be translated using gettext, like other GtkBuilder
content. <attribute> elements can be marked for translation with a
translatable="yes" attribute. It is also possible to specify message
context and translator comments, using the context and comments attributes.
To make use of this, the GtkBuilder must have been given the gettext
domain to use.
The following attributes are used when constructing menu items:
- "label": a user-visible string to display
- "use-markup": whether the text in the menu item includes Pango markup
- "action": the prefixed name of the action to trigger
- "target": the parameter to use when activating the action
- "icon" and "verb-icon": names of icons that may be displayed
- "submenu-action": name of an action that may be used to track whether a submenu is open
- "hidden-when": a string used to determine when the item will be hidden.
Possible values include "action-disabled", "action-missing", "macos-menubar".
This is mainly useful for exported menus, see
applicationSetMenubar. - "custom": a string used to match against the ID of a custom child added with
popoverMenuAddChild,popoverMenuBarAddChild, or in the ui file with<child type="ID">.
The following attributes are used when constructing sections:
- "label": a user-visible string to use as section heading
- "display-hint": a string used to determine special formatting for the section. Possible values include "horizontal-buttons", "circular-buttons" and "inline-buttons". They all indicate that section should be displayed as a horizontal row of buttons.
- "text-direction": a string used to determine the
GtkTextDirectionto use when "display-hint" is set to "horizontal-buttons". Possible values include "rtl", "ltr", and "none".
The following attributes are used when constructing submenus:
- "label": a user-visible string to display
- "icon": icon name to display
Menu items will also show accelerators, which are usually associated
with actions via applicationSetAccelsForAction,
[methodwidgetClass.add_binding_action] or
shortcutControllerAddShortcut.
Shortcuts and Gestures
GtkPopoverMenu supports the following keyboard shortcuts:
- <kbd>Space</kbd> activates the default widget.
CSS Nodes
GtkPopoverMenu is just a subclass of GtkPopover that adds custom content
to it, therefore it has the same CSS nodes. It is one of the cases that add
a .menu style class to the main popover node.
Menu items have nodes with name button and class .model. If a section
display-hint is set, the section gets a node box with class horizontal
plus a class with the same text as the display hint. Note that said box may
not be the direct ancestor of the item buttons. Thus, for example, to style
items in an inline-buttons section, select .inline-buttons button.model.
Other things that may be of interest to style in menus include label nodes.
Accessibility
GtkPopoverMenu uses the AccessibleRoleMenu role, and its
items use the AccessibleRoleMenuItem,
AccessibleRoleMenuItemCheckbox or
AccessibleRoleMenuItemRadio roles, depending on the
action they are connected to.
Synopsis
- newtype PopoverMenu = PopoverMenu (ManagedPtr PopoverMenu)
- class (GObject o, IsDescendantOf PopoverMenu o) => IsPopoverMenu o
- toPopoverMenu :: (MonadIO m, IsPopoverMenu o) => o -> m PopoverMenu
- popoverMenuAddChild :: (HasCallStack, MonadIO m, IsPopoverMenu a, IsWidget b) => a -> b -> Text -> m Bool
- popoverMenuGetFlags :: (HasCallStack, MonadIO m, IsPopoverMenu a) => a -> m [PopoverMenuFlags]
- popoverMenuGetMenuModel :: (HasCallStack, MonadIO m, IsPopoverMenu a) => a -> m (Maybe MenuModel)
- popoverMenuNewFromModel :: (HasCallStack, MonadIO m, IsMenuModel a) => Maybe a -> m PopoverMenu
- popoverMenuNewFromModelFull :: (HasCallStack, MonadIO m, IsMenuModel a) => a -> [PopoverMenuFlags] -> m PopoverMenu
- popoverMenuRemoveChild :: (HasCallStack, MonadIO m, IsPopoverMenu a, IsWidget b) => a -> b -> m Bool
- popoverMenuSetFlags :: (HasCallStack, MonadIO m, IsPopoverMenu a) => a -> [PopoverMenuFlags] -> m ()
- popoverMenuSetMenuModel :: (HasCallStack, MonadIO m, IsPopoverMenu a, IsMenuModel b) => a -> Maybe b -> m ()
- constructPopoverMenuFlags :: (IsPopoverMenu o, MonadIO m) => [PopoverMenuFlags] -> m (GValueConstruct o)
- getPopoverMenuFlags :: (MonadIO m, IsPopoverMenu o) => o -> m [PopoverMenuFlags]
- setPopoverMenuFlags :: (MonadIO m, IsPopoverMenu o) => o -> [PopoverMenuFlags] -> m ()
- clearPopoverMenuMenuModel :: (MonadIO m, IsPopoverMenu o) => o -> m ()
- constructPopoverMenuMenuModel :: (IsPopoverMenu o, MonadIO m, IsMenuModel a) => a -> m (GValueConstruct o)
- getPopoverMenuMenuModel :: (MonadIO m, IsPopoverMenu o) => o -> m (Maybe MenuModel)
- setPopoverMenuMenuModel :: (MonadIO m, IsPopoverMenu o, IsMenuModel a) => o -> a -> m ()
- clearPopoverMenuVisibleSubmenu :: (MonadIO m, IsPopoverMenu o) => o -> m ()
- constructPopoverMenuVisibleSubmenu :: (IsPopoverMenu o, MonadIO m) => Text -> m (GValueConstruct o)
- getPopoverMenuVisibleSubmenu :: (MonadIO m, IsPopoverMenu o) => o -> m (Maybe Text)
- setPopoverMenuVisibleSubmenu :: (MonadIO m, IsPopoverMenu o) => o -> Text -> m ()
Exported types
newtype PopoverMenu Source #
Memory-managed wrapper type.
Constructors
| PopoverMenu (ManagedPtr PopoverMenu) |
Instances
| Eq PopoverMenu Source # | |
Defined in GI.Gtk.Objects.PopoverMenu | |
| GObject PopoverMenu Source # | |
Defined in GI.Gtk.Objects.PopoverMenu | |
| ManagedPtrNewtype PopoverMenu Source # | |
Defined in GI.Gtk.Objects.PopoverMenu Methods | |
| TypedObject PopoverMenu Source # | |
Defined in GI.Gtk.Objects.PopoverMenu | |
| HasParentTypes PopoverMenu Source # | |
Defined in GI.Gtk.Objects.PopoverMenu | |
| IsGValue (Maybe PopoverMenu) Source # | Convert |
Defined in GI.Gtk.Objects.PopoverMenu Methods gvalueGType_ :: IO GType # gvalueSet_ :: Ptr GValue -> Maybe PopoverMenu -> IO () # gvalueGet_ :: Ptr GValue -> IO (Maybe PopoverMenu) # | |
| type ParentTypes PopoverMenu Source # | |
Defined in GI.Gtk.Objects.PopoverMenu type ParentTypes PopoverMenu = '[Popover, Widget, Object, Accessible, Buildable, ConstraintTarget, Native, ShortcutManager] | |
class (GObject o, IsDescendantOf PopoverMenu o) => IsPopoverMenu o Source #
Type class for types which can be safely cast to PopoverMenu, for instance with toPopoverMenu.
Instances
| (GObject o, IsDescendantOf PopoverMenu o) => IsPopoverMenu o Source # | |
Defined in GI.Gtk.Objects.PopoverMenu | |
toPopoverMenu :: (MonadIO m, IsPopoverMenu o) => o -> m PopoverMenu Source #
Cast to PopoverMenu, for types for which this is known to be safe. For general casts, use castTo.
Methods
Click to display all available methods, including inherited ones
Methods
actionSetEnabled, activate, activateAction, activateDefault, addChild, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, announce, bindProperty, bindPropertyFull, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, forceFloating, freezeNotify, getv, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFloating, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, notify, notifyByPspec, observeChildren, observeControllers, pick, popdown, popup, present, queueAllocate, queueDraw, queueResize, realize, ref, refSink, removeChild, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, resetProperty, resetRelation, resetState, runDispose, shouldLayout, show, sizeAllocate, snapshotChild, stealData, stealQdata, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unsetStateFlags, updateNextAccessibleSibling, updateProperty, updateRelation, updateState, watchClosure.
Getters
getAccessibleParent, getAccessibleRole, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getAtContext, getAutohide, getBaseline, getBounds, getBuildableId, getCanFocus, getCanTarget, getCascadePopdown, getChild, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getData, getDirection, getDisplay, getFirstAccessibleChild, getFirstChild, getFlags, getFocusChild, getFocusOnClick, getFocusable, getFontMap, getFontOptions, getFrameClock, getHalign, getHasArrow, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getMenuModel, getMnemonicsVisible, getName, getNative, getNextAccessibleSibling, getNextSibling, getOffset, getOpacity, getOverflow, getPangoContext, getParent, getPlatformState, getPointingTo, getPosition, getPreferredSize, getPrevSibling, getPrimaryClipboard, getProperty, getQdata, getRealized, getReceivesDefault, getRenderer, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getSurface, getSurfaceTransform, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth.
Setters
setAccessibleParent, setAutohide, setCanFocus, setCanTarget, setCascadePopdown, setChild, setChildVisible, setCssClasses, setCursor, setCursorFromName, setData, setDataFull, setDefaultWidget, setDirection, setFlags, setFocusChild, setFocusOnClick, setFocusable, setFontMap, setFontOptions, setHalign, setHasArrow, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setMenuModel, setMnemonicsVisible, setName, setOffset, setOpacity, setOverflow, setParent, setPointingTo, setPosition, setProperty, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible.
addChild
Arguments
| :: (HasCallStack, MonadIO m, IsPopoverMenu a, IsWidget b) | |
| => a |
|
| -> b |
|
| -> Text |
|
| -> m Bool | Returns: |
Adds a custom widget to a generated menu.
For this to work, the menu model of popover must have
an item with a custom attribute that matches id.
getFlags
Arguments
| :: (HasCallStack, MonadIO m, IsPopoverMenu a) | |
| => a |
|
| -> m [PopoverMenuFlags] | Returns: the |
Returns the flags that popover uses to create/display a menu from its model.
Since: 4.14
getMenuModel
popoverMenuGetMenuModel Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPopoverMenu a) | |
| => a |
|
| -> m (Maybe MenuModel) | Returns: the menu model of |
Returns the menu model used to populate the popover.
newFromModel
popoverMenuNewFromModel Source #
Arguments
| :: (HasCallStack, MonadIO m, IsMenuModel a) | |
| => Maybe a |
|
| -> m PopoverMenu | Returns: the new |
Creates a GtkPopoverMenu and populates it according to model.
The created buttons are connected to actions found in the
GtkApplicationWindow to which the popover belongs - typically
by means of being attached to a widget that is contained within
the GtkApplicationWindows widget hierarchy.
Actions can also be added using widgetInsertActionGroup
on the menus attach widget or on any of its parent widgets.
This function creates menus with sliding submenus.
See popoverMenuNewFromModelFull for a way
to control this.
newFromModelFull
popoverMenuNewFromModelFull Source #
Arguments
| :: (HasCallStack, MonadIO m, IsMenuModel a) | |
| => a |
|
| -> [PopoverMenuFlags] |
|
| -> m PopoverMenu | Returns: the new |
Creates a GtkPopoverMenu and populates it according to model.
The created buttons are connected to actions found in the
action groups that are accessible from the parent widget.
This includes the GtkApplicationWindow to which the popover
belongs. Actions can also be added using widgetInsertActionGroup
on the parent widget or on any of its parent widgets.
removeChild
popoverMenuRemoveChild Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPopoverMenu a, IsWidget b) | |
| => a |
|
| -> b |
|
| -> m Bool | Returns: |
Removes a widget that has previously been added with
[methodgtk.PopoverMenu.add_child()]
setFlags
Arguments
| :: (HasCallStack, MonadIO m, IsPopoverMenu a) | |
| => a |
|
| -> [PopoverMenuFlags] |
|
| -> m () |
Sets the flags that popover uses to create/display a menu from its model.
If a model is set and the flags change, contents are rebuilt, so if setting properties individually, set flags before model to avoid a redundant rebuild.
Since: 4.14
setMenuModel
popoverMenuSetMenuModel Source #
Arguments
| :: (HasCallStack, MonadIO m, IsPopoverMenu a, IsMenuModel b) | |
| => a |
|
| -> Maybe b |
|
| -> m () |
Sets a new menu model on popover.
The existing contents of popover are removed, and
the popover is populated with new contents according
to model.
Properties
flags
The flags that popover uses to create/display a menu from its model.
If a model is set and the flags change, contents are rebuilt, so if setting properties individually, set flags before model to avoid a redundant rebuild.
Since: 4.14
constructPopoverMenuFlags :: (IsPopoverMenu o, MonadIO m) => [PopoverMenuFlags] -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “flags” property. This is rarely needed directly, but it is used by new.
getPopoverMenuFlags :: (MonadIO m, IsPopoverMenu o) => o -> m [PopoverMenuFlags] Source #
Get the value of the “flags” property.
When overloading is enabled, this is equivalent to
get popoverMenu #flags
setPopoverMenuFlags :: (MonadIO m, IsPopoverMenu o) => o -> [PopoverMenuFlags] -> m () Source #
Set the value of the “flags” property.
When overloading is enabled, this is equivalent to
setpopoverMenu [ #flags:=value ]
menuModel
The model from which the menu is made.
clearPopoverMenuMenuModel :: (MonadIO m, IsPopoverMenu o) => o -> m () Source #
Set the value of the “menu-model” property to Nothing.
When overloading is enabled, this is equivalent to
clear #menuModel
constructPopoverMenuMenuModel :: (IsPopoverMenu o, MonadIO m, IsMenuModel a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “menu-model” property. This is rarely needed directly, but it is used by new.
getPopoverMenuMenuModel :: (MonadIO m, IsPopoverMenu o) => o -> m (Maybe MenuModel) Source #
Get the value of the “menu-model” property.
When overloading is enabled, this is equivalent to
get popoverMenu #menuModel
setPopoverMenuMenuModel :: (MonadIO m, IsPopoverMenu o, IsMenuModel a) => o -> a -> m () Source #
Set the value of the “menu-model” property.
When overloading is enabled, this is equivalent to
setpopoverMenu [ #menuModel:=value ]
visibleSubmenu
The name of the visible submenu.
clearPopoverMenuVisibleSubmenu :: (MonadIO m, IsPopoverMenu o) => o -> m () Source #
Set the value of the “visible-submenu” property to Nothing.
When overloading is enabled, this is equivalent to
clear #visibleSubmenu
constructPopoverMenuVisibleSubmenu :: (IsPopoverMenu o, MonadIO m) => Text -> m (GValueConstruct o) Source #
Construct a GValueConstruct with valid value for the “visible-submenu” property. This is rarely needed directly, but it is used by new.
getPopoverMenuVisibleSubmenu :: (MonadIO m, IsPopoverMenu o) => o -> m (Maybe Text) Source #
Get the value of the “visible-submenu” property.
When overloading is enabled, this is equivalent to
get popoverMenu #visibleSubmenu
setPopoverMenuVisibleSubmenu :: (MonadIO m, IsPopoverMenu o) => o -> Text -> m () Source #
Set the value of the “visible-submenu” property.
When overloading is enabled, this is equivalent to
setpopoverMenu [ #visibleSubmenu:=value ]