mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
Annotate all examples with their language
The C ones, at least.
This commit is contained in:
@@ -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,
|
||||
|
@@ -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); /* GObject doesn't really need this */
|
||||
* ]|
|
||||
* 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)
|
||||
|
@@ -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,
|
||||
|
@@ -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" -->
|
||||
* /* save floating state */
|
||||
* 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)
|
||||
|
@@ -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;
|
||||
*
|
||||
|
@@ -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,
|
||||
|
@@ -55,7 +55,7 @@
|
||||
* The code in the example program below demonstrates #GValue's
|
||||
* features.
|
||||
*
|
||||
* |[
|
||||
* |[<!-- language="C" -->
|
||||
* #include <glib-object.h>
|
||||
*
|
||||
* static void
|
||||
|
@@ -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);
|
||||
* ]|
|
||||
|
Reference in New Issue
Block a user