## Extending Libglade

In some cases, libglade may not provide support for the widgets you want to use, or you may want to insert a bit of hand coded interface into the larger libglade generated interface. Libglade provides support for doing this.

If you are only need a few custom widgets (eg. a word processor may have a custom widget for the document editing area), the simplest choice is probably Glade's custom widget. It allows you to specify a custom function that will be used to create the widget. The signature of the function is as follows:

    GtkWidget *custom_func(gchar *widget_name, gchar *string1, gchar *string2,
                           gint int1, gint int2);

When calling this function, widget_name is the name of the widget given in the XML file, and `string1`, `string2`, `int1` and `int2` are arbitrary constants whose values also come from the XML file. Libglade supports the custom widget using gmodule. For most cases, this is sufficient.

If you wish to get libglade to recognise a new widget type directly, your best option is to ensure that it implements properties for all settings required to construct the widget, and packing properties if the widget happens to be a container. If the widget satisifies this requirement, libglade will support the widget with no extra code (provided the widget's `get_type()` function has been called to register it with GLib).

If a widget has more complex requirements, a libglade module must be written (or if the library containing the widget already depends on libglade, it may build the module in). In the module, a widget construction routine and a build children routine must be registered. If the widget can be manipulated via properties for construction or adding children, `glade_standard_build_widget` or `glade_standard_build_children` can be used here.

If the widget mostly supports properties, custom handlers for particular properties can be registered with `glade_register_custom_prop`.

If the widget implements no properties (and you have no way to convince the author to do so), you will most likely need to implement custom handlers for construction and adding children.

For a more extensive example of registering new widget types and build functions, see `glade/glade-gtk.c` in the libglade package. For more information on the exact API's used to register new widget types with libglade, see the Libglade Build section of this manual.