grim/gir2glade
Clone
Summary
Browse
Changes
Graph
add support for parsing the library on mac and preliminary support for windows (untested)
draft
default
tip
2018-05-08, Gary Kramlich
2ef7e38f4086
add support for parsing the library on mac and preliminary support for windows (untested)
<?xml version="1.0" encoding="utf-8"?>
<!--
gir2glade
Copyright 2018 Gary Kramlich <grim@reaperworld.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<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.2"
/>
<xsl:output
method=
"xml"
encoding=
"UTF-8"
indent=
"yes"
version=
"1.0"
/>
<xsl:strip-space
elements=
"*"
/>
<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:variable
name=
"split"
>
<xsl:value-of
select=
"substring-after(@shared-library, 'lib')"
/>
</xsl:variable>
<xsl:choose
>
<xsl:when
test=
"contains($split, '.so')"
>
<xsl:value-of
select=
"substring-before($split, '.so')"
/>
</xsl:when>
<xsl:when
test=
"contains($split, '.dylib')"
>
<xsl:value-of
select=
"substring-before(substring-before($split, '.dylib'), '.')"
/>
</xsl:when>
<xsl:when
test=
"contains($split, '.dll')"
>
<xsl:value-of
select=
"substring-before($split, '.dll')"
/>
</xsl:when>
<xsl:otherwise
>
<xsl:text
>
unsupported
</xsl:text>
</xsl:otherwise>
</xsl:choose>
</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>