Whole document tree

Whole document tree

Glade FAQ

1. Glade FAQ

This is a list of the most frequently asked questions for the Glade GTK+/GNOME user interface builder.

1. General Information About Glade
1.1.1. What documentation is there for Glade?
1.1.2. Is there any example code?
1.1.3. Do I have to use a particular license for the C code generated by Glade?
2. Creating A User Interface In Glade
1.2.1. When I add a widget to a window, it fills the whole window and I can't add any other widgets.
1.2.2. How do I change the colors of a widget, e.g. make a label red?
1.2.3. How do I add a pixmap to a button?
1.2.4. How do I add several widgets of the same type in one go?
1.2.5. 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
1.2.6. What graphics formats does Glade support?
1.2.7. How do I add a signal handler?
3. Building The C Code Generated By Glade
1.3.1. How do I build the code generated by Glade?
1.3.2. I get this error: aclocal: configure.in: 10: macro `AM_PATH_GTK' not found in library
1.3.3. I get this error: ** CRITICAL **: file glade_gnome.c: line 939 (glade_gnome_write_menu_item_source): assertion `source_buffer != NULL' failed.
4. Using The C Code Generated By Glade
1.4.1. What are all the files output by Glade?
1.4.2. What files can the developer edit safely and which files are overwritten?
1.4.3. How do I add my own source files to the project?
1.4.4. How do I add a library to the project?
1.4.5. How do I get a pointer to a widget from within a signal handler?
1.4.6. How do I get a pointer to a widget in another window?
1.4.7. How do I get the value of a GtkOptionMenu?
1.4.8. How do I get a GtkOptionMenu to call a function when it changes?
1.4.9. How do I connect to GtkAdjustment signals?
1.4.10. How do I add rows to a GtkCList before the window is shown?

2. Creating A User Interface In Glade

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);

3. Building The C Code Generated By Glade

4. Using The C Code Generated By Glade

These are the default output files, but some of your file names may differ if you have changed the project options.

If gettext support is enable, the po directory is created, with POTFILES.in and a separate ChangeLog. POTFILES.in lists the source files which contain translatable strings, and you should add any source files you create here.

For GNOME projects the macros directory is also added, containing all the m4 macros used to build the project. (These should really have been installed as part of GNOME, but unfortunately this wasn't done in GNOME 1.0.X. Hopefully this will be fixed in a future version of GNOME, and so this directory will not be needed.)

If you change the Gnome Support or Gettext Support project options after building the project, you will need to update some of the build files such as configure.in and Makefile.am. The best solution may be to change the project directory in the Project Options dialog, and to rebuild the project from scratch. However, you would have to copy over any code you have added to signal handlers. An alternative would be to delete autogen.sh, configure.in, Makefile.am, src/Makefile.am, and src/main.c and use Glade to recreate them. But if you have changed these files you will need to add the changes back in. (Hopefully Glade will deal with this better in future.)

This FAQ was written by Damon Chaplin (). Please send all comments and suggestions regarding this manual to the author. For more information on Glade or the Glade mailing lists, please visit the Glade Home Page.