Skip to content

Commit

Permalink
menus: fix dialogs_dockable_actions being in 2 groups.
Browse files Browse the repository at this point in the history
Depending on where it's used, this list of action can be either in the
"dockable" or the "dialogs" action group.

The meson rule is a bit more complicated than I wished it were because of the
ever-so-blocking lack of simple dependency in meson.
Cf. my latest comment: mesonbuild/meson#8123 (comment)
  • Loading branch information
Jehan committed Apr 11, 2023
1 parent a903773 commit da9bf9f
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 48 deletions.
30 changes: 21 additions & 9 deletions menus/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
menudatadir = $(gimpdatadir)/menus

menudata_in_files = \
dockable-menu.ui.in \
image-menu.ui.in
dockable-menu.ui.in.in \
image-menu.ui.in.in

menudata_built_files = $(menudata_in_files:.ui.in=.ui)
menudata_built_files = $(menudata_in_files:.ui.in.in=.ui)

menudata_DATA = \
$(menudata_built_files) \
Expand Down Expand Up @@ -46,7 +46,7 @@ menudata_DATA = \
EXTRA_DIST = \
$(menudata_DATA) \
$(menudata_in_files) \
dialogs-menuitems.ui \
dialogs-menuitems.ui.in \
gtkuimanager.dtd \
menus.xsl

Expand All @@ -57,20 +57,32 @@ if GIMP_UNSTABLE
UNSTABLE_MENU_PARAMS = --stringparam unstable-menus yes
endif

SUFFIXES = .ui.in .ui
SUFFIXES = .ui.in.in .ui

%-dialogs-menuitems.ui: dialogs-menuitems.ui.in
sed 's/@GROUP@/$*/' $< > $@

dockable-menu.ui.in: dockable-menu.ui.in.in
sed 's/@GROUP@/dockable/' $< > $@

image-menu.ui.in: image-menu.ui.in.in
sed 's/@GROUP@/dialogs/' $< > $@

# Adding a `realpath` because xsltproc adds an xml:base attribute when the path
# is absolute. This breaks our parsing at runtime.
.ui.in.ui:
image-menu.ui: image-menu.ui.in dialogs-dialogs-menuitems.ui $(srcdir)/menus.xsl $(top_srcdir)/configure.ac
if HAVE_XSLTPROC
$(XSLTPROC) --xinclude $(UNSTABLE_MENU_PARAMS) $(srcdir)/menus.xsl "`realpath --relative-to=. $<`" > $(@) || rm -f $(@)
else
@echo "*** xsltproc is required to build the menus XML files ***"; exit 1;
endif

# Specifying dependencies in the implicit rule above does not work, so
# specify them here instead
dockable-menu.ui image-menu.ui: $(top_srcdir)/configure.ac $(srcdir)/menus.xsl dialogs-menuitems.ui
dockable-menu.ui: dockable-menu.ui.in dockable-dialogs-menuitems.ui $(srcdir)/menus.xsl $(top_srcdir)/configure.ac
if HAVE_XSLTPROC
$(XSLTPROC) --xinclude $(UNSTABLE_MENU_PARAMS) $(srcdir)/menus.xsl "`realpath --relative-to=. $<`" > $(@) || rm -f $(@)
else
@echo "*** xsltproc is required to build the menus XML files ***"; exit 1;
endif

validate: $(menudata_DATA)
if HAVE_XMLLINT
Expand Down
36 changes: 0 additions & 36 deletions menus/dialogs-menuitems.ui

This file was deleted.

36 changes: 36 additions & 0 deletions menus/dialogs-menuitems.ui.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>

<section>
<item><attribute name="action">@GROUP@.dialogs-tool-options</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-device-status</attribute></item>
<section>
<item><attribute name="action">@GROUP@.dialogs-layers</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-channels</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-vectors</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-indexed-palette</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-histogram</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-selection-editor</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-navigation</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-undo-history</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-cursor</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-sample-points</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-symmetry</attribute></item>
</section>
<section>
<item><attribute name="action">@GROUP@.dialogs-colors</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-brushes</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-dynamics</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-mypaint-brushes</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-patterns</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-gradients</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-palettes</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-fonts</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-tool-presets</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-buffers</attribute></item>
</section>
<item><attribute name="action">@GROUP@.dialogs-images</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-document-history</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-templates</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-error-console</attribute></item>
<item><attribute name="action">@GROUP@.dialogs-dashboard</attribute></item>
</section>
2 changes: 1 addition & 1 deletion menus/dockable-menu.ui.in → menus/dockable-menu.ui.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<menu id="/dockable-popup">
<submenu>
<attribute name="label" translatable="yes" context="file-action">_Add Tab</attribute>
<xi:include href="dialogs-menuitems.ui" />
<xi:include href="@GROUP@-dialogs-menuitems.ui" />
</submenu>
<item><attribute name="action">dockable.dockable-close-tab</attribute></item>
<item><attribute name="action">dockable.dockable-detach-tab</attribute></item>
Expand Down
2 changes: 1 addition & 1 deletion menus/image-menu.ui.in → menus/image-menu.ui.in.in
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@
</submenu>
<submenu>
<attribute name="label" translatable="yes" context="windows-action">_Dockable Dialogs</attribute>
<xi:include href="dialogs-menuitems.ui" />
<xi:include href="@GROUP@-dialogs-menuitems.ui" />
</submenu>
<item><attribute name="action">app.dialogs-toolbox</attribute></item>
</section>
Expand Down
31 changes: 30 additions & 1 deletion menus/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,42 @@ unstable_menus_args = stable ? [] : [ '--stringparam', 'unstable-menus', 'yes' ]

menus_ui_built_files = []
foreach menu_filegen : [ 'dockable-menu.ui', 'image-menu.ui', ]
# This does look a bit overly complicated, but I encountered 2 issues:
# 1. The simpler solution was to do first the custom_target() then a single
# configure_file() per file. It didn't work out because of meson complex
# dependency logic (see https://github.com/mesonbuild/meson/issues/8123).
# 2. So I inverted, but now xsltproc was the one acting up by adding the
# 'xml:base' attribute when the included and including XML files are in
# different folders. This is why I added a second configure_file() to have
# both XML files in the same folder.
conf = configuration_data()
if menu_filegen == 'dockable-menu.ui'
group = 'dockable'
else
group = 'dialogs'
endif
conf.set('GROUP', group)
included_file = configure_file(
input: 'dialogs-menuitems.ui.in',
output: group + '-dialogs-menuitems.ui',
configuration: conf,
)

pre_built_file = configure_file(
input: menu_filegen + '.in.in',
output: menu_filegen + '.in',
configuration: conf,
)

menus_ui_built_files += custom_target(menu_filegen,
input : [ menu_filegen +'.in', 'menus.xsl', 'dialogs-menuitems.ui'],
input : [ pre_built_file, 'menus.xsl', included_file],
output: [ menu_filegen ],
command: [
xsltproc,
'--xinclude',
unstable_menus_args,
'--path',
meson.current_build_dir(),
'--output', '@OUTPUT@',
'@INPUT1@',
'@INPUT0@',
Expand Down

0 comments on commit da9bf9f

Please sign in to comment.