Libglade Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# 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 new widget types, you will need to do a bit more work. You will need to write a function that will create the widget from a node in the XML tree (the function need not worry about standard options like whether the widget is visible or not, or how it is added to its parent). If the widget is also a container, you will need to specify a child building function (which is also responsible for adding the widgets to container). If the container uses the standard `gtk_container_add` interface, you can use the `glade_standard_build_children` function that is provided by libglade.

For a more extensive example of registering new widget types and build functions, see the files `glade/glade-gtk.c` or `glade/glade-gnome.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.

<<< Previous Page | Home | Up | Next Page >>>
Internationalisation with Libglade | Embedding Libglade Interfaces