![]()
|
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.74b">
Libglade Programming NotesLibglade is an alternative to using Glade's code generation. Instead of generating code from the XML interface description, libglade loads and parses the description at runtime. It also provides functions that can be used to connect signal handlers to parts of the interface. In this way, it allows you to separate your program code from the interface code. In fact, if you use the simple as the test-libglade.c example that comes with libglade. Of course, you would also add your own signal handlers to the code. Note that the signals are connected the same way as if you had hand coded the interface. There is no extra overhead to user interfaces constructed by libglade (after the initial generating of course, and this is not much of an overhead) when compared to a hand crafted interface. Libglade Programming BasicsYour basic libglade program will look something like this:
This will create the interface from the file filename.glade, then connect all the signals in the interface. The automatic signal connection is done by looking up function names in the global symbol table using gmodule. This means that the interface file can use standard GTK functions such as gtk_widget_show, or gtk_main_quit, or others in the interface and not have to write any code to connect the signals. The some_signal_handler_func function is not referenced anywhere in the program explicitely, but if any signals are defined in the interface description that use "some_signal_handler_func" as the handler name, then this function will automatically be connected. Note that the function can not be static, since we require it to apear in the symbol table. Here is an example of the XML that would cause some_signal_handler_func to be connected:
To compile the program, we would use the following:
The pkg-config program is used to deduce the compiler and link flags necessary to compile various modules. If you are using automake or autoconf, you probably want to use the PKG_CHECK_MODULES macro. This can be used to check for the presence of a collection of a number of packages, and set some shell variables:
|