mirror of
https://github.com/brl/mutter.git
synced 2024-11-24 00:50:42 -05:00
267 lines
9.0 KiB
XML
267 lines
9.0 KiB
XML
<?xml version='1.0' encoding='UTF-8'?>
|
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
|
|
<!ENTITY appurl "http://www.clutter-project.org">
|
|
<!ENTITY docurl "http://docs.clutter-project.org/docs/clutter-cookbook">
|
|
<!ENTITY license_url "http://creativecommons.org/licenses/by-nc-sa/2.0/uk/">
|
|
<!ENTITY ebassi_mail "ebassi@linux.intel.com">
|
|
<!ENTITY elliot_mail "elliot.smith@intel.com">
|
|
<!ENTITY apiversion "@CLUTTER_API_VERSION@">
|
|
]>
|
|
|
|
<book lang="en"
|
|
xmlns:xi="http://www.w3.org/2003/XInclude">
|
|
<bookinfo>
|
|
<authorgroup>
|
|
<author>
|
|
<firstname>Emmanuele</firstname>
|
|
<surname>Bassi</surname>
|
|
<address><email>&ebassi_mail;</email></address>
|
|
</author>
|
|
<author>
|
|
<firstname>Elliot</firstname>
|
|
<surname>Smith</surname>
|
|
<address><email>&elliot_mail;</email></address>
|
|
</author>
|
|
</authorgroup>
|
|
<copyright>
|
|
<year>2009, 2010, 2011</year>
|
|
<holder>Intel Corporation</holder>
|
|
</copyright>
|
|
<legalnotice>
|
|
<para>Permission is granted to copy, distribute and/or modify this
|
|
document under the terms of the <ulink url="&license_url;">Creative
|
|
Commons Attribution-Non-Commercial-Share Alike 2.0 UK: England &
|
|
Wales</ulink> as published by Creative Commons.</para>
|
|
</legalnotice>
|
|
<title>The Clutter Cookbook</title>
|
|
<releaseinfo>for Clutter &apiversion;</releaseinfo>
|
|
</bookinfo>
|
|
|
|
<xi:include href="introduction.xml" />
|
|
<xi:include href="actors.xml" />
|
|
<xi:include href="events.xml" />
|
|
<xi:include href="textures.xml" />
|
|
<xi:include href="animations.xml" />
|
|
<xi:include href="text.xml" />
|
|
<xi:include href="layouts.xml" />
|
|
<xi:include href="script.xml" />
|
|
<xi:include href="effects.xml" />
|
|
|
|
<appendix id="contributing">
|
|
<title>Contributing to this document</title>
|
|
|
|
<para>This document is written in
|
|
<ulink url="http://docbook.org/">Docbook XML</ulink>. The source files
|
|
for this document are located in the subdirectory
|
|
<filename>doc/cookbook</filename> inside the Clutter source directory.</para>
|
|
|
|
<para>To maintain some degree of consistency, try to stick to the
|
|
following broad guidelines about how to write Docbook for this
|
|
cookbook:</para>
|
|
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>If adding a new recipe, use the
|
|
<filename>recipe-template.xml</filename> XML file as a basis.
|
|
You can find it in the <filename><clutter source>/doc/cookbook/</filename>
|
|
directory.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Try to indent your XML sensibly using 2 spaces per level
|
|
(we're not too strict, but some indentation helps reading
|
|
the source).</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Stick to a column width of around 80 characters.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Use the <filename> element for file
|
|
and directory names.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Use the <property> element for property names
|
|
(e.g. GObject properties).</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Use the <type> element for GObject class
|
|
names.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Use the <constant> element for C defines.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Use the <keycap> element for keys, where
|
|
you are referring to what's actually printed on the key, e.g.
|
|
<keycap>Shift</keycap>. If you're referring to the key some
|
|
other way (e.g. "the Control key"), don't use
|
|
<keycap>.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Use the <function> element for functions;
|
|
the style adopted is to give the function name followed by
|
|
empty brackets, e.g. <function>clutter_actor_set_size()</function>.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>Use the <note> element for asides which might
|
|
otherwise interrupt the flow of the recipe.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>To include a video in a recipe, do the following:</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>Make the video as short as is practical, and only include
|
|
the relevant Clutter window(s).</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>Use Ogg Theora for the encoding.</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>Put the file into the
|
|
<filename><clutter source>/doc/cookbook/videos</filename>
|
|
directory. The name should be in the format
|
|
<filename><section>-<recipe>-<identifier>.ogv</filename>.
|
|
For example: <filename>animations-fading-fade-out.ogv</filename>.</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>Add the name of the file to the <varname></varname>
|
|
in the cookbook's <filename>Makefile.am</filename>, e.g.</para>
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
<![CDATA[
|
|
VIDEO_FILES = \
|
|
videos/animations-fading-fade-out.ogv \
|
|
$(NULL)
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
|
|
<para>This ensures it gets included in the distribution and
|
|
installation.</para>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>Use an <inlinemediaobject> to include it in the
|
|
Docbook recipe file. It should look something like this:</para>
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
<![CDATA[
|
|
<inlinemediaobject>
|
|
<videoobject>
|
|
<videodata fileref="videos/animations-fading-in-then-out.ogv"/>
|
|
</videoobject>
|
|
<alt>
|
|
<para>Video showing an actor fading in then out using
|
|
<type>ClutterState</type></para>
|
|
</alt>
|
|
</inlinemediaobject>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
|
|
<para>The <alt> tag provides the text which
|
|
is presented as a link to the file for users whose browser
|
|
doesn't support HTML 5 embedded video.</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</listitem>
|
|
<listitem>
|
|
<para>To include a full code sample in a recipe (which can
|
|
be compiled into a runnable binary), do the following:</para>
|
|
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>Create a C code file in the
|
|
<filename><clutter source>/doc/cookbook/examples</filename>
|
|
directory. It should be a standalone C application (with
|
|
a <function>main()</function> etc.). The filename should be
|
|
in the format
|
|
<filename><section>-<recipe>.c</filename>; you
|
|
can add an optional identifier to the end if you have more
|
|
than one example for a recipe.</para>
|
|
|
|
<para>If you want to load image files into the application
|
|
(e.g. to demonstrate something with a texture), you can use
|
|
the <constant>TESTS_DATA_DIR</constant> variable in your C
|
|
code to reuse images in the Clutter <filename>tests</filename>
|
|
directory; this will be replaced with
|
|
<filename><clutter source>/tests/data</filename>
|
|
during the build. For example:</para>
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
<![CDATA[
|
|
clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
|
|
TESTS_DATA_DIR "/redhand.png",
|
|
&error);
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>Edit <filename>Makefile.am</filename>
|
|
in the <filename>cookbook/examples</filename> directory
|
|
so that the build recognises the new code; e.g. if
|
|
your C source file were called
|
|
<filename>fooing-barring.c</filename> you would do:</para>
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
<![CDATA[
|
|
noinst_PROGRAMS = \
|
|
textures-reflection \
|
|
text-shadow \
|
|
animations-rotating \
|
|
fooing-barring \
|
|
$(NULL)
|
|
|
|
fooing_barring_SOURCE = fooing-barring.c
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
|
|
<note>
|
|
<para>Note the second line is a new one to tell the
|
|
build where the source file is for your example.</para>
|
|
</note>
|
|
</listitem>
|
|
|
|
<listitem>
|
|
<para>Add a section at the end of your recipe which
|
|
XIncludes the sample code, e.g.:</para>
|
|
|
|
<informalexample>
|
|
<programlisting>
|
|
<![CDATA[
|
|
<section>
|
|
<title>Full example</title>
|
|
|
|
<example id="fooing-barring-example">
|
|
<title>Fooing with a bar</title>
|
|
<programlisting>
|
|
<xi:include href="examples/fooing-barring.c" parse="text">
|
|
<xi:fallback>a code sample should be here... but isn't</xi:fallback>
|
|
</xi:include>
|
|
</programlisting>
|
|
</example>
|
|
</section>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
</listitem>
|
|
</itemizedlist>
|
|
|
|
</appendix>
|
|
|
|
</book>
|