0

My GTK application has the following UIManager XML. Is there a way to link those menus in the XML, so that I do not have to repeat myself?

<ui>
    <menubar name="MenuBar">
        <menu action="Options">
            <menuitem action="Item0"/>
            <menuitem action="Item1"/>
        </menu>
    </menubar>
    <popup name="ContextMenu">
        <menu action="Options">
            <menuitem action="Item0"/>
            <menuitem action="Item1"/>
        </menu>
    </popup>
</ui>
Tim
  • 13,904
  • 10
  • 69
  • 101

1 Answers1

2

You can remove the repeated parts into a separate file, then use entities or XInclude to include them.

daxim
  • 39,270
  • 4
  • 65
  • 132
  • +1, that's an awesome solution - I'm just not 100% sure it works because GTK might parse these files according to GMarkup, a subset of XML that doesn't support XInclude, but I don't know. – ptomato May 23 '11 at 10:12
  • Subset of XML… `o_O` Let me strike another one on the "Gnome developers are morons" chalkboard. - You have to add a preprocessing step with a real XML toolkit to merge your separated files into a single one their library can grok. – daxim May 23 '11 at 10:42
  • Not saying they use the subset, just not 100% sure they don't. I just wanted to point out that this solution needs testing. – ptomato May 24 '11 at 17:10