grim/gir2glade

Muscle memory is weird
draft
2018-05-08, Gary Kramlich
1ceacc6b4468
Parents 36082cc7145e
Children 98a4e72a6c2a
Muscle memory is weird
  • +1 -1
    README.md
  • +0 -92
    gir2glade.xls
  • +92 -0
    gir2glade.xsl
  • --- a/README.md Tue May 08 01:37:13 2018 -0500
    +++ b/README.md Tue May 08 01:49:51 2018 -0500
    @@ -58,7 +58,7 @@
    gtkim_glade_catalog = custom_target('gtkim.xml',
    output : 'gtkim.xml',
    input : gtkim_gir[0],
    - command : [XSLTPROC.path(), '--output', '@0@/gtkim.xml'.format(meson.current_build_dir()), '@0@/gir2glade.xls'.format(meson.source_root()), gtkim_gir[0]],
    + command : [XSLTPROC.path(), '--output', '@0@/gtkim.xml'.format(meson.current_build_dir()), '@0@/gir2glade.xsl'.format(meson.source_root()), gtkim_gir[0]],
    install : true,
    install_dir : GLADEUI.get_pkgconfig_variable('catalogdir'))
    ```
    --- a/gir2glade.xls Tue May 08 01:37:13 2018 -0500
    +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
    @@ -1,92 +0,0 @@
    -<?xml version="1.0" encoding="utf-8"?>
    -<xsl:stylesheet version="1.0"
    - xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    - xmlns:gir="http://www.gtk.org/introspection/core/1.0"
    - xmlns:c="http://www.gtk.org/introspection/c/1.0"
    - xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
    -
    - <xsl:variable name="gir2glade-version" value="0.1"/>
    -
    - <xsl:output method="xml" encoding="UTF-8" indent="yes" version="1.0"/>
    -
    - <xsl:strip-space elements="*"/>
    -
    - <xsl:template name="library-name">
    - <xsl:param name="lib"></xsl:param>
    -
    - <xsl:variable name="split">
    - <xsl:value-of select="substring-after($lib, 'lib')"/>
    - </xsl:variable>
    -
    - <xsl:choose>
    - <xsl:when test="contains($split, '.so')">
    - <xsl:value-of select="substring-before($split, '.so')"/>
    - </xsl:when>
    - <xsl:otherwise>
    - <xsl:text>unsupported</xsl:text>
    - </xsl:otherwise>
    - </xsl:choose>
    - </xsl:template>
    -
    - <xsl:template match="gir:repository">
    - <xsl:element name="glade-catalog">
    - <xsl:apply-templates/>
    - </xsl:element>
    - </xsl:template>
    -
    - <xsl:template match="gir:namespace">
    - <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
    - <xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
    -
    - <!-- clean up the library name -->
    - <xsl:attribute name="library">
    - <xsl:call-template name="library-name">
    - <xsl:with-param name="lib"><xsl:value-of select="@shared-library"/></xsl:with-param>
    - </xsl:call-template>
    - </xsl:attribute>
    -
    - <!-- add each widget class if it's implements Gtk.Buildable -->
    - <xsl:element name="glade-widget-classes">
    - <xsl:for-each select="gir:class">
    - <xsl:call-template name="class"/>
    - </xsl:for-each>
    - </xsl:element>
    -
    - <!-- add a referench for each widget class to the widget group if it implement Gtk.Buildable -->
    - <xsl:element name="glade-widget-group">
    - <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
    - <xsl:attribute name="title"><xsl:value-of select="@name"/></xsl:attribute>
    -
    - <xsl:for-each select="gir:class">
    - <xsl:call-template name="class-group"/>
    - </xsl:for-each>
    - </xsl:element>
    - </xsl:template>
    -
    - <xsl:template name="class">
    - <xsl:if test="gir:implements[@name='Gtk.Buildable']">
    - <xsl:element name="glade-widget-class">
    - <xsl:attribute name="name"><xsl:value-of select="@c:type"/></xsl:attribute>
    - <xsl:attribute name="generic-name"><xsl:value-of select="@c:symbol-prefix"/></xsl:attribute>
    - <xsl:attribute name="title"><xsl:value-of select="@name"/></xsl:attribute>
    - <xsl:attribute name="get-type-function"><xsl:value-of select="@glib:get-type"/></xsl:attribute>
    -
    - <xsl:if test="property">
    - <xsl:element name="properties">
    - <xsl:for-each select="property">
    - <xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
    - </xsl:for-each>
    - </xsl:element>
    - </xsl:if>
    - </xsl:element>
    - </xsl:if>
    - </xsl:template>
    -
    - <xsl:template name="class-group">
    - <xsl:if test="gir:implements[@name='Gtk.Buildable']">
    - <xsl:element name="glade-widget-class-ref">
    - <xsl:attribute name="name"><xsl:value-of select="@c:type"/></xsl:attribute>
    - </xsl:element>
    - </xsl:if>
    - </xsl:template>
    -</xsl:stylesheet>
    --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/gir2glade.xsl Tue May 08 01:49:51 2018 -0500
    @@ -0,0 +1,92 @@
    +<?xml version="1.0" encoding="utf-8"?>
    +<xsl:stylesheet version="1.0"
    + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    + xmlns:gir="http://www.gtk.org/introspection/core/1.0"
    + xmlns:c="http://www.gtk.org/introspection/c/1.0"
    + xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
    +
    + <xsl:variable name="gir2glade-version" value="0.1"/>
    +
    + <xsl:output method="xml" encoding="UTF-8" indent="yes" version="1.0"/>
    +
    + <xsl:strip-space elements="*"/>
    +
    + <xsl:template name="library-name">
    + <xsl:param name="lib"></xsl:param>
    +
    + <xsl:variable name="split">
    + <xsl:value-of select="substring-after($lib, 'lib')"/>
    + </xsl:variable>
    +
    + <xsl:choose>
    + <xsl:when test="contains($split, '.so')">
    + <xsl:value-of select="substring-before($split, '.so')"/>
    + </xsl:when>
    + <xsl:otherwise>
    + <xsl:text>unsupported</xsl:text>
    + </xsl:otherwise>
    + </xsl:choose>
    + </xsl:template>
    +
    + <xsl:template match="gir:repository">
    + <xsl:element name="glade-catalog">
    + <xsl:apply-templates/>
    + </xsl:element>
    + </xsl:template>
    +
    + <xsl:template match="gir:namespace">
    + <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
    + <xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
    +
    + <!-- clean up the library name -->
    + <xsl:attribute name="library">
    + <xsl:call-template name="library-name">
    + <xsl:with-param name="lib"><xsl:value-of select="@shared-library"/></xsl:with-param>
    + </xsl:call-template>
    + </xsl:attribute>
    +
    + <!-- add each widget class if it's implements Gtk.Buildable -->
    + <xsl:element name="glade-widget-classes">
    + <xsl:for-each select="gir:class">
    + <xsl:call-template name="class"/>
    + </xsl:for-each>
    + </xsl:element>
    +
    + <!-- add a referench for each widget class to the widget group if it implement Gtk.Buildable -->
    + <xsl:element name="glade-widget-group">
    + <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
    + <xsl:attribute name="title"><xsl:value-of select="@name"/></xsl:attribute>
    +
    + <xsl:for-each select="gir:class">
    + <xsl:call-template name="class-group"/>
    + </xsl:for-each>
    + </xsl:element>
    + </xsl:template>
    +
    + <xsl:template name="class">
    + <xsl:if test="gir:implements[@name='Gtk.Buildable']">
    + <xsl:element name="glade-widget-class">
    + <xsl:attribute name="name"><xsl:value-of select="@c:type"/></xsl:attribute>
    + <xsl:attribute name="generic-name"><xsl:value-of select="@c:symbol-prefix"/></xsl:attribute>
    + <xsl:attribute name="title"><xsl:value-of select="@name"/></xsl:attribute>
    + <xsl:attribute name="get-type-function"><xsl:value-of select="@glib:get-type"/></xsl:attribute>
    +
    + <xsl:if test="property">
    + <xsl:element name="properties">
    + <xsl:for-each select="property">
    + <xsl:attribute name="id"><xsl:value-of select="@name"/></xsl:attribute>
    + </xsl:for-each>
    + </xsl:element>
    + </xsl:if>
    + </xsl:element>
    + </xsl:if>
    + </xsl:template>
    +
    + <xsl:template name="class-group">
    + <xsl:if test="gir:implements[@name='Gtk.Buildable']">
    + <xsl:element name="glade-widget-class-ref">
    + <xsl:attribute name="name"><xsl:value-of select="@c:type"/></xsl:attribute>
    + </xsl:element>
    + </xsl:if>
    + </xsl:template>
    +</xsl:stylesheet>