~compiz-team/compiz/0.9.12

« back to all changes in this revision

Viewing changes to xslt/compiz_gconf_schemas.xslt

  • Committer: CI Train Bot
  • Author(s): Marco Trevisan (Treviño)
  • Date: 2015-12-11 10:00:29 UTC
  • mfrom: (3988.2.3 compiz)
  • Revision ID: ci-train-bot@canonical.com-20151211100029-5tq13bj2xvpejtdv
backends: drop gconf support
Approved by: Sebastien Bacher

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!--
2
 
  Copyright © 2007 Dennis Kasprzyk
3
 
 
4
 
  Permission to use, copy, modify, distribute, and sell this software
5
 
  and its documentation for any purpose is hereby granted without
6
 
  fee, provided that the above copyright notice appear in all copies
7
 
  and that both that copyright notice and this permission notice
8
 
  appear in supporting documentation, and that the name of
9
 
  Dennis Kasprzyk not be used in advertising or publicity pertaining to
10
 
  distribution of the software without specific, written prior permission.
11
 
  Dennis Kasprzyk makes no representations about the suitability of this
12
 
  software for any purpose. It is provided "as is" without express or
13
 
  implied warranty.
14
 
 
15
 
  DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16
 
  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17
 
  NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18
 
  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19
 
  OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20
 
  NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21
 
  WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
 
 
23
 
  Authors: Dennis Kasprzyk <onestone@deltatauchi.de>
24
 
-->
25
 
 
26
 
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
27
 
  <xsl:output method="xml" indent="yes"/>
28
 
 
29
 
  <xsl:param name="appName">/apps/compiz-1</xsl:param>
30
 
 
31
 
  <xsl:template  match="/compiz">
32
 
    <gconfschemafile>
33
 
      <schemalist>
34
 
        <!-- two levels of indentation: group and subgroup>= -->
35
 
        <xsl:for-each select="/compiz//options//option[not(@read_only='true') and not(@type='action')]">
36
 
          <xsl:call-template name="dumpOption"/>
37
 
        </xsl:for-each>
38
 
      </schemalist>
39
 
    </gconfschemafile>
40
 
  </xsl:template>
41
 
 
42
 
  <!-- generates the schema for an option -->
43
 
  <xsl:template name="dumpOption">
44
 
    <schema>
45
 
      <key>/schemas<xsl:call-template name="printKey"/></key>
46
 
      <applyto><xsl:call-template name="printKey"/></applyto>
47
 
      <owner>compiz-1</owner>
48
 
      <type><xsl:call-template name="printType"/></type>
49
 
      <xsl:choose>
50
 
        <!-- color values need a special handling -->
51
 
        <xsl:when test="@type = 'color'">
52
 
          <default>
53
 
            <xsl:choose>
54
 
              <xsl:when test="default">
55
 
                <xsl:for-each select="default[1]">
56
 
                  <xsl:call-template name="printColor"/>
57
 
                </xsl:for-each>
58
 
              </xsl:when>
59
 
              <xsl:otherwise>
60
 
                <xsl:text>#000000ff</xsl:text>
61
 
              </xsl:otherwise>
62
 
            </xsl:choose>
63
 
          </default>
64
 
        </xsl:when>
65
 
        <xsl:when test="@type = 'edge'">
66
 
          <default>
67
 
            <xsl:call-template name="printEdgeList"/>
68
 
          </default>
69
 
        </xsl:when>
70
 
        <xsl:when test="@type = 'list'">
71
 
          <list_type>
72
 
            <xsl:call-template name="printType">
73
 
              <xsl:with-param name="type" select="type/text()"/>
74
 
            </xsl:call-template>
75
 
          </list_type>
76
 
          <xsl:choose>
77
 
            <xsl:when test="type/text() = 'color'">
78
 
              <default>[<xsl:call-template name="printColorList"/>]</default>
79
 
            </xsl:when>
80
 
            <xsl:otherwise>
