From 6a66da995b110aff64ff6b92241cb4fa9478abe6 Mon Sep 17 00:00:00 2001 From: Dieter Verfaillie Date: Fri, 18 Feb 2011 21:45:02 +0100 Subject: reference: pygtk-gtkbuilder.xml: update description --- docs/reference/pygtk-gtkbuilder.xml | 113 +++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 46 deletions(-) (limited to 'docs') diff --git a/docs/reference/pygtk-gtkbuilder.xml b/docs/reference/pygtk-gtkbuilder.xml index 57451ff1..f9354083 100644 --- a/docs/reference/pygtk-gtkbuilder.xml +++ b/docs/reference/pygtk-gtkbuilder.xml @@ -115,9 +115,9 @@ is an auxiliary object that reads textual descriptions of a user interface and instantiates the described objects. To pass a description to a gtk.Builder, call - add_from_file or - add_from_string. - These functions can be called multiple times; the builder merges the content of all descriptions. + add_from_file() or + add_from_string(). + These methods can be called multiple times; the builder merges the content of all descriptions. A gtk.Builder @@ -125,21 +125,21 @@ when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to call - gtk.Widget.destroy + gtk.Widget.destroy() to get rid of them and all the widgets they contain. - The functions get_object - and get_objects + The methods get_object() + and get_objects() can be used to access the widgets in the interface by the names assigned to them inside the UI description. - Toplevel windows returned by these functions will stay around until the user explicitly - destroys them with gtk_widget_destroy(). Other widgets will either be part of a larger - hierarchy constructed by the builder (in which case you should not have to worry about their - lifecycle), or without a parent, in which case they have to be added to some container to make - use of them. + Toplevel windows returned by these methods will stay around until the user explicitly + destroys them with gtk.Widget.destroy(). + Other widgets will either be part of a larger hierarchy constructed by the builder (in which case you + should not have to worry about their lifecycle), or without a parent, in which case they have to be added + to some container to make use of them. - The function connect_signals + The methods connect_signals() and variants thereof can be used to connect handlers to the named signals in the description. @@ -153,56 +153,70 @@ + + - - - - - - + + + + + + ]]> The toplevel element is <interface>. It optionally takes a "domain" attribute, which will make the builder look for translated strings using dgettext() in the domain specified. This can also be done by calling - set_translation_domain + set_translation_domain() on the builder. Objects are described by <object> elements, which can contain <property> elements to set properties, <signal> elements which connect signals to handlers, and <child> 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 <child> element contains an <object> - element which describes the child object. + element which describes the child object. The target toolkit version(s) are described by <requires> + elements, the "lib" attribute specifies the widget library in question (currently the only supported value + is "gtk+") and the "version" attribute specifies the target version in the form "<major>.<minor>". + The builder will error out if the version requirements are not met. Typically, the specific kind of object represented by an <object> element is specified by the "class" attribute. If the type has not been loaded yet, GTK+ tries to find the _get_type() from the class name by applying heuristics. This works in most cases, but if necessary, it is possible to specify - the name of the _get_type() explictly with the "type-func" attribute. As a special case, GtkBuilder allows - to use an object that has been constructed by a GtkUIManager in another part of the UI definition by - specifying the id of the GtkUIManager in the "constructor" attribute and the name of the object - in the "id" attribute. + the name of the _get_type() explictly with the "type-func" attribute. As a special case, + gtk.Builder allows to use an object that + has been constructed by a gtk.UIManager + in another part of the UI definition by specifying the id of the + gtk.UIManager in the "constructor" attribute + and the name of the object in the "id" attribute. Objects must be given a name with the "id" attribute, which allows the application to retrieve them from - the builder with gtk_builder_get_object(). An id is also necessary to use the object as property - value in other parts of the UI definition. + the builder with get_object(). + An id is also necessary to use the object as property value in other parts of the UI definition. + + Prior to GTK+ 2.20, gtk.Builder + was setting the "name" property of constructed widgets to the "id" attribute. In GTK+ 2.20 or newer, you + have to use gtk.Buildable.get_name() + instead of gtk.Widget.get_name() + to obtain the "id", or set the "name" property in your UI definition. + Setting properties of objects is pretty straightforward with the <property>element: the "name" attribute specifies the name of the property, and the content of the element specifies the value. If the @@ -218,27 +232,29 @@ True, strings like "FALSE, "f", "no", "n", "0" are interpreted as False), enumerations (can be specified by their name, nick or integer value), flags (can be specified by their name, nick, integer value, optionally combined with "|", e.g. "gtk.VISIBLE|gtk.REALIZED") - and colors (in a format understood by gdk_color_parse()). Objects can be referred to by their name. + and colors (in a format understood by gtk.gdk.color_parse()). + Objects can be referred to by their name. Pixbufs can be specified as a filename of an image file to load. In general, GtkBuilder allows - forward references to objects — an object doesn't have to constructed before it can be referred to. + forward references to objects — an object doesn't have to be constructed before it can be referred to. The 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. Signal handlers are set up with the <signal> element. The "name" attribute specifies the name of the signal, and the "handler" attribute specifies the function to connect to the signal. By default, - GTK+ tries to find the handler using g_module_symbol(), but this can be changed by passing a custom - GtkBuilderConnectFunc to gtk_builder_connect_signals_full(). The remaining attributes, "after", "swapped" + GTK+ tries to find the handler using g_module_symbol(). The remaining attributes, "after", "swapped" and "object", have the same meaning as the corresponding parameters of the g_signal_connect_object() or g_signal_connect_data() functions. A "last_modification_time" attribute is also allowed, but it does not have a meaning to the builder. Sometimes it is necessary to refer to widgets which have implicitly been constructed by GTK+ as part of - a composite widget, to set properties on them or to add further children (e.g. the vbox of a GtkDialog). + a composite widget, to set properties on them or to add further children (e.g. the vbox of a + gtk.Dialog). This can be achieved by setting the "internal-child" propery of the <child> element to a true value. - Note that GtkBuilder still requires an <object> element for the internal child, even if it has - already been constructed. + Note that gtk.Builder + still requires an <object> element for the internal child, even if it has already been constructed. A number of widgets have different places where a child can be added (e.g. tabs vs. page content in @@ -282,6 +298,11 @@ the parent object, while a custom element in an <object> element gets parsed by the custom tag handler of the object. + + + These XML fragments are explained in the documentation of their respective objects in the + GTK+ Reference Manual. + -- cgit v1.2.1