Annotate all examples with their language

The C ones, at least.
This commit is contained in:
Matthias Clasen 2014-02-01 15:11:49 -05:00
parent 701f00f125
commit adf892e96a
49 changed files with 151 additions and 151 deletions

View File

@ -160,7 +160,7 @@ g_action_map_remove_action (GActionMap *action_map,
*
* Each action is constructed as per one #GActionEntry.
*
* |[
* |[<!-- language="C" -->
* static void
* activate_quit (GSimpleAction *simple,
* GVariant *parameter,

View File

@ -47,7 +47,7 @@
*
* A typical implementation might look something like this:
*
* |[
* |[<!-- language="C" -->
* enum {
* NOT_INITIALIZED,
* INITIALIZING,

View File

@ -57,7 +57,7 @@
* however, the "_finish()" function may be called at most once.
*
* Example of a typical asynchronous operation flow:
* |[
* |[<!-- language="C" -->
* void _theoretical_frobnitz_async (Theoretical *t,
* GCancellable *c,
* GAsyncReadyCallback cb,

View File

@ -105,7 +105,7 @@ g_cancellable_class_init (GCancellableClass *klass)
* like this.
*
* An example of how to us this:
* |[
* |[<!-- language="C" -->
* /&ast; Make sure we don't do unnecessary work if already cancelled &ast;/
* if (g_cancellable_set_error_if_cancelled (cancellable, error))
* return;

View File

@ -5794,7 +5794,7 @@ g_dbus_connection_call_sync_internal (GDBusConnection *connection,
*
* If the @parameters #GVariant is floating, it is consumed. This allows
* convenient 'inline' use of g_variant_new(), e.g.:
* |[
* |[<!-- language="C" -->
* g_dbus_connection_call (connection,
* "org.freedesktop.StringThings",
* "/org/freedesktop/StringThings",
@ -5895,7 +5895,7 @@ g_dbus_connection_call_finish (GDBusConnection *connection,
*
* If the @parameters #GVariant is floating, it is consumed.
* This allows convenient 'inline' use of g_variant_new(), e.g.:
* |[
* |[<!-- language="C" -->
* g_dbus_connection_call_sync (connection,
* "org.freedesktop.StringThings",
* "/org/freedesktop/StringThings",

View File

@ -55,7 +55,7 @@
* automatically map from D-Bus errors to #GError and back. This
* is typically done in the function returning the #GQuark for the
* error domain:
* |[
* |[<!-- language="C" -->
* /&ast; foo-bar-error.h: &ast;/
*
* #define FOO_BAR_ERROR (foo_bar_error_quark ())

View File

@ -786,7 +786,7 @@ g_dbus_proxy_get_cached_property (GDBusProxy *proxy,
*
* If the @value #GVariant is floating, it is consumed. This allows
* convenient 'inline' use of g_variant_new(), e.g.
* |[
* |[<!-- language="C" -->
* g_dbus_proxy_set_cached_property (proxy,
* "SomeProperty",
* g_variant_new ("(si)",
@ -2966,7 +2966,7 @@ g_dbus_proxy_call_sync_internal (GDBusProxy *proxy,
*
* If the @parameters #GVariant is floating, it is consumed. This allows
* convenient 'inline' use of g_variant_new(), e.g.:
* |[
* |[<!-- language="C" -->
* g_dbus_proxy_call (proxy,
* "TwoStrings",
* g_variant_new ("(ss)",
@ -3057,7 +3057,7 @@ g_dbus_proxy_call_finish (GDBusProxy *proxy,
*
* If the @parameters #GVariant is floating, it is consumed. This allows
* convenient 'inline' use of g_variant_new(), e.g.:
* |[
* |[<!-- language="C" -->
* g_dbus_proxy_call_sync (proxy,
* "TwoStrings",
* g_variant_new ("(ss)",

View File

@ -603,7 +603,7 @@ g_file_enumerator_get_container (GFileEnumerator *enumerator)
* inside loops with g_file_enumerator_next_file().
*
* This is a convenience method that's equivalent to:
* |[
* |[<!-- language="C" -->
* gchar *name = g_file_info_get_name (info);
* GFile *child = g_file_get_child (g_file_enumerator_get_container (enumr),
* name);

View File

@ -77,7 +77,7 @@
* of an extension point has a name, and a priority. Use
* g_io_extension_point_implement() to implement an extension point.
*
* |[
* |[<!-- language="C" -->
* GIOExtensionPoint *ep;
*
* /&ast; Register an extension point &ast;/
@ -85,7 +85,7 @@
* g_io_extension_point_set_required_type (ep, MY_TYPE_EXAMPLE);
* ]|
*
* |[
* |[<!-- language="C" -->
* /&ast; Implement an extension point &ast;/
* G_DEFINE_TYPE (MyExampleImpl, my_example_impl, MY_TYPE_EXAMPLE);
* g_io_extension_point_implement ("my-extension-point",

View File

@ -367,7 +367,7 @@ g_memory_output_stream_init (GMemoryOutputStream *stream)
* @size as 0 (allowing #GMemoryOutputStream to do the initial
* allocation for itself).
*
* |[
* |[<!-- language="C" -->
* /&ast; a stream that can grow &ast;/
* stream = g_memory_output_stream_new (NULL, 0, realloc, free);
*

View File

@ -52,7 +52,7 @@
*
* Consider the following example:
*
* |[
* |[<!-- language="C" -->
* typedef struct
* {
* ...
@ -109,7 +109,7 @@
* ships a gschemas.compiled file as part of itself, and then simply do
* the following:
*
* |[
* |[<!-- language="C" -->
* {
* GSettings *settings;
* gint some_value;

View File

@ -399,7 +399,7 @@ g_simple_action_class_init (GSimpleActionClass *class)
* call g_simple_action_set_state() from the handler.
*
* An example of a 'change-state' handler:
* |[
* |[<!-- language="C" -->
* static void
* change_volume_state (GSimpleAction *action,
* GVariant *value,

View File

@ -106,7 +106,7 @@
* #GAsyncResult. A typical implementation of an asynchronous operation
* using GSimpleAsyncResult looks something like this:
*
* |[
* |[<!-- language="C" -->
* static void
* baked_cb (Cake *cake,
* gpointer user_data)

View File

@ -32,7 +32,7 @@
* to try out each socket address in turn until one succeeds, as shown
* in the sample code below.
*
* |[
* |[<!-- language="C" -->
* MyConnectionType *
* connect_to_host (const char *hostname,
* guint16 port,

View File

@ -50,7 +50,7 @@
* the return value.
*
* Here is an example for using GTask as a GAsyncResult:
* |[
* |[<!-- language="C" -->
* typedef struct {
* CakeFrostingType frosting;
* char *message;
@ -158,7 +158,7 @@
* and priority).
*
* Here is an example for chained asynchronous operations:
* |[
* |[<!-- language="C" -->
* typedef struct {
* Cake *cake;
* CakeFrostingType frosting;
@ -293,7 +293,7 @@
* #GMainContext when it completes.
*
* Running a task in a thread:
* |[
* |[<!-- language="C" -->
* typedef struct {
* guint radius;
* CakeFlavor flavor;
@ -377,7 +377,7 @@
* synchronous variants of blocking APIs.
*
* Cancelling a task:
* |[
* |[<!-- language="C" -->
* static void
* bake_cake_thread (GTask *task,
* gpointer source_object,

View File

@ -257,7 +257,7 @@ g_themed_icon_class_init (GThemedIconClass *klass)
*
* For example, if the icon name was "gnome-dev-cdrom-audio", the array
* would become
* |[
* |[<!-- language="C" -->
* {
* "gnome-dev-cdrom-audio",
* "gnome-dev-cdrom",
@ -345,7 +345,7 @@ g_themed_icon_new_from_names (char **iconnames,
* that can be created by shortening @iconname at '-' characters.
*
* In the following example, @icon1 and @icon2 are equivalent:
* |[
* |[<!-- language="C" -->
* const char *names[] = {
* "gnome-dev-cdrom-audio",
* "gnome-dev-cdrom",

View File

@ -622,7 +622,7 @@ g_volume_enumerate_identifiers (GVolume *volume)
* either be equal or a prefix of what this function returns. In
* other words, in code
*
* |[
* |[<!-- language="C" -->
* GMount *mount;
* GFile *mount_root
* GFile *volume_activation_root;
@ -632,7 +632,7 @@ g_volume_enumerate_identifiers (GVolume *volume)
* volume_activation_root = g_volume_get_activation_root (volume); /&ast; assume not NULL &ast;/
* ]|
* then the expression
* |[
* |[<!-- language="C" -->
* (g_file_has_prefix (volume_activation_root, mount_root) ||
g_file_equal (volume_activation_root, mount_root))
* ]|

View File

@ -259,7 +259,7 @@
* and conversion specifier and append a conversion specifier.
*
* The following example prints "0x7b";
* |[
* |[<!-- language="C" -->
* gint16 value = 123;
* g_print ("%#" G_GINT16_MODIFIER "x", value);
* ]|
@ -275,7 +275,7 @@
* include the percent-sign, such that you can add precision and length
* modifiers between percent-sign and conversion specifier.
*
* |[
* |[<!-- language="C" -->
* gint16 in;
* gint32 out;
* sscanf ("42", "%" G_GINT16_FORMAT, &in)
@ -721,7 +721,7 @@
* data" to a callback, in the form of a void pointer. From time to time
* you want to pass an integer instead of a pointer. You could allocate
* an integer, with something like:
* |[
* |[<!-- language="C" -->
* int *ip = g_new (int, 1);
* *ip = 42;
* ]|
@ -731,7 +731,7 @@
* Pointers are always at least 32 bits in size (on all platforms GLib
* intends to support). Thus you can store at least 32-bit integer values
* in a pointer value. Naively, you might try this, but it's incorrect:
* |[
* |[<!-- language="C" -->
* gpointer p;
* int i;
* p = (void*) 42;
@ -739,7 +739,7 @@
* ]|
* Again, that example was not correct, don't copy it.
* The problem is that on some systems you need to do this:
* |[
* |[<!-- language="C" -->
* gpointer p;
* int i;
* p = (void*) (long) 42;
@ -1777,14 +1777,14 @@
* Accepts a macro or a string and converts it into a string after
* preprocessor argument expansion. For example, the following code:
*
* |[
* |[<!-- language="C" -->
* #define AGE 27
* const gchar *greeting = G_STRINGIFY (AGE) " today!";
* ]|
*
* is transformed by the preprocessor into (code equivalent to):
*
* |[
* |[<!-- language="C" -->
* const gchar *greeting = "27 today!";
* ]|
*/
@ -1798,7 +1798,7 @@
* @identifier1identifier2 from its expanded
* arguments @identifier1 and @identifier2. For example,
* the following code:
* |[
* |[<!-- language="C" -->
* #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
* const gchar *name = GET (traveller, name);
* const gchar *quest = GET (traveller, quest);
@ -1806,7 +1806,7 @@
* ]|
*
* is transformed by the preprocessor into:
* |[
* |[<!-- language="C" -->
* const gchar *name = traveller_get_name (traveller);
* const gchar *quest = traveller_get_quest (traveller);
* GdkColor *favourite = traveller_get_favourite_colour (traveller);
@ -1846,7 +1846,7 @@
* Its value should be ignored. This can be accomplished by placing
* it as the first argument of a comma expression.
*
* |[
* |[<!-- language="C" -->
* #define ADD_ONE_TO_INT(x) \
* (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
* ]|
@ -2078,7 +2078,7 @@
* semicolon. For arguments, place the attribute at the beginning of the
* argument declaration.
*
* |[
* |[<!-- language="C" -->
* void my_unused_function (G_GNUC_UNUSED gint unused_argument,
* gint other_argument) G_GNUC_UNUSED;
* ]|
@ -2102,7 +2102,7 @@
*
* See the GNU C documentation for more details.
*
* |[
* |[<!-- language="C" -->
* gint g_snprintf (gchar *string,
* gulong n,
* gchar const *format,
@ -2141,7 +2141,7 @@
*
* See the GNU C documentation for more details.
*
* |[
* |[<!-- language="C" -->
* gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
* ]|
*/
@ -2223,7 +2223,7 @@
* function declaration. While GCC allows the macro after the declaration,
* Sun Studio does not.
*
* |[
* |[<!-- language="C" -->
* G_GNUC_INTERNAL
* void _g_log_fallback_handler (const gchar *log_domain,
* GLogLevelFlags log_level,
@ -2253,7 +2253,7 @@
* Hints the compiler that the expression is likely to evaluate to
* a true value. The compiler may use this information for optimizations.
*
* |[
* |[<!-- language="C" -->
* if (G_LIKELY (random () != 1))
* g_print ("not one");
* ]|
@ -2270,7 +2270,7 @@
* Hints the compiler that the expression is unlikely to evaluate to
* a true value. The compiler may use this information for optimizations.
*
* |[
* |[<!-- language="C" -->
* if (G_UNLIKELY (random () == 1))
* g_print ("a random one");
* ]|

View File

@ -68,7 +68,7 @@
* To free an array, use g_array_free().
*
* Here is an example that stores integers in a #GArray:
* |[
* |[<!-- language="C" -->
* GArray *garray;
* gint i;
* /&ast; We create a new array to store gint values.
@ -120,7 +120,7 @@ struct _GRealArray
* value is cast to the given type.
*
* This example gets a pointer to an element in a #GArray:
* |[
* |[<!-- language="C" -->
* EDayViewEvent *event;
* /&ast; This gets a pointer to the 4th element
* &ast; in the array of EDayViewEvent structs.
@ -816,7 +816,7 @@ g_array_maybe_expand (GRealArray *array,
* To free a pointer array, use g_ptr_array_free().
*
* An example using a #GPtrArray:
* |[
* |[<!-- language="C" -->
* GPtrArray *gparray;
* gchar *string1 = "one", *string2 = "two", *string3 = "three";
*
@ -1514,7 +1514,7 @@ g_ptr_array_foreach (GPtrArray *array,
* To free a #GByteArray, use g_byte_array_free().
*
* An example for using a #GByteArray:
* |[
* |[<!-- language="C" -->
* GByteArray *gbarray;
* gint i;
*

View File

@ -726,7 +726,7 @@ g_async_queue_length_unlocked (GAsyncQueue *queue)
*
* If you were sorting a list of priority numbers to make sure the
* lowest priority would be at the top of the queue, you could use:
* |[
* |[<!-- language="C" -->
* gint32 id1;
* gint32 id2;
*

View File

@ -101,7 +101,7 @@ volatile gboolean glib_on_error_halt = TRUE;
* The following example shows how it can be used together with
* the g_log() functions.
*
* |[
* |[<!-- language="C" -->
* #include <glib.h>
*
* static void

View File

@ -161,7 +161,7 @@
* function.
*
* Instead, do the following:
* |[
* |[<!-- language="C" -->
* time_t ttime;
* GTime gtime;
*
@ -1286,7 +1286,7 @@ g_date_set_parse (GDate *d,
* the user's current timezone.
*
* To set the value of a date to the current day, you could write:
* |[
* |[<!-- language="C" -->
* g_date_set_time_t (date, time (NULL));
* ]|
*

View File

@ -53,7 +53,7 @@
*
* Functions that can fail take a return location for a #GError as their
* last argument. For example:
* |[
* |[<!-- language="C" -->
* gboolean g_file_get_contents (const gchar *filename,
* gchar **contents,
* gsize *length,
@ -62,7 +62,7 @@
* If you pass a non-%NULL value for the <literal>error</literal>
* argument, it should point to a location where an error can be placed.
* For example:
* |[
* |[<!-- language="C" -->
* gchar *contents;
* GError *err = NULL;
*
@ -89,7 +89,7 @@
* Because g_file_get_contents() returns %FALSE on failure, if you
* are only interested in whether it failed and don't need to display
* an error message, you can pass %NULL for the @error argument:
* |[
* |[<!-- language="C" -->
* if (g_file_get_contents ("foo.txt", &contents, NULL, NULL)) /&ast; ignore errors &ast;/
* /&ast; no error occurred &ast;/ ;
* else
@ -115,7 +115,7 @@
* want to g_set_error(), then return immediately. g_set_error()
* does nothing if the error location passed to it is %NULL.
* Here's an example:
* |[
* |[<!-- language="C" -->
* gint
* foo_open_file (GError **error)
* {
@ -141,7 +141,7 @@
* function that can report a #GError. If the sub-function indicates
* fatal errors in some way other than reporting a #GError, such as
* by returning %TRUE on success, you can simply do the following:
* |[
* |[<!-- language="C" -->
* gboolean
* my_function_that_can_fail (GError **err)
* {
@ -163,7 +163,7 @@
* reporting a #GError, you need to create a temporary #GError
* since the passed-in one may be %NULL. g_propagate_error() is
* intended for use in this case.
* |[
* |[<!-- language="C" -->
* gboolean
* my_function_that_can_fail (GError **err)
* {
@ -188,7 +188,7 @@
* ]|
*
* Error pileups are always a bug. For example, this code is incorrect:
* |[
* |[<!-- language="C" -->
* gboolean
* my_function_that_can_fail (GError **err)
* {
@ -215,7 +215,7 @@
* of handling an error by always doing nothing about it. So the
* following code is fine, assuming errors in sub_function_that_can_fail()
* are not fatal to my_function_that_can_fail():
* |[
* |[<!-- language="C" -->
* gboolean
* my_function_that_can_fail (GError **err)
* {
@ -246,7 +246,7 @@
*
* - The error domain is called &lt;NAMESPACE&gt;_&lt;MODULE&gt;_ERROR,
* for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
* |[
* |[<!-- language="C" -->
* #define G_SPAWN_ERROR g_spawn_error_quark ()
*
* GQuark

View File

@ -289,7 +289,7 @@ g_mkdir_with_parents (const gchar *pathname,
* For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
* to know whether it is safe to write to a file without being
* tricked into writing into a different location. It doesn't work!
* |[
* |[<!-- language="C" -->
* /&ast; DON'T DO THIS &ast;/
* if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
* {

View File

@ -476,7 +476,7 @@ g_dngettext (const gchar *domain,
* <filename>glib/gi18n.h</filename>. For use in a library, you must include
* <filename>glib/gi18n-lib.h</filename> after defining the %GETTEXT_PACKAGE
* macro suitably for your library:
* |[
* |[<!-- language="C" -->
* #define GETTEXT_PACKAGE "gtk20"
* #include <glib/gi18n-lib.h>
* ]|
@ -542,7 +542,7 @@ g_dngettext (const gchar *domain,
* used as a context. This is mainly useful for short strings which
* may need different translations, depending on the context in which
* they are used.
* |[
* |[<!-- language="C" -->
* label1 = C_("Navigation", "Back");
* label2 = C_("Body part", "Back");
* ]|
@ -564,7 +564,7 @@ g_dngettext (const gchar *domain,
* where the translated strings can't be directly used, e.g. in string
* array initializers. To get the translated string, call gettext()
* at runtime.
* |[
* |[<!-- language="C" -->
* {
* static const char *messages[] = {
* N_("some very meaningful message"),
@ -593,7 +593,7 @@ g_dngettext (const gchar *domain,
* be directly used, e.g. in string array initializers. To get the
* translated string, you should call g_dpgettext2() at runtime.
*
* |[
* |[<!-- language="C" -->
* {
* static const char *messages[] = {
* NC_("some context", "some very meaningful message"),

View File

@ -679,7 +679,7 @@ g_hash_table_new_full (GHashFunc hash_func,
* Initializes a key/value pair iterator and associates it with
* @hash_table. Modifying the hash table after calling this function
* invalidates the returned iterator.
* |[
* |[<!-- language="C" -->
* GHashTableIter iter;
* gpointer key, value;
*

View File

@ -75,7 +75,7 @@
* g_list_insert() and g_list_insert_sorted().
*
* To visit all elements in the list, use a loop over the list:
* |[
* |[<!-- language="C" -->
* GList *l;
* for (l = list; l != NULL; l = l->next)
* {
@ -87,7 +87,7 @@
*
* To loop over the list and modify it (e.g. remove a certain element)
* a while loop is more appropriate, for example:
* |[
* |[<!-- language="C" -->
* GList *l = list;
* while (l != NULL)
* {
@ -236,7 +236,7 @@ g_list_free_full (GList *list,
* to avoid the inefficiency is to use g_list_prepend() and reverse
* the list with g_list_reverse() when all elements have been added.
*
* |[
* |[<!-- language="C" -->
* /&ast; Notice that these are initialized to the empty list. &ast;/
* GList *string_list = NULL, *number_list = NULL;
*
@ -288,7 +288,7 @@ g_list_append (GList *list,
* Note that the return value is the new start of the list,
* which will have changed, so make sure you store the new value.
*
* |[
* |[<!-- language="C" -->
* /&ast; Notice that it is initialized to the empty list. &ast;/
* GList *list = NULL;
*
@ -436,7 +436,7 @@ g_list_insert_before (GList *list,
*
* This function is for example used to move an element in the list.
* The following example moves an element to the top of the list:
* |[
* |[<!-- language="C" -->
* list = g_list_remove_link (list, llink);
* list = g_list_concat (llink, list);
* ]|
@ -578,7 +578,7 @@ g_list_remove_all (GList *list,
* This function is for example used to move an element in the list
* (see the example for g_list_concat()) or to remove an element in
* the list before freeing its data:
* |[
* |[<!-- language="C" -->
* list = g_list_remove_link (list, llink);
* free_some_data_that_may_access_the_list_again (llink->data);
* g_list_free (llink);
@ -650,12 +650,12 @@ g_list_copy (GList *list)
* if the copy function takes only one argument.
*
* For instance, if @list holds a list of GObjects, you can do:
* |[
* |[<!-- language="C" -->
* another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
* ]|
*
* And, to entirely free the new list, you could do:
* |[
* |[<!-- language="C" -->
* g_list_free_full (another_list, g_object_unref);
* ]|
*

View File

@ -2741,7 +2741,7 @@ get_dispatch (void)
* This function is useful in a situation like the following:
* Imagine an extremely simple "garbage collected" system.
*
* |[
* |[<!-- language="C" -->
* static GList *free_list;
*
* gpointer
@ -2778,7 +2778,7 @@ get_dispatch (void)
* doesn't work, since the idle function could be called from a
* recursive callback. This can be fixed by using g_main_depth()
*
* |[
* |[<!-- language="C" -->
* gpointer
* allocate_memory (gsize size)
* {
@ -2867,7 +2867,7 @@ g_main_current_source (void)
* from within idle handlers, but may have freed the object
* before the dispatch of your idle handler.
*
* |[
* |[<!-- language="C" -->
* static gboolean
* idle_callback (gpointer data)
* {
@ -2905,7 +2905,7 @@ g_main_current_source (void)
* this particular problem, is to check to if the source
* has already been destroy within the callback.
*
* |[
* |[<!-- language="C" -->
* static gboolean
* idle_callback (gpointer data)
* {
@ -4321,7 +4321,7 @@ g_main_context_get_poll_func (GMainContext *context)
* Another related use for this function is when implementing a main
* loop with a termination condition, computed from multiple threads:
*
* |[
* |[<!-- language="C" -->
* #define NUM_TASKS 10
* static volatile gint tasks_remaining = NUM_TASKS;
* ...
@ -4331,7 +4331,7 @@ g_main_context_get_poll_func (GMainContext *context)
* ]|
*
* Then in a thread:
* |[
* |[<!-- language="C" -->
* perform_work();
*
* if (g_atomic_int_dec_and_test (&tasks_remaining))

View File

@ -1996,7 +1996,7 @@ g_markup_parse_context_get_user_data (GMarkupParseContext *context)
* As an example, see the following implementation of a simple
* parser that counts the number of tags encountered.
*
* |[
* |[<!-- language="C" -->
* typedef struct
* {
* gint tag_count;
@ -2038,7 +2038,7 @@ g_markup_parse_context_get_user_data (GMarkupParseContext *context)
* In order to allow this parser to be easily used as a subparser, the
* following interface is provided:
*
* |[
* |[<!-- language="C" -->
* void
* start_counting (GMarkupParseContext *context)
* {
@ -2063,7 +2063,7 @@ g_markup_parse_context_get_user_data (GMarkupParseContext *context)
*
* The subparser would then be used as follows:
*
* |[
* |[<!-- language="C" -->
* static void start_element (context, element_name, ...)
* {
* if (strcmp (element_name, "count-these") == 0)
@ -2523,7 +2523,7 @@ g_markup_vprintf_escaped (const gchar *format,
* output, without having to worry that the strings
* might themselves contain markup.
*
* |[
* |[<!-- language="C" -->
* const char *store = "Fortnum & Mason";
* const char *item = "Tea";
* char *output;

View File

@ -538,19 +538,19 @@ g_log_set_fatal_mask (const gchar *log_domain,
*
* Here is an example for adding a log handler for all warning messages
* in the default domain:
* |[
* |[<!-- language="C" -->
* g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
* ]|
*
* This example adds a log handler for all critical messages from GTK+:
* |[
* |[<!-- language="C" -->
* g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
* ]|
*
* This example adds a log handler for all messages from GLib:
* |[
* |[<!-- language="C" -->
* g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
* ]|
@ -1146,7 +1146,7 @@ g_assert_warning (const char *log_domain,
*
* For example:
*
* |[
* |[<!-- language="C" -->
* /&ast; g_main_context_push_thread_default() should fail if the
* &ast; context is already owned by another thread.
* &ast;/

View File

@ -91,7 +91,7 @@
*
* Here is a complete example of setting up GOption to parse the example
* commandline above and produce the example help output.
* |[
* |[<!-- language="C" -->
* static gint repeats = 2;
* static gint max_size = 8;
* static gboolean verbose = FALSE;
@ -150,7 +150,7 @@
* The following example shows how you can use #GOptionContext directly
* in order to correctly deal with Unicode filenames on Windows:
*
* |[
* |[<!-- language="C" -->
* int
* main (int argc, char **argv)
* {

View File

@ -1638,7 +1638,7 @@ g_regex_match_simple (const gchar *pattern,
* To retrieve all the non-overlapping matches of the pattern in
* string you can use g_match_info_next().
*
* |[
* |[<!-- language="C" -->
* static void
* print_uppercase_words (const gchar *string)
* {
@ -1711,7 +1711,7 @@ g_regex_match (const GRegex *regex,
* To retrieve all the non-overlapping matches of the pattern in
* string you can use g_match_info_next().
*
* |[
* |[<!-- language="C" -->
* static void
* print_uppercase_words (const gchar *string)
* {
@ -2834,7 +2834,7 @@ g_regex_replace_literal (const GRegex *regex,
*
* The following example uses g_regex_replace_eval() to replace multiple
* strings at once:
* |[
* |[<!-- language="C" -->
* static gboolean
* eval_cb (const GMatchInfo *info,
* GString *res,

View File

@ -90,7 +90,7 @@
* object size used at allocation time is still available when freeing.
*
* Here is an example for using the slice allocator:
* |[
* |[<!-- language="C" -->
* gchar *mem[10000];
* gint i;
*
@ -111,7 +111,7 @@
*
* And here is an example for using the using the slice allocator
* with data structures:
* |[
* |[<!-- language="C" -->
* GRealArray *array;
*
* /&ast; Allocate one block, using the g_slice_new() macro. &ast;/

View File

@ -191,7 +191,7 @@ g_slist_free_full (GSList *list,
* elements. A common idiom to avoid the inefficiency is to prepend
* the elements and reverse the list when all elements have been added.
*
* |[
* |[<!-- language="C" -->
* /&ast; Notice that these are initialized to the empty list. &ast;/
* GSList *list = NULL, *number_list = NULL;
*
@ -239,7 +239,7 @@ g_slist_append (GSList *list,
* The return value is the new start of the list, which
* may have changed, so make sure you store the new value.
*
* |[
* |[<!-- language="C" -->
* /&ast; Notice that it is initialized to the empty list. &ast;/
* GSList *list = NULL;
* list = g_slist_prepend (list, "last");
@ -584,12 +584,12 @@ g_slist_copy (GSList *list)
* one argument.
*
* For instance, if @list holds a list of GObjects, you can do:
* |[
* |[<!-- language="C" -->
* another_list = g_slist_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
* ]|
*
* And, to entirely free the new list, you could do:
* |[
* |[<!-- language="C" -->
* g_slist_free_full (another_list, g_object_unref);
* ]|
*

View File

@ -266,7 +266,7 @@
* on systems with 64bit IEEE-compatible doubles.
*
* The typical usage would be something like:
* |[
* |[<!-- language="C" -->
* char buf[G_ASCII_DTOSTR_BUF_SIZE];
*
* fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value));
@ -1927,7 +1927,7 @@ g_strncasecmp (const gchar *s1,
* changed to the @new_delimiter character. Modifies @string in place,
* and returns @string itself, not a copy. The return value is to
* allow nesting such as
* |[
* |[<!-- language="C" -->
* g_ascii_strup (g_strdelimit (str, "abc", '?'))
* ]|
*
@ -1964,7 +1964,7 @@ g_strdelimit (gchar *string,
* replaces the character with @substitutor. Modifies @string in place,
* and return @string itself, not a copy. The return value is to allow
* nesting such as
* |[
* |[<!-- language="C" -->
* g_ascii_strup (g_strcanon (str, "abc", '?'))
* ]|
*

View File

@ -82,7 +82,7 @@
*
* The API is designed to handle creation and registration of test suites
* and test cases implicitly. A simple call like
* |[
* |[<!-- language="C" -->
* g_test_add_func ("/misc/assertions", test_assertions);
* ]|
* creates a test suite called "misc" with a single test case named
@ -411,7 +411,7 @@
* The advantage of this macro is that it can produce a message that
* includes the actual values of @s1 and @s2.
*
* |[
* |[<!-- language="C" -->
* g_assert_cmpstr (mystring, ==, "fubar");
* ]|
*
@ -2637,7 +2637,7 @@ wait_for_child (GPid pid,
* The forking parent process then asserts successful child program
* termination and validates child program outputs.
*
* |[
* |[<!-- language="C" -->
* static void
* test_fork_patterns (void)
* {
@ -2753,7 +2753,7 @@ g_test_trap_fork (guint64 usec_timeout,
* <literal>my_object_new(1000000)</literal> will abort with an error
* message.
*
* |[
* |[<!-- language="C" -->
* static void
* test_create_large_object_subprocess (void)
* {

View File

@ -141,7 +141,7 @@ g_mutex_get_impl (GMutex *mutex)
* It is not necessary to initialize a mutex that has been
* statically allocated.
*
* |[
* |[<!-- language="C" -->
* typedef struct {
* GMutex m;
* ...
@ -313,7 +313,7 @@ g_rec_mutex_get_impl (GRecMutex *rec_mutex)
* It is not necessary to initialise a recursive mutex that has been
* statically allocated.
*
* |[
* |[<!-- language="C" -->
* typedef struct {
* GRecMutex m;
* ...
@ -471,7 +471,7 @@ g_rw_lock_get_impl (GRWLock *lock)
* necessary to initialise a reader-writer lock that has been statically
* allocated.
*
* |[
* |[<!-- language="C" -->
* typedef struct {
* GRWLock l;
* ...
@ -807,7 +807,7 @@ g_cond_broadcast (GCond *cond)
* condition variable (extending the example presented in the
* documentation for #GCond):
*
* |[
* |[<!-- language="C" -->
* gpointer
* pop_data_timed (void)
* {
@ -917,7 +917,7 @@ g_cond_wait_until (GCond *cond,
* be properly initialised by default (ie: to all zeros). See the
* examples below.
*
* |[
* |[<!-- language="C" -->
* static GPrivate name_key = G_PRIVATE_INIT (g_free);
*
* /&ast; return value should not be freed &ast;/

View File

@ -158,7 +158,7 @@
* give_me_next_number() example using the #G_LOCK macros:
*
* Here is an example for using the #G_LOCK convenience macros:
* |[
* |[<!-- language="C" -->
* G_LOCK_DEFINE (current_number);
*
* int
@ -227,7 +227,7 @@
* access.
*
* Take for example the following function:
* |[
* |[<!-- language="C" -->
* int
* give_me_next_number (void)
* {
@ -244,7 +244,7 @@
* It is easy to see that this won't work in a multi-threaded
* application. There current_number must be protected against shared
* access. A #GMutex can be used as a solution to this problem:
* |[
* |[<!-- language="C" -->
* int
* give_me_next_number (void)
* {
@ -307,7 +307,7 @@
* g_rw_lock_reader_lock()).
*
* Here is an example for an array with access functions:
* |[
* |[<!-- language="C" -->
* GRWLock lock;
* GPtrArray *array;
*
@ -376,7 +376,7 @@
*
* Here is an example for using GCond to block a thread until a condition
* is satisfied:
* |[
* |[<!-- language="C" -->
* gpointer current_data = NULL;
* GMutex data_mutex;
* GCond data_cond;
@ -519,7 +519,7 @@ G_LOCK_DEFINE_STATIC (g_thread_new);
*
* A #GOnce must be initialized with this macro before it can be used.
*
* |[
* |[<!-- language="C" -->
* GOnce my_once = G_ONCE_INIT;
* ]|
*
@ -559,7 +559,7 @@ G_LOCK_DEFINE_STATIC (g_thread_new);
* Calling g_once() recursively on the same #GOnce struct in
* @func will lead to a deadlock.
*
* |[
* |[<!-- language="C" -->
* gpointer
* get_debug_flags (void)
* {
@ -614,7 +614,7 @@ g_once_impl (GOnce *once,
* blocked until initialization completed. To be used in constructs
* like this:
*
* |[
* |[<!-- language="C" -->
* static gsize initialization_value = 0;
*
* if (g_once_init_enter (&initialization_value))

View File

@ -2480,14 +2480,14 @@ g_variant_new_parsed_va (const gchar *format,
* g_variant_new() would have collected.
*
* Consider this simple example:
* |[
* |[<!-- language="C" -->
* g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
* ]|
*
* In the example, the variable argument parameters are collected and
* filled in as if they were part of the original string to produce the
* result of
* |[
* |[<!-- language="C" -->
* [('one', 1), ('two', 2), ('three', 3)]
* ]|
*
@ -2530,7 +2530,7 @@ g_variant_new_parsed (const gchar *format,
*
* This function might be used as follows:
*
* |[
* |[<!-- language="C" -->
* GVariant *
* make_pointless_dictionary (void)
* {

View File

@ -3068,7 +3068,7 @@ g_variant_iter_free (GVariantIter *iter)
* you no longer need it.
*
* Here is an example for iterating with g_variant_iter_next_value():
* |[
* |[<!-- language="C" -->
* /&ast; recursively iterate a container &ast;/
* void
* iterate_container_recursive (GVariant *container)
@ -4889,7 +4889,7 @@ g_variant_get_va (GVariant *value,
*
* This function might be used as follows:
*
* |[
* |[<!-- language="C" -->
* GVariant *
* make_pointless_dictionary (void)
* {
@ -4981,7 +4981,7 @@ g_variant_get_child (GVariant *value,
* the unpacking process.
*
* Here is an example for memory management with g_variant_iter_next():
* |[
* |[<!-- language="C" -->
* /&ast; Iterates a dictionary of type 'a{sv}' &ast;/
* void
* iterate_dictionary (GVariant *dictionary)
@ -5073,7 +5073,7 @@ g_variant_iter_next (GVariantIter *iter,
* g_variant_get(). Failure to do so will cause a memory leak.
*
* Here is an example for memory management with g_variant_iter_loop():
* |[
* |[<!-- language="C" -->
* /&ast; Iterates a dictionary of type 'a{sv}' &ast;/
* void
* iterate_dictionary (GVariant *dictionary)

View File

@ -80,7 +80,7 @@
* it must ensure that it is never unloaded, by calling g_module_make_resident().
*
* Example: Calling a function defined in a GModule
* |[
* |[<!-- language="C" -->
* /&ast; the function signature for 'say_hello' &ast;/
* typedef void (* SayHelloFunc) (const char *message);
*

View File

@ -29,7 +29,7 @@
* value is applied to the target property; for instance, the following
* binding:
*
* |[
* |[<!-- language="C" -->
* g_object_bind_property (object1, "property-a",
* object2, "property-b",
* G_BINDING_DEFAULT);
@ -43,7 +43,7 @@
* of two #GObject instances, so that if either property changes, the
* other is updated as well, for instance:
*
* |[
* |[<!-- language="C" -->
* g_object_bind_property (object1, "property-a",
* object2, "property-b",
* G_BINDING_BIDIRECTIONAL);
@ -56,7 +56,7 @@
* transformation from the source value to the target value before
* applying it; for instance, the following binding:
*
* |[
* |[<!-- language="C" -->
* g_object_bind_property_full (adjustment1, "value",
* adjustment2, "value",
* G_BINDING_BIDIRECTIONAL,

View File

@ -151,7 +151,7 @@ enum {
* part as a #GClosure. This function is mainly useful when
* implementing new types of closures.
*
* |[
* |[<!-- language="C" -->
* typedef struct _MyClosure MyClosure;
* struct _MyClosure
* {
@ -608,20 +608,20 @@ g_closure_unref (GClosure *closure)
* count. If the closure is not floating, g_closure_sink() does
* nothing. The reason for the existence of the floating state is to
* prevent cumbersome code sequences like:
* |[
* |[<!-- language="C" -->
* closure = g_cclosure_new (cb_func, cb_data);
* g_source_set_closure (source, closure);
* g_closure_unref (closure); /&ast; GObject doesn't really need this &ast;/
* ]|
* Because g_source_set_closure() (and similar functions) take ownership of the
* initial reference count, if it is unowned, we instead can write:
* |[
* |[<!-- language="C" -->
* g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
* ]|
*
* Generally, this function is used together with g_closure_ref(). Ane example
* of storing a closure for later notification looks like:
* |[
* |[<!-- language="C" -->
* static GClosure *notify_closure = NULL;
* void
* foo_notify_set_closure (GClosure *closure)

View File

@ -262,7 +262,7 @@ g_flags_register_static (const gchar *name,
* function of a #GTypePlugin implementation, as in the following
* example:
*
* |[
* |[<!-- language="C" -->
* static void
* my_enum_complete_type_info (GTypePlugin *plugin,
* GType g_type,

View File

@ -53,7 +53,7 @@
* This means that it is not specifically claimed to be "owned" by
* any code portion. The main motivation for providing floating references is
* C convenience. In particular, it allows code to be written as:
* |[
* |[<!-- language="C" -->
* container = create_container ();
* container_add_child (container, create_child());
* ]|
@ -62,7 +62,7 @@
* references, container_add_child() can only g_object_ref() the new child,
* so to implement this code without reference leaks, it would have to be
* written as:
* |[
* |[<!-- language="C" -->
* Child *child;
* container = create_container ();
* child = create_child ();
@ -84,7 +84,7 @@
* across certain code portions (an example is #GtkMenu), to achieve this,
* the following sequence can be used:
*
* |[
* |[<!-- language="C" -->
* /&ast; save floating state &ast;/
* gboolean was_floating = g_object_is_floating (object);
* g_object_ref_sink (object);
@ -473,7 +473,7 @@ g_object_do_class_init (GObjectClass *class)
* This signal is typically used to obtain change notification for a
* single property, by specifying the property name as a detail in the
* g_signal_connect() call, like this:
* |[
* |[<!-- language="C" -->
* g_signal_connect (text_view->buffer, "notify::paste-target-list",
* G_CALLBACK (gtk_text_view_target_list_notify),
* text_view)
@ -589,7 +589,7 @@ g_object_class_install_property (GObjectClass *class,
* #GParamSpecs and g_object_notify_by_pspec(). For instance, this
* class initialization:
*
* |[
* |[<!-- language="C" -->
* enum {
* PROP_0, PROP_FOO, PROP_BAR, N_PROPERTIES
* };
@ -622,7 +622,7 @@ g_object_class_install_property (GObjectClass *class,
*
* allows calling g_object_notify_by_pspec() to notify of property changes:
*
* |[
* |[<!-- language="C" -->
* void
* my_object_set_foo (MyObject *self, gint foo)
* {
@ -1209,7 +1209,7 @@ g_object_notify (GObject *object,
* instead, is to store the GParamSpec used with
* g_object_class_install_property() inside a static array, e.g.:
*
*|[
*|[<!-- language="C" -->
* enum
* {
* PROP_0,
@ -1234,7 +1234,7 @@ g_object_notify (GObject *object,
*
* and then notify a change on the "foo" property with:
*
* |[
* |[<!-- language="C" -->
* g_object_notify_by_pspec (self, properties[PROP_FOO]);
* ]|
*
@ -2229,7 +2229,7 @@ g_object_set (gpointer _object,
*
* Here is an example of using g_object_get() to get the contents
* of three properties: an integer, a string and an object:
* |[
* |[<!-- language="C" -->
* gint intval;
* gchar *strval;
* GObject *objval;
@ -2408,7 +2408,7 @@ g_object_get_property (GObject *object,
* - swapped_signal_after, swapped-signal-after: equivalent to g_signal_connect_data (..., NULL, G_CONNECT_SWAPPED | G_CONNECT_AFTER)
* - swapped_object_signal_after, swapped-object-signal-after: equivalent to g_signal_connect_object (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)
*
* |[
* |[<!-- language="C" -->
* menu->toplevel = g_object_connect (g_object_new (GTK_TYPE_WINDOW,
* "type", GTK_WINDOW_POPUP,
* "child", menu,
@ -3324,7 +3324,7 @@ g_object_set_qdata_full (GObject *object,
* set).
* Usually, calling this function is only required to update
* user data pointers with a destroy notifier, for example:
* |[
* |[<!-- language="C" -->
* void
* object_add_to_user_list (GObject *object,
* const gchar *new_string)

View File

@ -4425,7 +4425,7 @@ gobject_init_ctor (void)
* Note the use of a structure member "priv" to avoid the overhead
* of repeatedly calling MY_OBJECT_GET_PRIVATE().
*
* |[
* |[<!-- language="C" -->
* typedef struct _MyObject MyObject;
* typedef struct _MyObjectPrivate MyObjectPrivate;
*

View File

@ -33,7 +33,7 @@
* 1. The type is initially introduced (usually upon loading the module
* the first time, or by your main application that knows what modules
* introduces what types), like this:
* |[
* |[<!-- language="C" -->
* new_type_id = g_type_register_dynamic (parent_type_id,
* "TypeName",
* new_type_plugin,

View File

@ -55,7 +55,7 @@
* The code in the example program below demonstrates #GValue's
* features.
*
* |[
* |[<!-- language="C" -->
* #include <glib-object.h>
*
* static void

View File

@ -45,13 +45,13 @@
* g_value_unset() as the clear function using g_array_set_clear_func(),
* for instance, the following code:
*
* |[
* |[<!-- language="C" -->
* GValueArray *array = g_value_array_new (10);
* ]|
*
* can be replaced by:
*
* |[
* |[<!-- language="C" -->
* GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10);
* g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
* ]|