81
 
              <default>[<xsl:call-template name="printValueList"/>]</default>
82
 
            </xsl:otherwise>
83
 
          </xsl:choose>
84
 
        </xsl:when>
85
 
        <!-- for most option types we can use the default value directly -->
86
 
        <xsl:otherwise>
87
 
          <default>
88
 
            <xsl:choose>
89
 
              <xsl:when test="default/text()">
90
 
                <xsl:value-of select="default/text()"/>
91
 
              </xsl:when>
92
 
              <xsl:otherwise>
93
 
                <!-- if no default value was specified we need to generate one -->
94
 
                <xsl:choose>
95
 
                  <xsl:when test="contains('bool,bell',@type)">
96
 
                    <xsl:text>false</xsl:text>
97
 
                  </xsl:when>
98
 
                  <xsl:when test="@type = 'int'">
99
 
                    <xsl:variable name="num">
100
 
                      <xsl:call-template name="printNumFallback"/>
101
 
                    </xsl:variable>
102
 
                    <xsl:value-of select="floor($num)"/>
103
 
                  </xsl:when>
104
 
                  <xsl:when test="@type = 'float'">
105
 
                    <xsl:call-template name="printNumFallback"/>
106
 
                  </xsl:when>
107
 
                  <xsl:when test="contains('key,button',@type)">
108
 
                    <xsl:text>Disabled</xsl:text>
109
 
                  </xsl:when>
110
 
                </xsl:choose>
111
 
              </xsl:otherwise>
112
 
            </xsl:choose>
113
 
          </default>
114
 
        </xsl:otherwise>
115
 
      </xsl:choose>
116
 
      <!-- add the short and long descriptions -->
117
 
      <xsl:call-template name="printDescription"/>
118
 
    </schema>
119
 
  </xsl:template>
120
 
 
121
 
  <!-- converts a compiz type to a gconf type -->
122
 
  <xsl:template name="printType">
123
 
    <xsl:param name="type">
124
 
      <xsl:value-of select="@type"/>
125
 
    </xsl:param>
126
 
    <xsl:choose>
127
 
      <xsl:when test="$type = 'int'">
128
 
        <xsl:text>int</xsl:text>
129
 
      </xsl:when>
130
 
      <xsl:when test="$type = 'float'">
131
 
        <xsl:text>float</xsl:text>
132
 
      </xsl:when>
133
 
      <xsl:when test="$type = 'bool'">
134
 
        <xsl:text>bool</xsl:text>
135
 
      </xsl:when>
136
 
      <xsl:when test="$type = 'list'">
137
 
        <xsl:text>list</xsl:text>
138
 
      </xsl:when>
139
 
      <xsl:when test="$type = 'bell'">
140
 
        <xsl:text>bool</xsl:text>
141
 
      </xsl:when>
142
 
      <xsl:otherwise>
143
 
        <xsl:text>string</xsl:text>
144
 
      </xsl:otherwise>
145
 
    </xsl:choose>
146
 
  </xsl:template>
147
 
 
148
 
  <!-- prints the option long and short descriptions of an option -->
149
 
  <xsl:template name="printDescription">
150
 
    <xsl:param name="info">
151
 
      <xsl:call-template name="printInfo"/>
152
 
    </xsl:param>
153
 
    <locale name="C">
154
 
      <short><xsl:value-of select="short[not(@xml:lang)]/text()"/></short>
155
 
      <long>
156
 
        <xsl:value-of select="long[not(@xml:lang)]/text()"/>
157
 
        <xsl:value-of select="$info"/>
158
 
      </long>
159
 
    </locale>
160
 
    <xsl:for-each select="short[@xml:lang]">
161
 
      <xsl:variable name="language" select="@xml:lang"/>
162
 
      <xsl:variable name="infoTrans">
163
 
        <xsl:call-template name="printInfoTrans">
164
 
          <xsl:with-param name="language" select="$language"/>
165
 
        </xsl:call-template>
166
 
      </xsl:variable>
