cookbook: Use nicknames for enumeration values

GEnum nicknames can be used to set properties in JSON
definitions, so added a callout to the JSON example explaining
this, and showing how to derive the nickname for an enumeration
value.

Modified the example code to use nicknames as well.
This commit is contained in:
Elliot Smith 2010-08-27 15:29:09 +01:00
parent 2c3ca20cdc
commit 79a4dbb329
2 changed files with 27 additions and 4 deletions

View File

@ -16,8 +16,8 @@
"layout-manager" : { "layout-manager" : {
"type" : "ClutterBinLayout", "type" : "ClutterBinLayout",
"x-align" : "CLUTTER_BIN_ALIGNMENT_CENTER", "x-align" : "center",
"y-align" : "CLUTTER_BIN_ALIGNMENT_CENTER" "y-align" : "center"
}, },
"children" : [ "children" : [

View File

@ -108,8 +108,8 @@
"layout-manager" : { <co id="script-ui-introduction-json-no-id" /> "layout-manager" : { <co id="script-ui-introduction-json-no-id" />
"type" : "ClutterBinLayout", "type" : "ClutterBinLayout",
"x-align" : "CLUTTER_BIN_ALIGNMENT_CENTER", "x-align" : "center", <co id="script-ui-introduction-json-nickname" />
"y-align" : "CLUTTER_BIN_ALIGNMENT_CENTER" "y-align" : "center"
}, },
"children" : [ <co id="script-ui-introduction-json-child-by-embedding" /> "children" : [ <co id="script-ui-introduction-json-child-by-embedding" />
@ -175,6 +175,29 @@
within the list. The two can be mixed in a single within the list. The two can be mixed in a single
list of <varname>children</varname>.</para> list of <varname>children</varname>.</para>
</callout> </callout>
<callout arearefs="script-ui-introduction-json-nickname">
<para>This uses the nickname for a value in an enumeration
(in this case, the nickname for
<constant>CLUTTER_BIN_ALIGNMENT_CENTER</constant>).</para>
<para>To get the nickname for an enumeration value, take
the component which is unique to that value in the
enumeration, lowercase it, and replace any underscores
with hyphens. Some examples:</para>
<itemizedlist>
<listitem>
<para><constant>CLUTTER_ALIGN_X_AXIS</constant> has
the nickname <code>x-axis</code></para>
</listitem>
<listitem>
<para><constant>CLUTTER_GRAVITY_NORTH</constant> has
the nickname <code>north</code></para>
</listitem>
<listitem>
<para><constant>CLUTTER_REQUEST_HEIGHT_FOR_WIDTH</constant>
has the nickname <code>height-for-width</code></para>
</listitem>
</itemizedlist>
</callout>
</calloutlist> </calloutlist>
</programlistingco> </programlistingco>