gi-gtk-4.0.2: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.PopoverMenu

Description

GtkPopoverMenu is a subclass of Popover that 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.

GtkPopoverMenu is meant to be used primarily with menu models, using popoverMenuNewFromModel. If you need to put other widgets such as SpinButton or Switch into a popover, use a plain Popover.

Menu models

The XML format understood by Builder for MenuModel 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.

<!--language: xml -->
<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 Builder 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 Builder 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
  • "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 determine if a submenu can be opened
  • "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.

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 TextDirection to 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, gtk_widget_class_add_binding_action() or shortcutControllerAddShortcut.

CSS Nodes

PopoverMenu is just a subclass of Popover 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 popover's main node.

Synopsis

Exported types

newtype PopoverMenu Source #

Memory-managed wrapper type.

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

Instances details
(GObject o, IsDescendantOf PopoverMenu o) => IsPopoverMenu o Source # 
Instance details

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

Overloaded methods

getMenuModel

popoverMenuGetMenuModel Source #

Arguments

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

popover: a PopoverMenu

-> m MenuModel

Returns: the menu model of popover

Returns the menu model used to populate the popover.

newFromModel

popoverMenuNewFromModel Source #

Arguments

:: (HasCallStack, MonadIO m, IsMenuModel a) 
=> Maybe a

model: a MenuModel, or Nothing

-> m PopoverMenu

Returns: the new PopoverMenu

Creates a PopoverMenu and populates it according to model.

The created buttons are connected to actions found in the ApplicationWindow 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

model: a MenuModel

-> [PopoverMenuFlags]

flags: flags that affect how the menu is created

-> m PopoverMenu

Returns: the new PopoverMenu

Creates a PopoverMenu 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 ApplicationWindow to which the popover belongs. Actions can also be added using widgetInsertActionGroup on the parent widget or on any of its parent widgets.

The only flag that is supported currently is GTK_POPOVER_MENU_NESTED, which makes GTK create traditional, nested submenus instead of the default sliding submenus.

setMenuModel

popoverMenuSetMenuModel Source #

Arguments

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

popover: a PopoverMenu

-> Maybe b

model: a MenuModel, or Nothing

-> 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

menuModel

No description available in the introspection data.

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 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

set popoverMenu [ #menuModel := value ]

visibleSubmenu

No description available in the introspection data.

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

set popoverMenu [ #visibleSubmenu := value ]