167
 
      <locale>
168
 
        <xsl:attribute name='name'>
169
 
          <xsl:value-of select="@xml:lang"/>
170
 
        </xsl:attribute>
171
 
        <short><xsl:value-of select="text()"/></short>
172
 
        <long>
173
 
          <xsl:choose>
174
 
            <xsl:when test="parent::option/long[lang($language)]">
175
 
              <xsl:value-of select="parent::option/long[lang($language)]/text()"/>
176
 
            </xsl:when>
177
 
            <xsl:otherwise>
178
 
              <xsl:value-of select="parent::option/long[not(@xml:lang)]/text()"/>
179
 
            </xsl:otherwise>
180
 
          </xsl:choose>
181
 
          <xsl:value-of select="$infoTrans"/>
182
 
        </long>
183
 
      </locale>
184
 
    </xsl:for-each>
185
 
  </xsl:template>
186
 
 
187
 
  <!-- generates the additional info for the long option description -->
188
 
  <xsl:template name="printInfo">
189
 
    <xsl:variable name="info">
190
 
      <xsl:text> (</xsl:text>
191
 
      <xsl:choose>
192
 
        <xsl:when test="contains('int,float',@type) and not(desc/value/text())">
193
 
          <xsl:value-of select="min/text()"/> - <xsl:value-of select="max/text()"/>
194
 
        </xsl:when>
195
 
        <xsl:when test="@type='int' and desc/value/text()">
196
 
          <xsl:call-template name="printIntDescList"/>
197
 
        </xsl:when>
198
 
        <xsl:when test="@type = 'match'">
199
 
          <xsl:text>match</xsl:text>
200
 
        </xsl:when>
201
 
      </xsl:choose>
202
 
      <xsl:text>)</xsl:text>
203
 
    </xsl:variable>
204
 
    <xsl:if test="not(contains($info,' ()'))">
205
 
      <xsl:value-of select="$info"/>
206
 
    </xsl:if>
207
 
  </xsl:template>
208
 
 
209
 
  <!-- generates a list of int descriptions -->
210
 
  <xsl:template name="printIntDescList">
211
 
    <xsl:variable name="list">
212
 
      <xsl:for-each select="desc">
213
 
          <xsl:value-of select="value/text()"/>
214
 
          <xsl:text> = </xsl:text>
215
 
          <xsl:value-of select="name/text()"/>
216
 
          <xsl:text>, </xsl:text>
217
 
      </xsl:for-each>
218
 
    </xsl:variable>
219
 
    <xsl:value-of select="substring($list,1,string-length($list) - 2)"/>
220
 
  </xsl:template>
221
 
 
222
 
   <!-- generates the additional info for the long option description -->
223
 
  <xsl:template name="printInfoTrans">
224
 
    <xsl:param name="language"/>
225
 
    <xsl:variable name="info">
226
 
      <xsl:text> (</xsl:text>
227
 
      <xsl:choose>
228
 
        <xsl:when test="contains('int,float',parent::option/@type) and not(parent::option/desc/value/text())">
229
 
          <xsl:value-of select="parent::option/min/text()"/> - <xsl:value-of select="parent::option/max/text()"/>
230
 
        </xsl:when>
231
 
        <xsl:when test="parent::option/@type='int' and parent::option/desc/value/text()">
232
 
          <xsl:call-template name="printIntDescListTrans">
233
 
            <xsl:with-param name="language" select="$language"/>
234
 
          </xsl:call-template>
235
 
        </xsl:when>
236
 
        <xsl:when test="parent::option/@type = 'match'">
237
 
          <xsl:text>match</xsl:text>
238
 
        </xsl:when>
239
 
      </xsl:choose>
240
 
      <xsl:text>)</xsl:text>
241
 
    </xsl:variable>
242
 
    <xsl:if test="not(contains($info,' ()'))">
243
 
      <xsl:value-of select="$info"/>
244
 
    </xsl:if>
245
 
  </xsl:template>
