Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
Blueprint documentation
Blueprint documentation

Contents:

  • Setup
  • Translations
  • Flatpak
  • Syntax Reference
    • Document Root & Imports
    • Objects
    • Composite Templates
    • Values
    • Expressions
    • Menus
    • Extensions
    • Diagnostics
  • For Distro Packagers
Back to top
View this page

Menus¶

Menus¶

Menu = ‘menu’ <id:IDENT>? ‘{’ MenuChild* ‘}’ MenuChild = ( MenuSection | MenuSubmenu | MenuItemShorthand | MenuItem ) MenuSection = ‘section’ <id:IDENT>? ‘{’ ( MenuChild | MenuAttribute )* ‘}’ MenuSubmenu = ‘submenu’ <id:IDENT>? ‘{’ ( MenuChild | MenuAttribute )* ‘}’ MenuItem = ‘item’ ‘{’ MenuAttribute* ‘}’ MenuAttribute = <name:IDENT> ‘:’ StringValue ‘;’

Menus, such as the application menu, are defined using the menu keyword. Menus have the type Gio.MenuModel and can be referenced by ID. They cannot be defined inline.

Example¶

menu my_menu {
  submenu {
    label: _("File");
    item {
      label: _("New");
      action: "app.new";
      icon: "document-new-symbolic";
    }
  }
}

MenuButton {
  menu-model: my_menu;
}

Item Shorthand¶

MenuItemShorthand = ‘item’ ‘(’ StringValue ( ‘,’ ( StringValue ( ‘,’ StringValue? )? )? )? ‘)’

The most common menu attributes are label, action, and icon. Because they’re so common, Blueprint provides a shorter syntax for menu items with just these properties.

Example¶

menu {
  item ("label")
  item ("label", "action")
  item ("label", "action", "icon")
}
Next
Extensions
Previous
Expressions
Copyright © 2021-2023, James Westman
Made with Sphinx and @pradyunsg's Furo
On this page
  • Menus
    • Menus
      • Example
    • Item Shorthand
      • Example