cookbook: Use nicknames for enumeration values
authorElliot Smith <elliot.smith@intel.com>
Fri, 27 Aug 2010 14:29:09 +0000 (15:29 +0100)
committerElliot Smith <elliot.smith@intel.com>
Fri, 27 Aug 2010 14:29:15 +0000 (15:29 +0100)
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.

doc/cookbook/examples/script-ui.json
doc/cookbook/script.xml

index 83b1451..d7b8f9a 100644 (file)
@@ -16,8 +16,8 @@
 
     "layout-manager" : {
       "type" : "ClutterBinLayout",
-      "x-align" : "CLUTTER_BIN_ALIGNMENT_CENTER",
-      "y-align" : "CLUTTER_BIN_ALIGNMENT_CENTER"
+      "x-align" : "center",
+      "y-align" : "center"
     },
 
     "children" : [
index f15d6b8..690f570 100644 (file)
 
     "layout-manager" : {   <co id="script-ui-introduction-json-no-id" />
       "type" : "ClutterBinLayout",
-      "x-align" : "CLUTTER_BIN_ALIGNMENT_CENTER",
-      "y-align" : "CLUTTER_BIN_ALIGNMENT_CENTER"
+      "x-align" : "center",   <co id="script-ui-introduction-json-nickname" />
+      "y-align" : "center"
     },
 
     "children" : [   <co id="script-ui-introduction-json-child-by-embedding" />
               within the list. The two can be mixed in a single
               list of <varname>children</varname>.</para>
             </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>
 
         </programlistingco>