246
 
 
247
 
  <!-- generates a list of int descriptions -->
248
 
  <xsl:template name="printIntDescListTrans">
249
 
    <xsl:param name="language"/>
250
 
    <xsl:variable name="list">
251
 
      <xsl:for-each select="parent::option/desc">
252
 
          <xsl:value-of select="value/text()"/>
253
 
          <xsl:text> = </xsl:text>
254
 
          <xsl:choose>
255
 
            <xsl:when test="name[lang($language)]/text()">
256
 
              <xsl:value-of select="name[lang($language)]/text()"/>
257
 
            </xsl:when>
258
 
            <xsl:otherwise>
259
 
              <xsl:value-of select="name[not(@xml:lang)]/text()"/>
260
 
            </xsl:otherwise>
261
 
          </xsl:choose>
262
 
          <xsl:text>, </xsl:text>
263
 
      </xsl:for-each>
264
 
    </xsl:variable>
265
 
    <xsl:value-of select="substring($list,1,string-length($list) - 2)"/>
266
 
  </xsl:template>
267
 
 
268
 
  <!-- generates a default number out of the min and max values -->
269
 
  <xsl:template name="printNumFallback">
270
 
    <xsl:choose>
271
 
      <xsl:when test="max/text() and min/text()">
272
 
        <xsl:value-of select="(max/text() + min/text()) div 2"/>
273
 
      </xsl:when>
274
 
      <xsl:when test="max/text() and not(min/text())">
275
 
        <xsl:value-of select="max/text()"/>
276
 
      </xsl:when>
277
 
      <xsl:when test="not(max/text()) and min/text()">
278
 
        <xsl:value-of select="min/text()"/>
279
 
      </xsl:when>
280
 
      <xsl:otherwise>0</xsl:otherwise>
281
 
    </xsl:choose>
282
 
  </xsl:template>
283
 
 
284
 
  <!-- generates a list of values -->
285
 
  <xsl:template name="printValueList">
286
 
    <xsl:variable name="list">
287
 
      <xsl:for-each select="default/value">
288
 
        <xsl:value-of select="text()"/>
289
 
        <xsl:text>,</xsl:text>
290
 
      </xsl:for-each>
291
 
    </xsl:variable>
292
 
    <xsl:value-of select="substring($list,1,string-length($list) - 1)"/>
293
 
  </xsl:template>
294
 
 
295
 
  <!-- generates a list of color string values -->
296
 
  <xsl:template name="printColorList">
297
 
    <xsl:variable name="list">
298
 
      <xsl:for-each select="default/value">
299
 
        <xsl:call-template name="printColor"/>
300
 
        <xsl:text>,</xsl:text>
301
 
      </xsl:for-each>
302
 
    </xsl:variable>
303
 
    <xsl:value-of select="substring($list,1,string-length($list) - 1)"/>
304
 
  </xsl:template>
305
 
 
306
 
  <!--
307
 
    generates the #00aabbcc color value out of the compiz
308
 
    metadata color description
309
 
  -->
310
 
  <xsl:template name="printColor">
311
 
    <xsl:variable name="red">
312
 
      <xsl:call-template name="getHexNum">
313
 
        <xsl:with-param name="value" select="red/text()"/>
314
 
      </xsl:call-template>
315
 
    </xsl:variable>
316
 
    <xsl:variable name="green">
317
 
      <xsl:call-template name="getHexNum">
318
 
        <xsl:with-param name="value" select="green/text()"/>
319
 
      </xsl:call-template>
320
 
    </xsl:variable>
321
 
    <xsl:variable name="blue">
322
 
      <xsl:call-template name="getHexNum">
323
 
        <xsl:with-param name="value" select="blue/text()"/>
324
 
      </xsl:call-template>
325
 
    </xsl:variable>
326
 
    <xsl:variable name="alpha">
327
 
      <xsl:choose>
328
 
        <xsl:when test="alpha/text()">
329
 
          <xsl:call-template name="getHexNum">
