[buoh/cleanups: 3/4] build: fix ui validation



commit 09d6e4d98d5c54e400a8b93fa4f1658c033df9ad
Author: Jan Tojnar <jtojnar gmail com>
Date:   Wed Jan 23 11:11:58 2019 +0100

    build: fix ui validation

 build-aux/ui-pre-validation.xsl | 40 ++++++++++++++++++++++++++++++++++++++++
 data/meson.build                | 15 ++++++++++++++-
 2 files changed, 54 insertions(+), 1 deletion(-)
---
diff --git a/build-aux/ui-pre-validation.xsl b/build-aux/ui-pre-validation.xsl
new file mode 100644
index 0000000..5c1756d
--- /dev/null
+++ b/build-aux/ui-pre-validation.xsl
@@ -0,0 +1,40 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()" />
+    </xsl:copy>
+  </xsl:template>
+
+  <!-- BuohComicList -->
+  <xsl:template match="template[@parent = 'GtkBin']">
+    <object>
+      <!-- GtkBin is abstract -->
+      <xsl:attribute name="class">GtkWindow</xsl:attribute>
+      <xsl:apply-templates select="@*[name() != 'parent' and name() != 'class']|node()" />
+    </object>
+  </xsl:template>
+  <!-- Other templates -->
+  <xsl:template match="template[@parent != 'GtkBin']">
+    <object>
+      <xsl:attribute name="class">
+        <xsl:value-of select="@parent"/>
+      </xsl:attribute>
+      <xsl:apply-templates select="@*[name() != 'parent' and name() != 'class']|node()" />
+    </object>
+  </xsl:template>
+
+  <!-- Usage of custom elements -->
+  <xsl:template match="object/@class[. = 'BuohView']">
+    <!-- GtkBin is abstract -->
+    <xsl:attribute name="class">GtkWindow</xsl:attribute>
+  </xsl:template>
+  <xsl:template match="object/@class[. = 'BuohComicList']">
+    <xsl:attribute name="class">GtkNotebook</xsl:attribute>
+  </xsl:template>
+  <xsl:template match="object/@class[. = 'BuohViewComic']">
+    <xsl:attribute name="class">GtkViewport</xsl:attribute>
+  </xsl:template>
+  <xsl:template match="object/@class[. = 'BuohViewMessage']">
+    <xsl:attribute name="class">GtkViewport</xsl:attribute>
+  </xsl:template>
+</xsl:stylesheet>
diff --git a/data/meson.build b/data/meson.build
index 87c8bf4..b17beee 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -8,12 +8,25 @@ ui_files = files(
   'ui/view-message.ui',
   'ui/window.ui',
 )
+xsltproc = find_program('xsltproc')
 if gtk_builder_tool.found()
   foreach ui : ui_files
+    # gtk-builder-tool validate does not support custom widgets
+    ui_for_validation = configure_file(
+      input: ui,
+      output: '@PLAINNAME@',
+      command: [
+        xsltproc,
+        join_paths(meson.source_root(), 'build-aux', 'ui-pre-validation.xsl'),
+        '@INPUT@',
+      ],
+      capture: true,
+    )
+
     test(
       'Validating @0@'.format(ui),
       gtk_builder_tool,
-      args: ['validate', ui],
+      args: ['validate', ui_for_validation],
       workdir: meson.current_build_dir(),
     )
   endforeach


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]