## Building user interfaces

When construcing a more complicated user interface, with dozens or hundreds of widgets, doing all the setup work in C code is cumbersome, and making changes becomes next to impossible.

Thankfully, GTK+ supports the separation of user interface layout from your business logic, by using UI descriptions in an XML format that can be parsed by the GtkBuilder class.

Example 4. Packing buttons with GtkBuilder

Create a new file with the following content named example-4.c.

    FIXME: MISSING XINCLUDE CONTENT

Create a new file with the following content named builder.ui.

    FIXME: MISSING XINCLUDE CONTENT

You can compile the program above with GCC using:

`gcc `pkg-config --cflags gtk+-3.0` -o example-4 example-4.c `pkg-config --libs gtk+-3.0``

Note that GtkBuilder can also be used to construct objects that are not widgets, such as tree models, adjustments, etc. That is the reason the method we use here is called `gtk_builder_get_object()` and returns a GObject* instead of a GtkWidget*.

Normally, you would pass a full path to `gtk_builder_add_from_file()` to make the execution of your program independent of the current directory. A common location to install UI descriptions and similar data is `/usr/share/`appname``.

It is also possible to embed the UI description in the source code as a string and use `gtk_builder_add_from_string()` to load it. But keeping the UI description in a separate file has several advantages: It is then possible to make minor adjustments to the UI without recompiling your program, and, more importantly, graphical UI editors such as glade can load the file and allow you to create and modify your UI by point-and-click.