This is a list of the most frequently asked questions for the Glade GTK+/GNOME user interface builder.
In the GNOME version of Glade the Quick-Start Guide, Manual, and FAQ are available from the Help menu. Unfortunately these do not cover all aspects of using Glade yet.
There are a few other docs available on the web:
Spanish Guide - tigre.aragon.unam.mx/m3d/links_es.htm
Italian Guide - digilander.iol.it/robang/glade
I don't think there are any books specifically about Glade, though I have seen a chapter on Glade in a book from Wrox press for Linux developers.
I'll add links to documentation to Glade's home page at glade.pn.org as they become available.
Glade includes a simple text editor example application in the examples/editor directory. If you have a binary-only package of Glade (e.g. an RPM), these files may possibly be installed in /usr/doc/glade-X.X.X. If you can't find it, download the Glade tarball from glade.pn.org.
The web site contains links to quite a few applications created using Glade. These may contain useful example code. See the 'Applications' page on glade.pn.org.
This is not a bug in Glade! In GTK+ you use containers to lay out your widgets. The commonly-used containers are at the bottom of the main page on the palette. Try adding a vertical box to a window in Glade. Now add a table to one of the positions in the vertical box. Do you get the idea now?
If you really want to position widgets at specific coordinates, try the Fixed container. However, this isn't recommended since your windows/dialogs will not look good when resized, and if you translate the text in the labels and buttons into other languages they may not fit.
You can use standard GTK+ rc files to set the colors & fonts of your widgets. If you turn on the 'Set Widget Names' project option in Glade, that may make it easier to refer to your widgets, as you can refer to them by name. See the GTK+ Resource Files documentation at developer.gnome.org/doc/API/gtk/index.html.
You can also change a widget's style within your code by calling gtk_widget_modify_style(), e.g.
GdkColor red = { 0, 65535, 0, 0 }; GtkRcStyle *rc_style = gtk_rc_style_new (); rc_style->fg[GTK_STATE_NORMAL] = red; rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG; gtk_widget_modify_style (widget, rc_style); gtk_rc_style_unref (rc_style); |
Create a button and select Remove Label from the popup menu. You can then add any widgets you like to the button, e.g. a horizontal box with a pixmap and a label inside it. (Glade may make this even easier in future.)
Hold the 'Control' key when you select the widget in the Palette. It will then stay selected until you select another widget or the Selector.
I get this warning whenever I use a scrolled window: Gtk-WARNING **: gtk_scrolled_window_add(): cannot add non scrollable widget use gtk_scrolled_window_add_with_viewport() instead
You can safely ignore this warning. It is output by GTK+ to remind people to update their code, since the behaviour of scrolled windows changed quite a bit between GTK+ 1.0 and GTK+ 1.2. But the Glade code is OK. The warning should not appear in your final application.
If you are creating a GTK+ application, your graphics must be in XPM format. (GTK+ 2.0 will include the gdk-pixbuf library and so will support many more graphics formats.)
If you are creating a GNOME application, most graphics formats can be used. Though the PNG format is preferred for most graphics such as icons.
You can convert images between formats using the GIMP graphics application or the 'convert' utility in the ImageMagick toolkit.
Follow these steps:
Select the widget you want to add the handler to.
Select the 'Signals' page in the Property Editor window.
Click the '...' button to the right of the 'Signal:' field. This should show a popup window listing the signals that this widget emits.
In the popup window, select which signal you want to connect a handler for and hit the 'OK' button.
Glade automatically creates a name for the signal handler function in the 'Handler:' field, but you are free to change this if you desire.
Click the 'Add' button to add it to the list of signal handlers for this widget.
When you generate the C source code, an empty signal handler function should be output in the callbacks.c file. You can add your code to this function.
You need automake >= 1.4 & autoconf >= 2.13 to build the generated C code. You also need gettext >= 0.10.35 if you enabled gettext support. See the Requirements section in the README file for links to these.
Run ./autogen.sh in the toplevel directory of the project to run automake, autoconf and the related utilities to build the Makefile's. Pass it any options you want passed to configure, e.g. ./autogen.sh --prefix /usr/local/gnome.
Then run make to build your application.
Note that for GNOME applications, you must also do a make install so that the pixmaps are installed properly. If you don't do that, it will still run, but you won't see the pixmaps.
This means that the gtk.m4 file cannot be found. (gtk.m4 is a set of m4 macros which is installed as part of GTK+ and is used to build programs which use GTK+.) aclocal (part of automake) searches for these macros to add to aclocal.m4 in your program's root directory.
To find out where GTK+ is installed, run gtk-config --prefix. The gtk.m4 file should be in the share/aclocal subdirectory. To find out the directory that aclocal is using, run aclocal --print-ac-dir.
You should add the directory that the GTK+ m4 file is installed to the ACLOCAL_FLAGS environment variable, e.g. if the GTK+ m4 files are in /usr/local/share/aclocal, then add this to your $HOME/.profile: export ACLOCAL_FLAGS="-I /usr/local/share/aclocal/".
I get this error: ** CRITICAL **: file glade_gnome.c: line 939 (glade_gnome_write_menu_item_source): assertion `source_buffer != NULL' failed.
You are trying to use Gnome stock menu items in a GTK+-only app. Edit any menus you have and make sure the "Stock" property is set to "None" for every item.
These are the default output files, but some of your file names may differ if you have changed the project options.
autogen.sh . A script which runs automake, autoconf and the related programs in the correct order, making it very easy to build the application. You pass it any arguments you want to be passed to configure. After running it, you can type make to build the application.
configure.in . Standard script passed to autoconf to generate the configure script.
Makefile.am . Standard make rules passed to automake to generate the Makefile.in, which the configure script turns into Makefile.
acconfig.h .