Next: , Previous: array-list-store, Up: Gtk+ Objects


6.4.7 builder

— Class: builder

Superclass: g-object

A builder is an auxiliary object that reads textual descriptions of a user interface and instantiates the described objects. To pass a description to a builder, call builder-add-from-file or builder-add-from-string or use :from-file or :from-string initialization arguments. These functions can be called multiple times; both initargs may be specified; the builder merges the content of all descriptions.

A builder holds a reference to all objects that it has constructed and drops these references 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 to get rid of them and all the widgets they contain.

The function builder-get-object 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, or without a parent, in which case they have to be added to some container to make use of them.

The functions builder-connect-signals-simple and builder-connect-signals-full can be used to connect handlers to the named signals in the description.

Slots:

Signals:

— Function: builder-add-from-file
     (builder-add-from-file builder file-name)

Parses a file containing a GtkBuilder UI definition and merges it with the current contents of builder

— Function: builder-add-from-string
     (builder-add-from-string builder string)

Parses a string containing a GtkBuilder UI definition and merges it with the current contents of builder.

— Function: builder-get-object
     (builder-get-object builder name)

Gets the object named name.

— Function: builder-connect-signals-simple
     (builder-connect-signals-simple builder handlers-list)

Connects the signal handlers to objects. handler-list is a plist mapping from signal handler names to signal handler functions.

Example:

     (builder-connect-signals-simple builder `(("new" ,#'new) ("open" ,#'cb-open)))

— Function: builder-connect-signals-full
     (builder-connect-signals-full builder func)

Connects the signals handlers to objects. func is a function that maps signal handler name to signal handler function. Its signature is (function (builder object signal-name handler-name connect-object flags)). The func function should connect the signal handler named handler-name for signal-name of object. connect-object should be ignored. flags specifies the behavior of signal connection (:after if the handler should be called before or after the default handler of the signal; :swapped if the instance and data should be swapped when calling the handler).