diff --git a/doc/cookbook/clutter-cookbook.xml.in b/doc/cookbook/clutter-cookbook.xml.in index 761661d11..6f4b476d1 100644 --- a/doc/cookbook/clutter-cookbook.xml.in +++ b/doc/cookbook/clutter-cookbook.xml.in @@ -168,6 +168,101 @@ VIDEO_FILES = \ + + To include a full code sample in a recipe (which can + be compiled into a runnable binary), do the following: + + + + Create a C code file in the + <clutter source>/doc/cookbook/examples + directory. It should be a standalone C application (with + a main() etc.). The filename should be + in the format + <section>-<recipe>.c; you + can add an optional identifier to the end if you have more + than one example for a recipe. + + If you want to load image files into the application + (e.g. to demonstrate something with a texture), you can use + the TESTS_DATA_DIR variable in your C + code to reuse images in the Clutter tests + directory; this will be replaced with + <clutter source>/tests/data + during the build. For example: + + + + + + + + + + Edit Makefile.am + in the cookbook/examples directory + so that the build recognises the new code; e.g. if + your C source file were called + fooing-barring.c you would do: + + + + + + + + + Note the second line is a new one to tell the + build where the source file is for your example. + + + + + Add a section at the end of your recipe which + XIncludes the sample code, e.g.: + + + + + Full example + + + Fooing with a bar + + + a code sample should be here... but isn't + + + + +]]> + + + + + The <xi:include> element + should be aligned to the left-hand margin of the text + (no whitespace on the line before it), to prevent any + stray whitespace appearing in the program listing. + + + + +