
You may wonder why I'm using libglade at all for this. The reason is to promote the use of libglade and show examples of how libglade can be used in combination with C/GTK+ generated widgets.
Information Dialog |
Warning Dialog |
Error Dialog |
Question Dialog |
Compiling the Project
Download the glade file (gui.glade) and the source code (main.c) here: dialogs1.tar.gz On my machine, the code was compiled with: gcc -o dialogs -Wall -g main.c `pkg-config gtk+-2.0 --cflags --libs `-I/usr/include/libglade-2.0 -lglade-2.0 You may have to modify the include path for your distribution's location of libglade. I also have the code written such that the glade file gui.glade must exist in the same path as the executable.Connecting the Signals
I'm defining the signals in the glade file, however, I'm connecting them individually as opposed to using glade_xml_signal_autoconnect(). The reason for this is because I simply have gotten in the habbit of doing so. In this case, some, but not all of the signals have user data passed to them. For example:glade_xml_signal_connect_data (gxml, "on_info_button_clicked",
G_CALLBACK(on_info_button_clicked), main_window);
In this case, the main_window, which is a pointer to my main window, is being passed as user data to the callback function. This allows me to setup the message box with the main_window as the "parent" for the dialog box.
Information Dialog
Warning Dialog
Error Dialog
Question Dialog