_File
Open ...">

Is there a way to insert a menu entry for a plugin in a specific "section" of the menus? (original) (raw)

For instance looking at Image-menu.ui, in <Image>/File there are Open/Save/Export sections:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE interface SYSTEM "gtkuimanager.dtd">
<!-- This file is automatically generated. Do not edit! -->
<interface>
  <menu id="/image-menubar">
    <!-- File menu -->
    <submenu>
      <attribute name="label" translatable="yes" context="file-action">_File</attribute>
      <section>
        <attribute name="section-name" translatable="no">Open</attribute>
        <item><attribute name="action">app.image-new</attribute></item>
        <submenu>
          <attribute name="label" translatable="yes" context="file-action">Crea_te</attribute>
          <item><attribute name="action">app.edit-paste-as-new-image</attribute></item>
        </submenu>
        <item><attribute name="action">app.file-open</attribute></item>
        <item><attribute name="action">app.file-open-as-layers</attribute></item>
        <item><attribute name="action">app.file-open-location</attribute></item>
        <submenu>
          <attribute name="label" translatable="yes" context="file-action">Open _Recent</attribute>
          <section>
            <attribute name="section-name" translatable="no">Files</attribute>
          </section>
          <item><attribute name="action">app.dialogs-document-history</attribute></item>
        </submenu>

      <section>
        <attribute name="section-name" translatable="no">Save</attribute>
        <item><attribute name="action">app.file-save</attribute></item>
        <item><attribute name="action">app.file-save-as</attribute></item>
        <item><attribute name="action">app.file-save-a-copy</attribute></item>
        <item><attribute name="action">app.file-revert</attribute></item>
      </section>
      <section>
        <attribute name="section-name" translatable="no">Export</attribute>
        <item><attribute name="action">app.file-overwrite</attribute></item>
        <item><attribute name="action">app.file-export</attribute></item>
        <item><attribute name="action">app.file-export-as</attribute></item>
        <item><attribute name="action">app.file-create-template</attribute></item>
      </section>

Is there some syntax in the menu path name to get there? <Image >/<File>/<Export> doesn’t seem to work (in V2 I could just use <Image>/File/Export).

Jehan (Jehan) March 27, 2025, 6:53pm 2

You may use square brackets to target sections. Basically, use the menu path <Image>/File/[Export].

Ofnuts March 27, 2025, 8:52pm 3

Thanks. Hmm. But why only on [Export]? Asking because if I make a translatable plugin I guess that [Export] is not translatable, but File would be?

Jehan (Jehan) March 28, 2025, 9:10pm 4

Why do you mean? Only what? The square brackets? Because this is not a (sub)menu. This is a named section. So it’s a different syntax.

As for translating, don’t translate existing menu names. Even “File”, GIMP will find the proper menu, even when translated (e.g. “Fichier” in French).

You may feel free to localize the non-existing submenus in your plug-in (these will be created by GIMP as is).