mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
Annotate all examples with their language
The C ones, at least.
This commit is contained in:
@@ -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,
|
||||
|
@@ -47,7 +47,7 @@
|
||||
*
|
||||
* A typical implementation might look something like this:
|
||||
*
|
||||
* |[
|
||||
* |[<!-- language="C" -->
|
||||
* enum {
|
||||
* NOT_INITIALIZED,
|
||||
* INITIALIZING,
|
||||
|
@@ -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,
|
||||
|
@@ -105,7 +105,7 @@ g_cancellable_class_init (GCancellableClass *klass)
|
||||
* like this.
|
||||
*
|
||||
* An example of how to us this:
|
||||
* |[
|
||||
* |[<!-- language="C" -->
|
||||
* /* Make sure we don't do unnecessary work if already cancelled */
|
||||
* if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||
* return;
|
||||
|
@@ -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",
|
||||
|
@@ -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" -->
|
||||
* /* foo-bar-error.h: */
|
||||
*
|
||||
* #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
|
||||
* 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)",
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
*
|
||||
* /* Register an extension point */
|
||||
@@ -85,7 +85,7 @@
|
||||
* g_io_extension_point_set_required_type (ep, MY_TYPE_EXAMPLE);
|
||||
* ]|
|
||||
*
|
||||
* |[
|
||||
* |[<!-- language="C" -->
|
||||
* /* Implement an extension point */
|
||||
* G_DEFINE_TYPE (MyExampleImpl, my_example_impl, MY_TYPE_EXAMPLE);
|
||||
* 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
|
||||
* allocation for itself).
|
||||
*
|
||||
* |[
|
||||
* |[<!-- language="C" -->
|
||||
* /* a stream that can grow */
|
||||
* stream = g_memory_output_stream_new (NULL, 0, realloc, free);
|
||||
*
|
||||
|
@@ -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;
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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",
|
||||
|
@@ -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); /* assume not NULL */
|
||||
* ]|
|
||||
* then the expression
|
||||
* |[
|
||||
* |[<!-- language="C" -->
|
||||
* (g_file_has_prefix (volume_activation_root, mount_root) ||
|
||||
g_file_equal (volume_activation_root, mount_root))
|
||||
* ]|
|
||||
|
Reference in New Issue
Block a user