diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 727adb78d7..458a3e7e4a 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -99,9 +99,7 @@ * Objects are described by `` elements, which can contain * `` elements to set properties, `` elements which * connect signals to handlers, and `` elements, which describe - * child objects (most often widgets inside a container, but also e.g. - * actions in an action group, or columns in a tree model). A `` - * element contains an `` element which describes the child object. + * child objects. * * Typically, the specific kind of object represented by an `` * element is specified by the “class” attribute. If the type has not @@ -173,6 +171,53 @@ * exception to this rule is that an object has to be constructed before * it can be used as the value of a construct-only property. * + * ### Child objects + * + * Many widgets have properties for child widgets, such as + * [property@Gtk.Expander:child]. In this case, the preferred way to + * specify the child widget in a ui file is to simply set the property: + * + * ```xml + * + * + * + * ... + * + * + * + * ``` + * + * Generic containers that can contain an arbitrary number of children, + * such as [class@Gtk.Box] instead use the `` element. A `` + * element contains an `` element which describes the child object. + * Most often, child objects are widgets inside a container, but they can + * also be, e.g., actions in an action group, or columns in a tree model. + * + * Any object type that implements the [iface@Gtk.Buildable] interface can + * specify how children may be added to it. Since many objects and widgets that + * are included with GTK already implement the `GtkBuildable` interface, + * typically child objects can be added using the `` element without + * having to be concerned about the underlying implementation. + * + * See the [`GtkWidget` documentation](class.Widget.html#gtkwidget-as-gtkbuildable) + * for many examples of using `GtkBuilder` with widgets, including setting + * child objects using the `` element. + * + * A noteworthy special case to the general rule that only objects implementing + * `GtkBuildable` may specify how to handle the `` element is that + * `GtkBuilder` provides special support for adding objects to a + * [class@Gio.ListStore] by using the `` element. For instance: + * + * ```xml + * + * MyObject + * + * + * + * ... + * + * ``` + * * ### Property bindings * * It is also possible to bind a property value to another object's @@ -208,6 +253,11 @@ * For more information, see the documentation of the * [method@GObject.Object.bind_property] method. * + * Please note that another way to set up bindings between objects in .ui files + * is to use the `GtkExpression` methodology. See the + * [`GtkExpression` documentation](class.Expression.html#gtkexpression-in-ui-files) + * for more information. + * * ### Internal children * * Sometimes it is necessary to refer to widgets which have implicitly diff --git a/gtk/gtkexpression.c b/gtk/gtkexpression.c index 3eebb27fe7..eba1a868b0 100644 --- a/gtk/gtkexpression.c +++ b/gtk/gtkexpression.c @@ -150,9 +150,10 @@ * Hello, world * ``` * - * To create a closure expression, use the `` element. The `type` and `function` - * attributes specify what function to use for the closure, the content of the element - * contains the expressions for the parameters. For instance: + * To create a closure expression, use the `` element. The `function` + * attribute specifies what function to use for the closure, and the `type` + * attribute specifies its return type. The content of the element contains the + * expressions for the parameters. For instance: * * ```xml * @@ -160,6 +161,22 @@ * myfile * * ``` + * + * To create a property binding, use the `` element in place of where a + * `` tag would ordinarily be used. The `name` and `object` attributes are + * supported. The `name` attribute is required, and pertains to the applicable property + * name. The `object` attribute is optional. If provided, it will use the specified object + * as the `this` object when the expression is evaluated. Here is an example in which the + * `label` property of a `GtkLabel` is bound to the `string` property of another arbitrary + * object: + * + * ```xml + * + * + * some_other_object + * + * + * ``` */ typedef struct _WeakRefGuard WeakRefGuard; diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index ed0b071730..6a77fbb519 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -518,12 +518,10 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) * on_output (GtkSpinButton *spin, * gpointer data) * { - * GtkAdjustment *adjustment; * char *text; * int value; * - * adjustment = gtk_spin_button_get_adjustment (spin); - * value = (int)gtk_adjustment_get_value (adjustment); + * value = gtk_spin_button_get_value_as_int (spin); * text = g_strdup_printf ("%02d", value); * gtk_editable_set_text (GTK_EDITABLE (spin), text): * g_free (text);