mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 17:26:17 +01:00
Annotate all examples with their language
The C ones, at least.
This commit is contained in:
parent
701f00f125
commit
adf892e96a
@ -160,7 +160,7 @@ g_action_map_remove_action (GActionMap *action_map,
|
|||||||
*
|
*
|
||||||
* Each action is constructed as per one #GActionEntry.
|
* Each action is constructed as per one #GActionEntry.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* activate_quit (GSimpleAction *simple,
|
* activate_quit (GSimpleAction *simple,
|
||||||
* GVariant *parameter,
|
* GVariant *parameter,
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
*
|
*
|
||||||
* A typical implementation might look something like this:
|
* A typical implementation might look something like this:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* enum {
|
* enum {
|
||||||
* NOT_INITIALIZED,
|
* NOT_INITIALIZED,
|
||||||
* INITIALIZING,
|
* INITIALIZING,
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
* however, the "_finish()" function may be called at most once.
|
* however, the "_finish()" function may be called at most once.
|
||||||
*
|
*
|
||||||
* Example of a typical asynchronous operation flow:
|
* Example of a typical asynchronous operation flow:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* void _theoretical_frobnitz_async (Theoretical *t,
|
* void _theoretical_frobnitz_async (Theoretical *t,
|
||||||
* GCancellable *c,
|
* GCancellable *c,
|
||||||
* GAsyncReadyCallback cb,
|
* GAsyncReadyCallback cb,
|
||||||
|
@ -105,7 +105,7 @@ g_cancellable_class_init (GCancellableClass *klass)
|
|||||||
* like this.
|
* like this.
|
||||||
*
|
*
|
||||||
* An example of how to us this:
|
* An example of how to us this:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Make sure we don't do unnecessary work if already cancelled */
|
* /* Make sure we don't do unnecessary work if already cancelled */
|
||||||
* if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
* if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||||
* return;
|
* return;
|
||||||
|
@ -5794,7 +5794,7 @@ g_dbus_connection_call_sync_internal (GDBusConnection *connection,
|
|||||||
*
|
*
|
||||||
* If the @parameters #GVariant is floating, it is consumed. This allows
|
* If the @parameters #GVariant is floating, it is consumed. This allows
|
||||||
* convenient 'inline' use of g_variant_new(), e.g.:
|
* convenient 'inline' use of g_variant_new(), e.g.:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_dbus_connection_call (connection,
|
* g_dbus_connection_call (connection,
|
||||||
* "org.freedesktop.StringThings",
|
* "org.freedesktop.StringThings",
|
||||||
* "/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.
|
* If the @parameters #GVariant is floating, it is consumed.
|
||||||
* This allows convenient 'inline' use of g_variant_new(), e.g.:
|
* This allows convenient 'inline' use of g_variant_new(), e.g.:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_dbus_connection_call_sync (connection,
|
* g_dbus_connection_call_sync (connection,
|
||||||
* "org.freedesktop.StringThings",
|
* "org.freedesktop.StringThings",
|
||||||
* "/org/freedesktop/StringThings",
|
* "/org/freedesktop/StringThings",
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
* automatically map from D-Bus errors to #GError and back. This
|
* automatically map from D-Bus errors to #GError and back. This
|
||||||
* is typically done in the function returning the #GQuark for the
|
* is typically done in the function returning the #GQuark for the
|
||||||
* error domain:
|
* error domain:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* foo-bar-error.h: */
|
* /* foo-bar-error.h: */
|
||||||
*
|
*
|
||||||
* #define FOO_BAR_ERROR (foo_bar_error_quark ())
|
* #define FOO_BAR_ERROR (foo_bar_error_quark ())
|
||||||
|
@ -786,7 +786,7 @@ g_dbus_proxy_get_cached_property (GDBusProxy *proxy,
|
|||||||
*
|
*
|
||||||
* If the @value #GVariant is floating, it is consumed. This allows
|
* If the @value #GVariant is floating, it is consumed. This allows
|
||||||
* convenient 'inline' use of g_variant_new(), e.g.
|
* convenient 'inline' use of g_variant_new(), e.g.
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_dbus_proxy_set_cached_property (proxy,
|
* g_dbus_proxy_set_cached_property (proxy,
|
||||||
* "SomeProperty",
|
* "SomeProperty",
|
||||||
* g_variant_new ("(si)",
|
* 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
|
* If the @parameters #GVariant is floating, it is consumed. This allows
|
||||||
* convenient 'inline' use of g_variant_new(), e.g.:
|
* convenient 'inline' use of g_variant_new(), e.g.:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_dbus_proxy_call (proxy,
|
* g_dbus_proxy_call (proxy,
|
||||||
* "TwoStrings",
|
* "TwoStrings",
|
||||||
* g_variant_new ("(ss)",
|
* 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
|
* If the @parameters #GVariant is floating, it is consumed. This allows
|
||||||
* convenient 'inline' use of g_variant_new(), e.g.:
|
* convenient 'inline' use of g_variant_new(), e.g.:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_dbus_proxy_call_sync (proxy,
|
* g_dbus_proxy_call_sync (proxy,
|
||||||
* "TwoStrings",
|
* "TwoStrings",
|
||||||
* g_variant_new ("(ss)",
|
* g_variant_new ("(ss)",
|
||||||
|
@ -603,7 +603,7 @@ g_file_enumerator_get_container (GFileEnumerator *enumerator)
|
|||||||
* inside loops with g_file_enumerator_next_file().
|
* inside loops with g_file_enumerator_next_file().
|
||||||
*
|
*
|
||||||
* This is a convenience method that's equivalent to:
|
* This is a convenience method that's equivalent to:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gchar *name = g_file_info_get_name (info);
|
* gchar *name = g_file_info_get_name (info);
|
||||||
* GFile *child = g_file_get_child (g_file_enumerator_get_container (enumr),
|
* GFile *child = g_file_get_child (g_file_enumerator_get_container (enumr),
|
||||||
* name);
|
* name);
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
* of an extension point has a name, and a priority. Use
|
* of an extension point has a name, and a priority. Use
|
||||||
* g_io_extension_point_implement() to implement an extension point.
|
* g_io_extension_point_implement() to implement an extension point.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GIOExtensionPoint *ep;
|
* GIOExtensionPoint *ep;
|
||||||
*
|
*
|
||||||
* /* Register an extension point */
|
* /* Register an extension point */
|
||||||
@ -85,7 +85,7 @@
|
|||||||
* g_io_extension_point_set_required_type (ep, MY_TYPE_EXAMPLE);
|
* g_io_extension_point_set_required_type (ep, MY_TYPE_EXAMPLE);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Implement an extension point */
|
* /* Implement an extension point */
|
||||||
* G_DEFINE_TYPE (MyExampleImpl, my_example_impl, MY_TYPE_EXAMPLE);
|
* G_DEFINE_TYPE (MyExampleImpl, my_example_impl, MY_TYPE_EXAMPLE);
|
||||||
* g_io_extension_point_implement ("my-extension-point",
|
* g_io_extension_point_implement ("my-extension-point",
|
||||||
|
@ -367,7 +367,7 @@ g_memory_output_stream_init (GMemoryOutputStream *stream)
|
|||||||
* @size as 0 (allowing #GMemoryOutputStream to do the initial
|
* @size as 0 (allowing #GMemoryOutputStream to do the initial
|
||||||
* allocation for itself).
|
* allocation for itself).
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* a stream that can grow */
|
* /* a stream that can grow */
|
||||||
* stream = g_memory_output_stream_new (NULL, 0, realloc, free);
|
* stream = g_memory_output_stream_new (NULL, 0, realloc, free);
|
||||||
*
|
*
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
*
|
*
|
||||||
* Consider the following example:
|
* Consider the following example:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct
|
* typedef struct
|
||||||
* {
|
* {
|
||||||
* ...
|
* ...
|
||||||
@ -109,7 +109,7 @@
|
|||||||
* ships a gschemas.compiled file as part of itself, and then simply do
|
* ships a gschemas.compiled file as part of itself, and then simply do
|
||||||
* the following:
|
* the following:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* {
|
* {
|
||||||
* GSettings *settings;
|
* GSettings *settings;
|
||||||
* gint some_value;
|
* gint some_value;
|
||||||
|
@ -399,7 +399,7 @@ g_simple_action_class_init (GSimpleActionClass *class)
|
|||||||
* call g_simple_action_set_state() from the handler.
|
* call g_simple_action_set_state() from the handler.
|
||||||
*
|
*
|
||||||
* An example of a 'change-state' handler:
|
* An example of a 'change-state' handler:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* change_volume_state (GSimpleAction *action,
|
* change_volume_state (GSimpleAction *action,
|
||||||
* GVariant *value,
|
* GVariant *value,
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
* #GAsyncResult. A typical implementation of an asynchronous operation
|
* #GAsyncResult. A typical implementation of an asynchronous operation
|
||||||
* using GSimpleAsyncResult looks something like this:
|
* using GSimpleAsyncResult looks something like this:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* baked_cb (Cake *cake,
|
* baked_cb (Cake *cake,
|
||||||
* gpointer user_data)
|
* gpointer user_data)
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
* to try out each socket address in turn until one succeeds, as shown
|
* to try out each socket address in turn until one succeeds, as shown
|
||||||
* in the sample code below.
|
* in the sample code below.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* MyConnectionType *
|
* MyConnectionType *
|
||||||
* connect_to_host (const char *hostname,
|
* connect_to_host (const char *hostname,
|
||||||
* guint16 port,
|
* guint16 port,
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
* the return value.
|
* the return value.
|
||||||
*
|
*
|
||||||
* Here is an example for using GTask as a GAsyncResult:
|
* Here is an example for using GTask as a GAsyncResult:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct {
|
* typedef struct {
|
||||||
* CakeFrostingType frosting;
|
* CakeFrostingType frosting;
|
||||||
* char *message;
|
* char *message;
|
||||||
@ -158,7 +158,7 @@
|
|||||||
* and priority).
|
* and priority).
|
||||||
*
|
*
|
||||||
* Here is an example for chained asynchronous operations:
|
* Here is an example for chained asynchronous operations:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct {
|
* typedef struct {
|
||||||
* Cake *cake;
|
* Cake *cake;
|
||||||
* CakeFrostingType frosting;
|
* CakeFrostingType frosting;
|
||||||
@ -293,7 +293,7 @@
|
|||||||
* #GMainContext when it completes.
|
* #GMainContext when it completes.
|
||||||
*
|
*
|
||||||
* Running a task in a thread:
|
* Running a task in a thread:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct {
|
* typedef struct {
|
||||||
* guint radius;
|
* guint radius;
|
||||||
* CakeFlavor flavor;
|
* CakeFlavor flavor;
|
||||||
@ -377,7 +377,7 @@
|
|||||||
* synchronous variants of blocking APIs.
|
* synchronous variants of blocking APIs.
|
||||||
*
|
*
|
||||||
* Cancelling a task:
|
* Cancelling a task:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* bake_cake_thread (GTask *task,
|
* bake_cake_thread (GTask *task,
|
||||||
* gpointer source_object,
|
* gpointer source_object,
|
||||||
|
@ -257,7 +257,7 @@ g_themed_icon_class_init (GThemedIconClass *klass)
|
|||||||
*
|
*
|
||||||
* For example, if the icon name was "gnome-dev-cdrom-audio", the array
|
* For example, if the icon name was "gnome-dev-cdrom-audio", the array
|
||||||
* would become
|
* would become
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* {
|
* {
|
||||||
* "gnome-dev-cdrom-audio",
|
* "gnome-dev-cdrom-audio",
|
||||||
* "gnome-dev-cdrom",
|
* "gnome-dev-cdrom",
|
||||||
@ -345,7 +345,7 @@ g_themed_icon_new_from_names (char **iconnames,
|
|||||||
* that can be created by shortening @iconname at '-' characters.
|
* that can be created by shortening @iconname at '-' characters.
|
||||||
*
|
*
|
||||||
* In the following example, @icon1 and @icon2 are equivalent:
|
* In the following example, @icon1 and @icon2 are equivalent:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* const char *names[] = {
|
* const char *names[] = {
|
||||||
* "gnome-dev-cdrom-audio",
|
* "gnome-dev-cdrom-audio",
|
||||||
* "gnome-dev-cdrom",
|
* "gnome-dev-cdrom",
|
||||||
|
@ -622,7 +622,7 @@ g_volume_enumerate_identifiers (GVolume *volume)
|
|||||||
* either be equal or a prefix of what this function returns. In
|
* either be equal or a prefix of what this function returns. In
|
||||||
* other words, in code
|
* other words, in code
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GMount *mount;
|
* GMount *mount;
|
||||||
* GFile *mount_root
|
* GFile *mount_root
|
||||||
* GFile *volume_activation_root;
|
* GFile *volume_activation_root;
|
||||||
@ -632,7 +632,7 @@ g_volume_enumerate_identifiers (GVolume *volume)
|
|||||||
* volume_activation_root = g_volume_get_activation_root (volume); /* assume not NULL */
|
* volume_activation_root = g_volume_get_activation_root (volume); /* assume not NULL */
|
||||||
* ]|
|
* ]|
|
||||||
* then the expression
|
* then the expression
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* (g_file_has_prefix (volume_activation_root, mount_root) ||
|
* (g_file_has_prefix (volume_activation_root, mount_root) ||
|
||||||
g_file_equal (volume_activation_root, mount_root))
|
g_file_equal (volume_activation_root, mount_root))
|
||||||
* ]|
|
* ]|
|
||||||
|
32
glib/docs.c
32
glib/docs.c
@ -259,7 +259,7 @@
|
|||||||
* and conversion specifier and append a conversion specifier.
|
* and conversion specifier and append a conversion specifier.
|
||||||
*
|
*
|
||||||
* The following example prints "0x7b";
|
* The following example prints "0x7b";
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gint16 value = 123;
|
* gint16 value = 123;
|
||||||
* g_print ("%#" G_GINT16_MODIFIER "x", value);
|
* g_print ("%#" G_GINT16_MODIFIER "x", value);
|
||||||
* ]|
|
* ]|
|
||||||
@ -275,7 +275,7 @@
|
|||||||
* include the percent-sign, such that you can add precision and length
|
* include the percent-sign, such that you can add precision and length
|
||||||
* modifiers between percent-sign and conversion specifier.
|
* modifiers between percent-sign and conversion specifier.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gint16 in;
|
* gint16 in;
|
||||||
* gint32 out;
|
* gint32 out;
|
||||||
* sscanf ("42", "%" G_GINT16_FORMAT, &in)
|
* 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
|
* 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
|
* you want to pass an integer instead of a pointer. You could allocate
|
||||||
* an integer, with something like:
|
* an integer, with something like:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* int *ip = g_new (int, 1);
|
* int *ip = g_new (int, 1);
|
||||||
* *ip = 42;
|
* *ip = 42;
|
||||||
* ]|
|
* ]|
|
||||||
@ -731,7 +731,7 @@
|
|||||||
* Pointers are always at least 32 bits in size (on all platforms GLib
|
* 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
|
* 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:
|
* in a pointer value. Naively, you might try this, but it's incorrect:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gpointer p;
|
* gpointer p;
|
||||||
* int i;
|
* int i;
|
||||||
* p = (void*) 42;
|
* p = (void*) 42;
|
||||||
@ -739,7 +739,7 @@
|
|||||||
* ]|
|
* ]|
|
||||||
* Again, that example was not correct, don't copy it.
|
* Again, that example was not correct, don't copy it.
|
||||||
* The problem is that on some systems you need to do this:
|
* The problem is that on some systems you need to do this:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gpointer p;
|
* gpointer p;
|
||||||
* int i;
|
* int i;
|
||||||
* p = (void*) (long) 42;
|
* p = (void*) (long) 42;
|
||||||
@ -1777,14 +1777,14 @@
|
|||||||
* Accepts a macro or a string and converts it into a string after
|
* Accepts a macro or a string and converts it into a string after
|
||||||
* preprocessor argument expansion. For example, the following code:
|
* preprocessor argument expansion. For example, the following code:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #define AGE 27
|
* #define AGE 27
|
||||||
* const gchar *greeting = G_STRINGIFY (AGE) " today!";
|
* const gchar *greeting = G_STRINGIFY (AGE) " today!";
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* is transformed by the preprocessor into (code equivalent to):
|
* is transformed by the preprocessor into (code equivalent to):
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* const gchar *greeting = "27 today!";
|
* const gchar *greeting = "27 today!";
|
||||||
* ]|
|
* ]|
|
||||||
*/
|
*/
|
||||||
@ -1798,7 +1798,7 @@
|
|||||||
* @identifier1identifier2 from its expanded
|
* @identifier1identifier2 from its expanded
|
||||||
* arguments @identifier1 and @identifier2. For example,
|
* arguments @identifier1 and @identifier2. For example,
|
||||||
* the following code:
|
* the following code:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
|
* #define GET(traveller,method) G_PASTE(traveller_get_, method) (traveller)
|
||||||
* const gchar *name = GET (traveller, name);
|
* const gchar *name = GET (traveller, name);
|
||||||
* const gchar *quest = GET (traveller, quest);
|
* const gchar *quest = GET (traveller, quest);
|
||||||
@ -1806,7 +1806,7 @@
|
|||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* is transformed by the preprocessor into:
|
* is transformed by the preprocessor into:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* const gchar *name = traveller_get_name (traveller);
|
* const gchar *name = traveller_get_name (traveller);
|
||||||
* const gchar *quest = traveller_get_quest (traveller);
|
* const gchar *quest = traveller_get_quest (traveller);
|
||||||
* GdkColor *favourite = traveller_get_favourite_colour (traveller);
|
* GdkColor *favourite = traveller_get_favourite_colour (traveller);
|
||||||
@ -1846,7 +1846,7 @@
|
|||||||
* Its value should be ignored. This can be accomplished by placing
|
* Its value should be ignored. This can be accomplished by placing
|
||||||
* it as the first argument of a comma expression.
|
* it as the first argument of a comma expression.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #define ADD_ONE_TO_INT(x) \
|
* #define ADD_ONE_TO_INT(x) \
|
||||||
* (G_STATIC_ASSERT_EXPR(sizeof (x) == sizeof (int)), ((x) + 1))
|
* (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
|
* semicolon. For arguments, place the attribute at the beginning of the
|
||||||
* argument declaration.
|
* argument declaration.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* void my_unused_function (G_GNUC_UNUSED gint unused_argument,
|
* void my_unused_function (G_GNUC_UNUSED gint unused_argument,
|
||||||
* gint other_argument) G_GNUC_UNUSED;
|
* gint other_argument) G_GNUC_UNUSED;
|
||||||
* ]|
|
* ]|
|
||||||
@ -2102,7 +2102,7 @@
|
|||||||
*
|
*
|
||||||
* See the GNU C documentation for more details.
|
* See the GNU C documentation for more details.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gint g_snprintf (gchar *string,
|
* gint g_snprintf (gchar *string,
|
||||||
* gulong n,
|
* gulong n,
|
||||||
* gchar const *format,
|
* gchar const *format,
|
||||||
@ -2141,7 +2141,7 @@
|
|||||||
*
|
*
|
||||||
* See the GNU C documentation for more details.
|
* See the GNU C documentation for more details.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);
|
* 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,
|
* function declaration. While GCC allows the macro after the declaration,
|
||||||
* Sun Studio does not.
|
* Sun Studio does not.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* G_GNUC_INTERNAL
|
* G_GNUC_INTERNAL
|
||||||
* void _g_log_fallback_handler (const gchar *log_domain,
|
* void _g_log_fallback_handler (const gchar *log_domain,
|
||||||
* GLogLevelFlags log_level,
|
* GLogLevelFlags log_level,
|
||||||
@ -2253,7 +2253,7 @@
|
|||||||
* Hints the compiler that the expression is likely to evaluate to
|
* Hints the compiler that the expression is likely to evaluate to
|
||||||
* a true value. The compiler may use this information for optimizations.
|
* a true value. The compiler may use this information for optimizations.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* if (G_LIKELY (random () != 1))
|
* if (G_LIKELY (random () != 1))
|
||||||
* g_print ("not one");
|
* g_print ("not one");
|
||||||
* ]|
|
* ]|
|
||||||
@ -2270,7 +2270,7 @@
|
|||||||
* Hints the compiler that the expression is unlikely to evaluate to
|
* Hints the compiler that the expression is unlikely to evaluate to
|
||||||
* a true value. The compiler may use this information for optimizations.
|
* a true value. The compiler may use this information for optimizations.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* if (G_UNLIKELY (random () == 1))
|
* if (G_UNLIKELY (random () == 1))
|
||||||
* g_print ("a random one");
|
* g_print ("a random one");
|
||||||
* ]|
|
* ]|
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
* To free an array, use g_array_free().
|
* To free an array, use g_array_free().
|
||||||
*
|
*
|
||||||
* Here is an example that stores integers in a #GArray:
|
* Here is an example that stores integers in a #GArray:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GArray *garray;
|
* GArray *garray;
|
||||||
* gint i;
|
* gint i;
|
||||||
* /* We create a new array to store gint values.
|
* /* We create a new array to store gint values.
|
||||||
@ -120,7 +120,7 @@ struct _GRealArray
|
|||||||
* value is cast to the given type.
|
* value is cast to the given type.
|
||||||
*
|
*
|
||||||
* This example gets a pointer to an element in a #GArray:
|
* This example gets a pointer to an element in a #GArray:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* EDayViewEvent *event;
|
* EDayViewEvent *event;
|
||||||
* /* This gets a pointer to the 4th element
|
* /* This gets a pointer to the 4th element
|
||||||
* * in the array of EDayViewEvent structs.
|
* * 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().
|
* To free a pointer array, use g_ptr_array_free().
|
||||||
*
|
*
|
||||||
* An example using a #GPtrArray:
|
* An example using a #GPtrArray:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GPtrArray *gparray;
|
* GPtrArray *gparray;
|
||||||
* gchar *string1 = "one", *string2 = "two", *string3 = "three";
|
* 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().
|
* To free a #GByteArray, use g_byte_array_free().
|
||||||
*
|
*
|
||||||
* An example for using a #GByteArray:
|
* An example for using a #GByteArray:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GByteArray *gbarray;
|
* GByteArray *gbarray;
|
||||||
* gint i;
|
* gint i;
|
||||||
*
|
*
|
||||||
|
@ -726,7 +726,7 @@ g_async_queue_length_unlocked (GAsyncQueue *queue)
|
|||||||
*
|
*
|
||||||
* If you were sorting a list of priority numbers to make sure the
|
* 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:
|
* lowest priority would be at the top of the queue, you could use:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gint32 id1;
|
* gint32 id1;
|
||||||
* gint32 id2;
|
* gint32 id2;
|
||||||
*
|
*
|
||||||
|
@ -101,7 +101,7 @@ volatile gboolean glib_on_error_halt = TRUE;
|
|||||||
* The following example shows how it can be used together with
|
* The following example shows how it can be used together with
|
||||||
* the g_log() functions.
|
* the g_log() functions.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #include <glib.h>
|
* #include <glib.h>
|
||||||
*
|
*
|
||||||
* static void
|
* static void
|
||||||
|
@ -161,7 +161,7 @@
|
|||||||
* function.
|
* function.
|
||||||
*
|
*
|
||||||
* Instead, do the following:
|
* Instead, do the following:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* time_t ttime;
|
* time_t ttime;
|
||||||
* GTime gtime;
|
* GTime gtime;
|
||||||
*
|
*
|
||||||
@ -1286,7 +1286,7 @@ g_date_set_parse (GDate *d,
|
|||||||
* the user's current timezone.
|
* the user's current timezone.
|
||||||
*
|
*
|
||||||
* To set the value of a date to the current day, you could write:
|
* To set the value of a date to the current day, you could write:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_date_set_time_t (date, time (NULL));
|
* g_date_set_time_t (date, time (NULL));
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
*
|
*
|
||||||
* Functions that can fail take a return location for a #GError as their
|
* Functions that can fail take a return location for a #GError as their
|
||||||
* last argument. For example:
|
* last argument. For example:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gboolean g_file_get_contents (const gchar *filename,
|
* gboolean g_file_get_contents (const gchar *filename,
|
||||||
* gchar **contents,
|
* gchar **contents,
|
||||||
* gsize *length,
|
* gsize *length,
|
||||||
@ -62,7 +62,7 @@
|
|||||||
* If you pass a non-%NULL value for the <literal>error</literal>
|
* 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.
|
* argument, it should point to a location where an error can be placed.
|
||||||
* For example:
|
* For example:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gchar *contents;
|
* gchar *contents;
|
||||||
* GError *err = NULL;
|
* GError *err = NULL;
|
||||||
*
|
*
|
||||||
@ -89,7 +89,7 @@
|
|||||||
* Because g_file_get_contents() returns %FALSE on failure, if you
|
* Because g_file_get_contents() returns %FALSE on failure, if you
|
||||||
* are only interested in whether it failed and don't need to display
|
* are only interested in whether it failed and don't need to display
|
||||||
* an error message, you can pass %NULL for the @error argument:
|
* an error message, you can pass %NULL for the @error argument:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* if (g_file_get_contents ("foo.txt", &contents, NULL, NULL)) /* ignore errors */
|
* if (g_file_get_contents ("foo.txt", &contents, NULL, NULL)) /* ignore errors */
|
||||||
* /* no error occurred */ ;
|
* /* no error occurred */ ;
|
||||||
* else
|
* else
|
||||||
@ -115,7 +115,7 @@
|
|||||||
* want to g_set_error(), then return immediately. g_set_error()
|
* want to g_set_error(), then return immediately. g_set_error()
|
||||||
* does nothing if the error location passed to it is %NULL.
|
* does nothing if the error location passed to it is %NULL.
|
||||||
* Here's an example:
|
* Here's an example:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gint
|
* gint
|
||||||
* foo_open_file (GError **error)
|
* foo_open_file (GError **error)
|
||||||
* {
|
* {
|
||||||
@ -141,7 +141,7 @@
|
|||||||
* function that can report a #GError. If the sub-function indicates
|
* function that can report a #GError. If the sub-function indicates
|
||||||
* fatal errors in some way other than reporting a #GError, such as
|
* fatal errors in some way other than reporting a #GError, such as
|
||||||
* by returning %TRUE on success, you can simply do the following:
|
* by returning %TRUE on success, you can simply do the following:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gboolean
|
* gboolean
|
||||||
* my_function_that_can_fail (GError **err)
|
* my_function_that_can_fail (GError **err)
|
||||||
* {
|
* {
|
||||||
@ -163,7 +163,7 @@
|
|||||||
* reporting a #GError, you need to create a temporary #GError
|
* reporting a #GError, you need to create a temporary #GError
|
||||||
* since the passed-in one may be %NULL. g_propagate_error() is
|
* since the passed-in one may be %NULL. g_propagate_error() is
|
||||||
* intended for use in this case.
|
* intended for use in this case.
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gboolean
|
* gboolean
|
||||||
* my_function_that_can_fail (GError **err)
|
* my_function_that_can_fail (GError **err)
|
||||||
* {
|
* {
|
||||||
@ -188,7 +188,7 @@
|
|||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* Error pileups are always a bug. For example, this code is incorrect:
|
* Error pileups are always a bug. For example, this code is incorrect:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gboolean
|
* gboolean
|
||||||
* my_function_that_can_fail (GError **err)
|
* my_function_that_can_fail (GError **err)
|
||||||
* {
|
* {
|
||||||
@ -215,7 +215,7 @@
|
|||||||
* of handling an error by always doing nothing about it. So the
|
* of handling an error by always doing nothing about it. So the
|
||||||
* following code is fine, assuming errors in sub_function_that_can_fail()
|
* following code is fine, assuming errors in sub_function_that_can_fail()
|
||||||
* are not fatal to my_function_that_can_fail():
|
* are not fatal to my_function_that_can_fail():
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gboolean
|
* gboolean
|
||||||
* my_function_that_can_fail (GError **err)
|
* my_function_that_can_fail (GError **err)
|
||||||
* {
|
* {
|
||||||
@ -246,7 +246,7 @@
|
|||||||
*
|
*
|
||||||
* - The error domain is called <NAMESPACE>_<MODULE>_ERROR,
|
* - The error domain is called <NAMESPACE>_<MODULE>_ERROR,
|
||||||
* for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
|
* for example %G_SPAWN_ERROR or %G_THREAD_ERROR:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #define G_SPAWN_ERROR g_spawn_error_quark ()
|
* #define G_SPAWN_ERROR g_spawn_error_quark ()
|
||||||
*
|
*
|
||||||
* GQuark
|
* GQuark
|
||||||
|
@ -289,7 +289,7 @@ g_mkdir_with_parents (const gchar *pathname,
|
|||||||
* For example, you might think you could use %G_FILE_TEST_IS_SYMLINK
|
* 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
|
* to know whether it is safe to write to a file without being
|
||||||
* tricked into writing into a different location. It doesn't work!
|
* tricked into writing into a different location. It doesn't work!
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* DON'T DO THIS */
|
* /* DON'T DO THIS */
|
||||||
* if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
|
* if (!g_file_test (filename, G_FILE_TEST_IS_SYMLINK))
|
||||||
* {
|
* {
|
||||||
|
@ -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.h</filename>. For use in a library, you must include
|
||||||
* <filename>glib/gi18n-lib.h</filename> after defining the %GETTEXT_PACKAGE
|
* <filename>glib/gi18n-lib.h</filename> after defining the %GETTEXT_PACKAGE
|
||||||
* macro suitably for your library:
|
* macro suitably for your library:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #define GETTEXT_PACKAGE "gtk20"
|
* #define GETTEXT_PACKAGE "gtk20"
|
||||||
* #include <glib/gi18n-lib.h>
|
* #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
|
* used as a context. This is mainly useful for short strings which
|
||||||
* may need different translations, depending on the context in which
|
* may need different translations, depending on the context in which
|
||||||
* they are used.
|
* they are used.
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* label1 = C_("Navigation", "Back");
|
* label1 = C_("Navigation", "Back");
|
||||||
* label2 = C_("Body part", "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
|
* where the translated strings can't be directly used, e.g. in string
|
||||||
* array initializers. To get the translated string, call gettext()
|
* array initializers. To get the translated string, call gettext()
|
||||||
* at runtime.
|
* at runtime.
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* {
|
* {
|
||||||
* static const char *messages[] = {
|
* static const char *messages[] = {
|
||||||
* N_("some very meaningful message"),
|
* 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
|
* be directly used, e.g. in string array initializers. To get the
|
||||||
* translated string, you should call g_dpgettext2() at runtime.
|
* translated string, you should call g_dpgettext2() at runtime.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* {
|
* {
|
||||||
* static const char *messages[] = {
|
* static const char *messages[] = {
|
||||||
* NC_("some context", "some very meaningful message"),
|
* NC_("some context", "some very meaningful message"),
|
||||||
|
@ -679,7 +679,7 @@ g_hash_table_new_full (GHashFunc hash_func,
|
|||||||
* Initializes a key/value pair iterator and associates it with
|
* Initializes a key/value pair iterator and associates it with
|
||||||
* @hash_table. Modifying the hash table after calling this function
|
* @hash_table. Modifying the hash table after calling this function
|
||||||
* invalidates the returned iterator.
|
* invalidates the returned iterator.
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GHashTableIter iter;
|
* GHashTableIter iter;
|
||||||
* gpointer key, value;
|
* gpointer key, value;
|
||||||
*
|
*
|
||||||
|
16
glib/glist.c
16
glib/glist.c
@ -75,7 +75,7 @@
|
|||||||
* g_list_insert() and g_list_insert_sorted().
|
* g_list_insert() and g_list_insert_sorted().
|
||||||
*
|
*
|
||||||
* To visit all elements in the list, use a loop over the list:
|
* To visit all elements in the list, use a loop over the list:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GList *l;
|
* GList *l;
|
||||||
* for (l = list; l != NULL; l = l->next)
|
* 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)
|
* To loop over the list and modify it (e.g. remove a certain element)
|
||||||
* a while loop is more appropriate, for example:
|
* a while loop is more appropriate, for example:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GList *l = list;
|
* GList *l = list;
|
||||||
* while (l != NULL)
|
* 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
|
* to avoid the inefficiency is to use g_list_prepend() and reverse
|
||||||
* the list with g_list_reverse() when all elements have been added.
|
* the list with g_list_reverse() when all elements have been added.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Notice that these are initialized to the empty list. */
|
* /* Notice that these are initialized to the empty list. */
|
||||||
* GList *string_list = NULL, *number_list = NULL;
|
* 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,
|
* Note that the return value is the new start of the list,
|
||||||
* which will have changed, so make sure you store the new value.
|
* which will have changed, so make sure you store the new value.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Notice that it is initialized to the empty list. */
|
* /* Notice that it is initialized to the empty list. */
|
||||||
* GList *list = NULL;
|
* 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.
|
* 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:
|
* The following example moves an element to the top of the list:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* list = g_list_remove_link (list, llink);
|
* list = g_list_remove_link (list, llink);
|
||||||
* list = g_list_concat (llink, list);
|
* 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
|
* 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
|
* (see the example for g_list_concat()) or to remove an element in
|
||||||
* the list before freeing its data:
|
* the list before freeing its data:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* list = g_list_remove_link (list, llink);
|
* list = g_list_remove_link (list, llink);
|
||||||
* free_some_data_that_may_access_the_list_again (llink->data);
|
* free_some_data_that_may_access_the_list_again (llink->data);
|
||||||
* g_list_free (llink);
|
* g_list_free (llink);
|
||||||
@ -650,12 +650,12 @@ g_list_copy (GList *list)
|
|||||||
* if the copy function takes only one argument.
|
* if the copy function takes only one argument.
|
||||||
*
|
*
|
||||||
* For instance, if @list holds a list of GObjects, you can do:
|
* 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);
|
* another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* And, to entirely free the new list, you could do:
|
* And, to entirely free the new list, you could do:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_list_free_full (another_list, g_object_unref);
|
* g_list_free_full (another_list, g_object_unref);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
|
12
glib/gmain.c
12
glib/gmain.c
@ -2741,7 +2741,7 @@ get_dispatch (void)
|
|||||||
* This function is useful in a situation like the following:
|
* This function is useful in a situation like the following:
|
||||||
* Imagine an extremely simple "garbage collected" system.
|
* Imagine an extremely simple "garbage collected" system.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static GList *free_list;
|
* static GList *free_list;
|
||||||
*
|
*
|
||||||
* gpointer
|
* gpointer
|
||||||
@ -2778,7 +2778,7 @@ get_dispatch (void)
|
|||||||
* doesn't work, since the idle function could be called from a
|
* doesn't work, since the idle function could be called from a
|
||||||
* recursive callback. This can be fixed by using g_main_depth()
|
* recursive callback. This can be fixed by using g_main_depth()
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gpointer
|
* gpointer
|
||||||
* allocate_memory (gsize size)
|
* allocate_memory (gsize size)
|
||||||
* {
|
* {
|
||||||
@ -2867,7 +2867,7 @@ g_main_current_source (void)
|
|||||||
* from within idle handlers, but may have freed the object
|
* from within idle handlers, but may have freed the object
|
||||||
* before the dispatch of your idle handler.
|
* before the dispatch of your idle handler.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static gboolean
|
* static gboolean
|
||||||
* idle_callback (gpointer data)
|
* idle_callback (gpointer data)
|
||||||
* {
|
* {
|
||||||
@ -2905,7 +2905,7 @@ g_main_current_source (void)
|
|||||||
* this particular problem, is to check to if the source
|
* this particular problem, is to check to if the source
|
||||||
* has already been destroy within the callback.
|
* has already been destroy within the callback.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static gboolean
|
* static gboolean
|
||||||
* idle_callback (gpointer data)
|
* 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
|
* Another related use for this function is when implementing a main
|
||||||
* loop with a termination condition, computed from multiple threads:
|
* loop with a termination condition, computed from multiple threads:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #define NUM_TASKS 10
|
* #define NUM_TASKS 10
|
||||||
* static volatile gint tasks_remaining = NUM_TASKS;
|
* static volatile gint tasks_remaining = NUM_TASKS;
|
||||||
* ...
|
* ...
|
||||||
@ -4331,7 +4331,7 @@ g_main_context_get_poll_func (GMainContext *context)
|
|||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* Then in a thread:
|
* Then in a thread:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* perform_work();
|
* perform_work();
|
||||||
*
|
*
|
||||||
* if (g_atomic_int_dec_and_test (&tasks_remaining))
|
* if (g_atomic_int_dec_and_test (&tasks_remaining))
|
||||||
|
@ -1996,7 +1996,7 @@ g_markup_parse_context_get_user_data (GMarkupParseContext *context)
|
|||||||
* As an example, see the following implementation of a simple
|
* As an example, see the following implementation of a simple
|
||||||
* parser that counts the number of tags encountered.
|
* parser that counts the number of tags encountered.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct
|
* typedef struct
|
||||||
* {
|
* {
|
||||||
* gint tag_count;
|
* 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
|
* In order to allow this parser to be easily used as a subparser, the
|
||||||
* following interface is provided:
|
* following interface is provided:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* void
|
* void
|
||||||
* start_counting (GMarkupParseContext *context)
|
* 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:
|
* The subparser would then be used as follows:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void start_element (context, element_name, ...)
|
* static void start_element (context, element_name, ...)
|
||||||
* {
|
* {
|
||||||
* if (strcmp (element_name, "count-these") == 0)
|
* 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
|
* output, without having to worry that the strings
|
||||||
* might themselves contain markup.
|
* might themselves contain markup.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* const char *store = "Fortnum & Mason";
|
* const char *store = "Fortnum & Mason";
|
||||||
* const char *item = "Tea";
|
* const char *item = "Tea";
|
||||||
* char *output;
|
* char *output;
|
||||||
|
@ -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
|
* Here is an example for adding a log handler for all warning messages
|
||||||
* in the default domain:
|
* in the default domain:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
|
* g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
|
||||||
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* This example adds a log handler for all critical messages from GTK+:
|
* 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_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
|
||||||
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* This example adds a log handler for all messages from GLib:
|
* 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_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
|
||||||
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
||||||
* ]|
|
* ]|
|
||||||
@ -1146,7 +1146,7 @@ g_assert_warning (const char *log_domain,
|
|||||||
*
|
*
|
||||||
* For example:
|
* For example:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* g_main_context_push_thread_default() should fail if the
|
* /* g_main_context_push_thread_default() should fail if the
|
||||||
* * context is already owned by another thread.
|
* * context is already owned by another thread.
|
||||||
* */
|
* */
|
||||||
|
@ -91,7 +91,7 @@
|
|||||||
*
|
*
|
||||||
* Here is a complete example of setting up GOption to parse the example
|
* Here is a complete example of setting up GOption to parse the example
|
||||||
* commandline above and produce the example help output.
|
* commandline above and produce the example help output.
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static gint repeats = 2;
|
* static gint repeats = 2;
|
||||||
* static gint max_size = 8;
|
* static gint max_size = 8;
|
||||||
* static gboolean verbose = FALSE;
|
* static gboolean verbose = FALSE;
|
||||||
@ -150,7 +150,7 @@
|
|||||||
* The following example shows how you can use #GOptionContext directly
|
* The following example shows how you can use #GOptionContext directly
|
||||||
* in order to correctly deal with Unicode filenames on Windows:
|
* in order to correctly deal with Unicode filenames on Windows:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* int
|
* int
|
||||||
* main (int argc, char **argv)
|
* main (int argc, char **argv)
|
||||||
* {
|
* {
|
||||||
|
@ -1638,7 +1638,7 @@ g_regex_match_simple (const gchar *pattern,
|
|||||||
* To retrieve all the non-overlapping matches of the pattern in
|
* To retrieve all the non-overlapping matches of the pattern in
|
||||||
* string you can use g_match_info_next().
|
* string you can use g_match_info_next().
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* print_uppercase_words (const gchar *string)
|
* 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
|
* To retrieve all the non-overlapping matches of the pattern in
|
||||||
* string you can use g_match_info_next().
|
* string you can use g_match_info_next().
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* print_uppercase_words (const gchar *string)
|
* 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
|
* The following example uses g_regex_replace_eval() to replace multiple
|
||||||
* strings at once:
|
* strings at once:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static gboolean
|
* static gboolean
|
||||||
* eval_cb (const GMatchInfo *info,
|
* eval_cb (const GMatchInfo *info,
|
||||||
* GString *res,
|
* GString *res,
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
* object size used at allocation time is still available when freeing.
|
* object size used at allocation time is still available when freeing.
|
||||||
*
|
*
|
||||||
* Here is an example for using the slice allocator:
|
* Here is an example for using the slice allocator:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gchar *mem[10000];
|
* gchar *mem[10000];
|
||||||
* gint i;
|
* gint i;
|
||||||
*
|
*
|
||||||
@ -111,7 +111,7 @@
|
|||||||
*
|
*
|
||||||
* And here is an example for using the using the slice allocator
|
* And here is an example for using the using the slice allocator
|
||||||
* with data structures:
|
* with data structures:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GRealArray *array;
|
* GRealArray *array;
|
||||||
*
|
*
|
||||||
* /* Allocate one block, using the g_slice_new() macro. */
|
* /* Allocate one block, using the g_slice_new() macro. */
|
||||||
|
@ -191,7 +191,7 @@ g_slist_free_full (GSList *list,
|
|||||||
* elements. A common idiom to avoid the inefficiency is to prepend
|
* elements. A common idiom to avoid the inefficiency is to prepend
|
||||||
* the elements and reverse the list when all elements have been added.
|
* the elements and reverse the list when all elements have been added.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Notice that these are initialized to the empty list. */
|
* /* Notice that these are initialized to the empty list. */
|
||||||
* GSList *list = NULL, *number_list = NULL;
|
* 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
|
* The return value is the new start of the list, which
|
||||||
* may have changed, so make sure you store the new value.
|
* may have changed, so make sure you store the new value.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Notice that it is initialized to the empty list. */
|
* /* Notice that it is initialized to the empty list. */
|
||||||
* GSList *list = NULL;
|
* GSList *list = NULL;
|
||||||
* list = g_slist_prepend (list, "last");
|
* list = g_slist_prepend (list, "last");
|
||||||
@ -584,12 +584,12 @@ g_slist_copy (GSList *list)
|
|||||||
* one argument.
|
* one argument.
|
||||||
*
|
*
|
||||||
* For instance, if @list holds a list of GObjects, you can do:
|
* 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);
|
* another_list = g_slist_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* And, to entirely free the new list, you could do:
|
* And, to entirely free the new list, you could do:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_slist_free_full (another_list, g_object_unref);
|
* g_slist_free_full (another_list, g_object_unref);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
|
@ -266,7 +266,7 @@
|
|||||||
* on systems with 64bit IEEE-compatible doubles.
|
* on systems with 64bit IEEE-compatible doubles.
|
||||||
*
|
*
|
||||||
* The typical usage would be something like:
|
* The typical usage would be something like:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* char buf[G_ASCII_DTOSTR_BUF_SIZE];
|
* char buf[G_ASCII_DTOSTR_BUF_SIZE];
|
||||||
*
|
*
|
||||||
* fprintf (out, "value=%s\n", g_ascii_dtostr (buf, sizeof (buf), value));
|
* 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,
|
* changed to the @new_delimiter character. Modifies @string in place,
|
||||||
* and returns @string itself, not a copy. The return value is to
|
* and returns @string itself, not a copy. The return value is to
|
||||||
* allow nesting such as
|
* allow nesting such as
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_ascii_strup (g_strdelimit (str, "abc", '?'))
|
* g_ascii_strup (g_strdelimit (str, "abc", '?'))
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
@ -1964,7 +1964,7 @@ g_strdelimit (gchar *string,
|
|||||||
* replaces the character with @substitutor. Modifies @string in place,
|
* replaces the character with @substitutor. Modifies @string in place,
|
||||||
* and return @string itself, not a copy. The return value is to allow
|
* and return @string itself, not a copy. The return value is to allow
|
||||||
* nesting such as
|
* nesting such as
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_ascii_strup (g_strcanon (str, "abc", '?'))
|
* g_ascii_strup (g_strcanon (str, "abc", '?'))
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
*
|
*
|
||||||
* The API is designed to handle creation and registration of test suites
|
* The API is designed to handle creation and registration of test suites
|
||||||
* and test cases implicitly. A simple call like
|
* and test cases implicitly. A simple call like
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_test_add_func ("/misc/assertions", test_assertions);
|
* g_test_add_func ("/misc/assertions", test_assertions);
|
||||||
* ]|
|
* ]|
|
||||||
* creates a test suite called "misc" with a single test case named
|
* 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
|
* The advantage of this macro is that it can produce a message that
|
||||||
* includes the actual values of @s1 and @s2.
|
* includes the actual values of @s1 and @s2.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_assert_cmpstr (mystring, ==, "fubar");
|
* g_assert_cmpstr (mystring, ==, "fubar");
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
@ -2637,7 +2637,7 @@ wait_for_child (GPid pid,
|
|||||||
* The forking parent process then asserts successful child program
|
* The forking parent process then asserts successful child program
|
||||||
* termination and validates child program outputs.
|
* termination and validates child program outputs.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* test_fork_patterns (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
|
* <literal>my_object_new(1000000)</literal> will abort with an error
|
||||||
* message.
|
* message.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* test_create_large_object_subprocess (void)
|
* test_create_large_object_subprocess (void)
|
||||||
* {
|
* {
|
||||||
|
@ -141,7 +141,7 @@ g_mutex_get_impl (GMutex *mutex)
|
|||||||
* It is not necessary to initialize a mutex that has been
|
* It is not necessary to initialize a mutex that has been
|
||||||
* statically allocated.
|
* statically allocated.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct {
|
* typedef struct {
|
||||||
* GMutex m;
|
* 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
|
* It is not necessary to initialise a recursive mutex that has been
|
||||||
* statically allocated.
|
* statically allocated.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct {
|
* typedef struct {
|
||||||
* GRecMutex m;
|
* GRecMutex m;
|
||||||
* ...
|
* ...
|
||||||
@ -471,7 +471,7 @@ g_rw_lock_get_impl (GRWLock *lock)
|
|||||||
* necessary to initialise a reader-writer lock that has been statically
|
* necessary to initialise a reader-writer lock that has been statically
|
||||||
* allocated.
|
* allocated.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct {
|
* typedef struct {
|
||||||
* GRWLock l;
|
* GRWLock l;
|
||||||
* ...
|
* ...
|
||||||
@ -807,7 +807,7 @@ g_cond_broadcast (GCond *cond)
|
|||||||
* condition variable (extending the example presented in the
|
* condition variable (extending the example presented in the
|
||||||
* documentation for #GCond):
|
* documentation for #GCond):
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gpointer
|
* gpointer
|
||||||
* pop_data_timed (void)
|
* 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
|
* be properly initialised by default (ie: to all zeros). See the
|
||||||
* examples below.
|
* examples below.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static GPrivate name_key = G_PRIVATE_INIT (g_free);
|
* static GPrivate name_key = G_PRIVATE_INIT (g_free);
|
||||||
*
|
*
|
||||||
* /* return value should not be freed */
|
* /* return value should not be freed */
|
||||||
|
@ -158,7 +158,7 @@
|
|||||||
* give_me_next_number() example using the #G_LOCK macros:
|
* give_me_next_number() example using the #G_LOCK macros:
|
||||||
*
|
*
|
||||||
* Here is an example for using the #G_LOCK convenience macros:
|
* Here is an example for using the #G_LOCK convenience macros:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* G_LOCK_DEFINE (current_number);
|
* G_LOCK_DEFINE (current_number);
|
||||||
*
|
*
|
||||||
* int
|
* int
|
||||||
@ -227,7 +227,7 @@
|
|||||||
* access.
|
* access.
|
||||||
*
|
*
|
||||||
* Take for example the following function:
|
* Take for example the following function:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* int
|
* int
|
||||||
* give_me_next_number (void)
|
* give_me_next_number (void)
|
||||||
* {
|
* {
|
||||||
@ -244,7 +244,7 @@
|
|||||||
* It is easy to see that this won't work in a multi-threaded
|
* It is easy to see that this won't work in a multi-threaded
|
||||||
* application. There current_number must be protected against shared
|
* application. There current_number must be protected against shared
|
||||||
* access. A #GMutex can be used as a solution to this problem:
|
* access. A #GMutex can be used as a solution to this problem:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* int
|
* int
|
||||||
* give_me_next_number (void)
|
* give_me_next_number (void)
|
||||||
* {
|
* {
|
||||||
@ -307,7 +307,7 @@
|
|||||||
* g_rw_lock_reader_lock()).
|
* g_rw_lock_reader_lock()).
|
||||||
*
|
*
|
||||||
* Here is an example for an array with access functions:
|
* Here is an example for an array with access functions:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GRWLock lock;
|
* GRWLock lock;
|
||||||
* GPtrArray *array;
|
* GPtrArray *array;
|
||||||
*
|
*
|
||||||
@ -376,7 +376,7 @@
|
|||||||
*
|
*
|
||||||
* Here is an example for using GCond to block a thread until a condition
|
* Here is an example for using GCond to block a thread until a condition
|
||||||
* is satisfied:
|
* is satisfied:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gpointer current_data = NULL;
|
* gpointer current_data = NULL;
|
||||||
* GMutex data_mutex;
|
* GMutex data_mutex;
|
||||||
* GCond data_cond;
|
* 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.
|
* A #GOnce must be initialized with this macro before it can be used.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GOnce my_once = G_ONCE_INIT;
|
* 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
|
* Calling g_once() recursively on the same #GOnce struct in
|
||||||
* @func will lead to a deadlock.
|
* @func will lead to a deadlock.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gpointer
|
* gpointer
|
||||||
* get_debug_flags (void)
|
* get_debug_flags (void)
|
||||||
* {
|
* {
|
||||||
@ -614,7 +614,7 @@ g_once_impl (GOnce *once,
|
|||||||
* blocked until initialization completed. To be used in constructs
|
* blocked until initialization completed. To be used in constructs
|
||||||
* like this:
|
* like this:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static gsize initialization_value = 0;
|
* static gsize initialization_value = 0;
|
||||||
*
|
*
|
||||||
* if (g_once_init_enter (&initialization_value))
|
* if (g_once_init_enter (&initialization_value))
|
||||||
|
@ -2480,14 +2480,14 @@ g_variant_new_parsed_va (const gchar *format,
|
|||||||
* g_variant_new() would have collected.
|
* g_variant_new() would have collected.
|
||||||
*
|
*
|
||||||
* Consider this simple example:
|
* Consider this simple example:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
|
* g_variant_new_parsed ("[('one', 1), ('two', %i), (%s, 3)]", 2, "three");
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* In the example, the variable argument parameters are collected and
|
* In the example, the variable argument parameters are collected and
|
||||||
* filled in as if they were part of the original string to produce the
|
* filled in as if they were part of the original string to produce the
|
||||||
* result of
|
* result of
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* [('one', 1), ('two', 2), ('three', 3)]
|
* [('one', 1), ('two', 2), ('three', 3)]
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
@ -2530,7 +2530,7 @@ g_variant_new_parsed (const gchar *format,
|
|||||||
*
|
*
|
||||||
* This function might be used as follows:
|
* This function might be used as follows:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GVariant *
|
* GVariant *
|
||||||
* make_pointless_dictionary (void)
|
* make_pointless_dictionary (void)
|
||||||
* {
|
* {
|
||||||
|
@ -3068,7 +3068,7 @@ g_variant_iter_free (GVariantIter *iter)
|
|||||||
* you no longer need it.
|
* you no longer need it.
|
||||||
*
|
*
|
||||||
* Here is an example for iterating with g_variant_iter_next_value():
|
* Here is an example for iterating with g_variant_iter_next_value():
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* recursively iterate a container */
|
* /* recursively iterate a container */
|
||||||
* void
|
* void
|
||||||
* iterate_container_recursive (GVariant *container)
|
* iterate_container_recursive (GVariant *container)
|
||||||
@ -4889,7 +4889,7 @@ g_variant_get_va (GVariant *value,
|
|||||||
*
|
*
|
||||||
* This function might be used as follows:
|
* This function might be used as follows:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GVariant *
|
* GVariant *
|
||||||
* make_pointless_dictionary (void)
|
* make_pointless_dictionary (void)
|
||||||
* {
|
* {
|
||||||
@ -4981,7 +4981,7 @@ g_variant_get_child (GVariant *value,
|
|||||||
* the unpacking process.
|
* the unpacking process.
|
||||||
*
|
*
|
||||||
* Here is an example for memory management with g_variant_iter_next():
|
* Here is an example for memory management with g_variant_iter_next():
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Iterates a dictionary of type 'a{sv}' */
|
* /* Iterates a dictionary of type 'a{sv}' */
|
||||||
* void
|
* void
|
||||||
* iterate_dictionary (GVariant *dictionary)
|
* 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.
|
* g_variant_get(). Failure to do so will cause a memory leak.
|
||||||
*
|
*
|
||||||
* Here is an example for memory management with g_variant_iter_loop():
|
* Here is an example for memory management with g_variant_iter_loop():
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* Iterates a dictionary of type 'a{sv}' */
|
* /* Iterates a dictionary of type 'a{sv}' */
|
||||||
* void
|
* void
|
||||||
* iterate_dictionary (GVariant *dictionary)
|
* iterate_dictionary (GVariant *dictionary)
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
* it must ensure that it is never unloaded, by calling g_module_make_resident().
|
* it must ensure that it is never unloaded, by calling g_module_make_resident().
|
||||||
*
|
*
|
||||||
* Example: Calling a function defined in a GModule
|
* Example: Calling a function defined in a GModule
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* the function signature for 'say_hello' */
|
* /* the function signature for 'say_hello' */
|
||||||
* typedef void (* SayHelloFunc) (const char *message);
|
* typedef void (* SayHelloFunc) (const char *message);
|
||||||
*
|
*
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* value is applied to the target property; for instance, the following
|
* value is applied to the target property; for instance, the following
|
||||||
* binding:
|
* binding:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_object_bind_property (object1, "property-a",
|
* g_object_bind_property (object1, "property-a",
|
||||||
* object2, "property-b",
|
* object2, "property-b",
|
||||||
* G_BINDING_DEFAULT);
|
* G_BINDING_DEFAULT);
|
||||||
@ -43,7 +43,7 @@
|
|||||||
* of two #GObject instances, so that if either property changes, the
|
* of two #GObject instances, so that if either property changes, the
|
||||||
* other is updated as well, for instance:
|
* other is updated as well, for instance:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_object_bind_property (object1, "property-a",
|
* g_object_bind_property (object1, "property-a",
|
||||||
* object2, "property-b",
|
* object2, "property-b",
|
||||||
* G_BINDING_BIDIRECTIONAL);
|
* G_BINDING_BIDIRECTIONAL);
|
||||||
@ -56,7 +56,7 @@
|
|||||||
* transformation from the source value to the target value before
|
* transformation from the source value to the target value before
|
||||||
* applying it; for instance, the following binding:
|
* applying it; for instance, the following binding:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_object_bind_property_full (adjustment1, "value",
|
* g_object_bind_property_full (adjustment1, "value",
|
||||||
* adjustment2, "value",
|
* adjustment2, "value",
|
||||||
* G_BINDING_BIDIRECTIONAL,
|
* G_BINDING_BIDIRECTIONAL,
|
||||||
|
@ -151,7 +151,7 @@ enum {
|
|||||||
* part as a #GClosure. This function is mainly useful when
|
* part as a #GClosure. This function is mainly useful when
|
||||||
* implementing new types of closures.
|
* implementing new types of closures.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct _MyClosure MyClosure;
|
* typedef struct _MyClosure MyClosure;
|
||||||
* struct _MyClosure
|
* struct _MyClosure
|
||||||
* {
|
* {
|
||||||
@ -608,20 +608,20 @@ g_closure_unref (GClosure *closure)
|
|||||||
* count. If the closure is not floating, g_closure_sink() does
|
* count. If the closure is not floating, g_closure_sink() does
|
||||||
* nothing. The reason for the existence of the floating state is to
|
* nothing. The reason for the existence of the floating state is to
|
||||||
* prevent cumbersome code sequences like:
|
* prevent cumbersome code sequences like:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* closure = g_cclosure_new (cb_func, cb_data);
|
* closure = g_cclosure_new (cb_func, cb_data);
|
||||||
* g_source_set_closure (source, closure);
|
* g_source_set_closure (source, closure);
|
||||||
* g_closure_unref (closure); /* GObject doesn't really need this */
|
* g_closure_unref (closure); /* GObject doesn't really need this */
|
||||||
* ]|
|
* ]|
|
||||||
* Because g_source_set_closure() (and similar functions) take ownership of the
|
* Because g_source_set_closure() (and similar functions) take ownership of the
|
||||||
* initial reference count, if it is unowned, we instead can write:
|
* 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));
|
* g_source_set_closure (source, g_cclosure_new (cb_func, cb_data));
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* Generally, this function is used together with g_closure_ref(). Ane example
|
* Generally, this function is used together with g_closure_ref(). Ane example
|
||||||
* of storing a closure for later notification looks like:
|
* of storing a closure for later notification looks like:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static GClosure *notify_closure = NULL;
|
* static GClosure *notify_closure = NULL;
|
||||||
* void
|
* void
|
||||||
* foo_notify_set_closure (GClosure *closure)
|
* foo_notify_set_closure (GClosure *closure)
|
||||||
|
@ -262,7 +262,7 @@ g_flags_register_static (const gchar *name,
|
|||||||
* function of a #GTypePlugin implementation, as in the following
|
* function of a #GTypePlugin implementation, as in the following
|
||||||
* example:
|
* example:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* static void
|
* static void
|
||||||
* my_enum_complete_type_info (GTypePlugin *plugin,
|
* my_enum_complete_type_info (GTypePlugin *plugin,
|
||||||
* GType g_type,
|
* GType g_type,
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
* This means that it is not specifically claimed to be "owned" by
|
* This means that it is not specifically claimed to be "owned" by
|
||||||
* any code portion. The main motivation for providing floating references is
|
* any code portion. The main motivation for providing floating references is
|
||||||
* C convenience. In particular, it allows code to be written as:
|
* C convenience. In particular, it allows code to be written as:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* container = create_container ();
|
* container = create_container ();
|
||||||
* container_add_child (container, create_child());
|
* container_add_child (container, create_child());
|
||||||
* ]|
|
* ]|
|
||||||
@ -62,7 +62,7 @@
|
|||||||
* references, container_add_child() can only g_object_ref() the new child,
|
* 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
|
* so to implement this code without reference leaks, it would have to be
|
||||||
* written as:
|
* written as:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* Child *child;
|
* Child *child;
|
||||||
* container = create_container ();
|
* container = create_container ();
|
||||||
* child = create_child ();
|
* child = create_child ();
|
||||||
@ -84,7 +84,7 @@
|
|||||||
* across certain code portions (an example is #GtkMenu), to achieve this,
|
* across certain code portions (an example is #GtkMenu), to achieve this,
|
||||||
* the following sequence can be used:
|
* the following sequence can be used:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* /* save floating state */
|
* /* save floating state */
|
||||||
* gboolean was_floating = g_object_is_floating (object);
|
* gboolean was_floating = g_object_is_floating (object);
|
||||||
* g_object_ref_sink (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
|
* This signal is typically used to obtain change notification for a
|
||||||
* single property, by specifying the property name as a detail in the
|
* single property, by specifying the property name as a detail in the
|
||||||
* g_signal_connect() call, like this:
|
* g_signal_connect() call, like this:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_signal_connect (text_view->buffer, "notify::paste-target-list",
|
* g_signal_connect (text_view->buffer, "notify::paste-target-list",
|
||||||
* G_CALLBACK (gtk_text_view_target_list_notify),
|
* G_CALLBACK (gtk_text_view_target_list_notify),
|
||||||
* text_view)
|
* text_view)
|
||||||
@ -589,7 +589,7 @@ g_object_class_install_property (GObjectClass *class,
|
|||||||
* #GParamSpecs and g_object_notify_by_pspec(). For instance, this
|
* #GParamSpecs and g_object_notify_by_pspec(). For instance, this
|
||||||
* class initialization:
|
* class initialization:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* enum {
|
* enum {
|
||||||
* PROP_0, PROP_FOO, PROP_BAR, N_PROPERTIES
|
* 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:
|
* allows calling g_object_notify_by_pspec() to notify of property changes:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* void
|
* void
|
||||||
* my_object_set_foo (MyObject *self, gint foo)
|
* 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
|
* instead, is to store the GParamSpec used with
|
||||||
* g_object_class_install_property() inside a static array, e.g.:
|
* g_object_class_install_property() inside a static array, e.g.:
|
||||||
*
|
*
|
||||||
*|[
|
*|[<!-- language="C" -->
|
||||||
* enum
|
* enum
|
||||||
* {
|
* {
|
||||||
* PROP_0,
|
* PROP_0,
|
||||||
@ -1234,7 +1234,7 @@ g_object_notify (GObject *object,
|
|||||||
*
|
*
|
||||||
* and then notify a change on the "foo" property with:
|
* and then notify a change on the "foo" property with:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* g_object_notify_by_pspec (self, properties[PROP_FOO]);
|
* 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
|
* Here is an example of using g_object_get() to get the contents
|
||||||
* of three properties: an integer, a string and an object:
|
* of three properties: an integer, a string and an object:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* gint intval;
|
* gint intval;
|
||||||
* gchar *strval;
|
* gchar *strval;
|
||||||
* GObject *objval;
|
* 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_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)
|
* - 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,
|
* menu->toplevel = g_object_connect (g_object_new (GTK_TYPE_WINDOW,
|
||||||
* "type", GTK_WINDOW_POPUP,
|
* "type", GTK_WINDOW_POPUP,
|
||||||
* "child", menu,
|
* "child", menu,
|
||||||
@ -3324,7 +3324,7 @@ g_object_set_qdata_full (GObject *object,
|
|||||||
* set).
|
* set).
|
||||||
* Usually, calling this function is only required to update
|
* Usually, calling this function is only required to update
|
||||||
* user data pointers with a destroy notifier, for example:
|
* user data pointers with a destroy notifier, for example:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* void
|
* void
|
||||||
* object_add_to_user_list (GObject *object,
|
* object_add_to_user_list (GObject *object,
|
||||||
* const gchar *new_string)
|
* const gchar *new_string)
|
||||||
|
@ -4425,7 +4425,7 @@ gobject_init_ctor (void)
|
|||||||
* Note the use of a structure member "priv" to avoid the overhead
|
* Note the use of a structure member "priv" to avoid the overhead
|
||||||
* of repeatedly calling MY_OBJECT_GET_PRIVATE().
|
* of repeatedly calling MY_OBJECT_GET_PRIVATE().
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* typedef struct _MyObject MyObject;
|
* typedef struct _MyObject MyObject;
|
||||||
* typedef struct _MyObjectPrivate MyObjectPrivate;
|
* typedef struct _MyObjectPrivate MyObjectPrivate;
|
||||||
*
|
*
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
* 1. The type is initially introduced (usually upon loading the module
|
* 1. The type is initially introduced (usually upon loading the module
|
||||||
* the first time, or by your main application that knows what modules
|
* the first time, or by your main application that knows what modules
|
||||||
* introduces what types), like this:
|
* introduces what types), like this:
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* new_type_id = g_type_register_dynamic (parent_type_id,
|
* new_type_id = g_type_register_dynamic (parent_type_id,
|
||||||
* "TypeName",
|
* "TypeName",
|
||||||
* new_type_plugin,
|
* new_type_plugin,
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
* The code in the example program below demonstrates #GValue's
|
* The code in the example program below demonstrates #GValue's
|
||||||
* features.
|
* features.
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* #include <glib-object.h>
|
* #include <glib-object.h>
|
||||||
*
|
*
|
||||||
* static void
|
* static void
|
||||||
|
@ -45,13 +45,13 @@
|
|||||||
* g_value_unset() as the clear function using g_array_set_clear_func(),
|
* g_value_unset() as the clear function using g_array_set_clear_func(),
|
||||||
* for instance, the following code:
|
* for instance, the following code:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GValueArray *array = g_value_array_new (10);
|
* GValueArray *array = g_value_array_new (10);
|
||||||
* ]|
|
* ]|
|
||||||
*
|
*
|
||||||
* can be replaced by:
|
* can be replaced by:
|
||||||
*
|
*
|
||||||
* |[
|
* |[<!-- language="C" -->
|
||||||
* GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10);
|
* GArray *array = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 10);
|
||||||
* g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
|
* g_array_set_clear_func (array, (GDestroyNotify) g_value_unset);
|
||||||
* ]|
|
* ]|
|
||||||
|
Loading…
Reference in New Issue
Block a user