########################### Extending Application Menus ########################### Menus in Builder are implemented using the ``GtkBuilder`` based menu definitions. These are created in ``gtk/menus.ui`` files within your extensions resources. Menus are automatically merged into the application when your plugin is loaded. If the plugin is unloaded by the user, they will be automatically unloaded as well. Extended Menu Features ====================== The ``GMenu`` abstraction is somewhat limited in features that Builder requires. In particular, Builder needs advanced sorting, icons, and accelerators for menu items. To overcome this, Builder has special "menu merging" code which has been extrated into ``libdazzle`` (a utility library). Here is an example of how the valgrind plugin extends the Run menu. .. code-block:: xml :caption: Embed file as a resource matching /org/gnome/Builder/plugins/valgrind_plugin/gtk/menus.ui
valgrind-run-handler default-run-handler run-manager.run-with-handler valgrind Run with Valgrind system-run-symbolic <Control>F10
For more information on embedding resources with Python-based plugins, see :ref:`creating embedded GResources`. Accessing Merged Menus ====================== Merged menus are available via the ``Dzl.Application`` base class of ``Ide.Application``. .. code-block:: python3 menu = Ide.Application.get_default().get_menu_by_id('run-menu')