330
 
            <xsl:with-param name="value" select="alpha/text()"/>
331
 
          </xsl:call-template>
332
 
        </xsl:when>
333
 
        <xsl:otherwise>
334
 
          <xsl:text>ff</xsl:text>
335
 
        </xsl:otherwise>
336
 
      </xsl:choose>
337
 
    </xsl:variable>
338
 
    <xsl:value-of select="concat('#',concat($red,concat($green,concat($blue,$alpha))))"/>
339
 
  </xsl:template>
340
 
 
341
 
  <!--
342
 
    converts a decimal number in the range of 0-65535 or
343
 
    a hex number in the range of 0x0000 - 0xffff to a hex number in the
344
 
    range of 00 - ff
345
 
  -->
346
 
  <xsl:template name="getHexNum">
347
 
    <xsl:param name="value"/>
348
 
    <xsl:choose>
349
 
      <xsl:when test="starts-with($value,'0x')">
350
 
        <xsl:variable name="number">
351
 
          <xsl:text>0000</xsl:text>
352
 
          <xsl:value-of select="substring-after($value,'0x')"/>
353
 
        </xsl:variable>
354
 
        <xsl:value-of select="substring(concat('000',$number),string-length($number),2)"/>
355
 
      </xsl:when>
356
 
      <xsl:when test="string-length($value)">
357
 
        <xsl:variable name="number">
358
 
          <xsl:call-template name="toHex">
359
 
            <xsl:with-param name="decimalNumber" select="$value"/>
360
 
          </xsl:call-template>
361
 
        </xsl:variable>
362
 
        <xsl:value-of select="substring(concat('000',$number),string-length($number),2)"/>
363
 
      </xsl:when>
364
 
      <xsl:otherwise>
365
 
        <xsl:text>00</xsl:text>
366
 
      </xsl:otherwise>
367
 
    </xsl:choose>
368
 
  </xsl:template>
369
 
 
370
 
  <!-- generates a list of selected edges -->
371
 
  <xsl:template name="printEdgeList">
372
 
    <xsl:variable name="list">
373
 
      <xsl:for-each select="default/edge">
374
 
        <xsl:value-of select="@name"/>
375
 
        <xsl:text> | </xsl:text>
376
 
      </xsl:for-each>
377
 
    </xsl:variable>
378
 
    <xsl:value-of select="substring($list,1,string-length($list) - 3)"/>
379
 
  </xsl:template>
380
 
 
381
 
  <!-- prints the key path for an option -->
382
 
  <xsl:template name="printKey">
383
 
    <xsl:value-of select="$appName"/>
384
 
    <xsl:choose>
385
 
      <xsl:when test="ancestor::plugin">
386
 
        <xsl:text>/plugins/</xsl:text>
387
 
        <xsl:value-of select="ancestor::plugin/@name"/>
388
 
      </xsl:when>
389
 
      <xsl:otherwise>
390
 
        <xsl:text>/general</xsl:text>
391
 
      </xsl:otherwise>
392
 
    </xsl:choose>
393
 
    <xsl:text>/screen0/options/</xsl:text>
394
 
    <xsl:value-of select="@name"/>
395
 
  </xsl:template>
396
 
 
397
 
  <!-- converts a decimal number to a hex number -->
398
 
  <xsl:variable name="hexDigits" select="'0123456789abcdef'" />
399
 
 
400
 
  <xsl:template name="toHex">
401
 
    <xsl:param name="decimalNumber" />
402
 
    <xsl:if test="$decimalNumber >= 16">
403
 
      <xsl:call-template name="toHex">
404
 
        <xsl:with-param name="decimalNumber" select="floor($decimalNumber div 16)" />
405
 
      </xsl:call-template>
406
 
    </xsl:if>
407
 
    <xsl:value-of select="substring($hexDigits, ($decimalNumber mod 16) + 1, 1)" />
408
 
  </xsl:template>
409
 
 
410
 
</xsl:stylesheet>