GTK+/Gnome Application Development Errata
Unfortunately, my beautiful book contains mistakes... but on
this page, I will tell you about them. Some of these errors may be
fixed in the second press run of the book, but for now only the first
run is available. Some of these are simple typos, others are
technical screwups.
Please note that these are mistakes in the printed version of the
book; the electronic version has its own special set of errors, but no
errata page since I just fix the book itself. Note that the electronic
version is lacking an editing pass that the printed book has
undergone.
- Copyright Page: My first name is misspelled.
- Acknowledgements: Marius and James wrote the language bindings for the Guile and Python programming languages; they didn't write "The Python" or "Guile bindings for GTK+/Gnome" (though those sound like interesting novels...)
- Page 6 (Section 1.2.2.1): It's "Enlightened Sound Daemon," not "Enlightenment Sound Daemon." Thanks to Eric Mitchell (ricdude).
- Page 19 (Section 2.1.5): a printf() format is missing the percent signs. Thanks to Michael Johnson.
- Page 16 (Section 2.1.4): Jon Trowbridge points out that
malloc() returns char* only in pre-ANSI C; which is
what I meant, but in retrospect I shouldn't have bothered to mention
it at all since glib won't compile on a pre-ANSI compiler.
- Page 16 (Function Listing 2.1): The glib.h is
missing after the #include. Thanks to Jon Trowbridge.
- Page 23 (Function Listing 2.9): Missing # on the include. Thanks to Jon.
- Page 25 (Function Listing 2.11): Missing # on the include. Thanks to Jon.
- Page 25 (Section 2.2.1): Building a linked list by calling g_slist_insert_sorted() in a loop is an O(n^2) algorithm, not an exponential algorithm. Thanks to Dave Peticolas for pointing this out.
- Page 40 (Section 3.1.2.1): It says when you fork(), you have to exit
the child with atexit() - this is nonsense and not my fault, a well-meaning copy editor changed it. :-) It should say you must exit the child with _exit(). Thanks to Michael Johnson for catching this.
- Page 60 (Function Listing 3.10): %void should be
just void. Thanks to John Gotts.
- Page 105 (Section 5.5.1): The callback connected to the
"die" signal of GnomeClient should return
void, not gint. This is an evil genetic bug; one of
the first session-managed Gnome apps got it wrong, and everyone else
used the buggy code as an example. :-) On the up side, it doesn't
really matter since the purpose of the "die" handler is to
exit the app, so these handlers never return anyway.
- Page 110 (Section 6.2): the GnomeUIInfo sample struct
initializer in the middle of the page is missing the last
element. This doesn't actually hurt anyting, since gnome-libs will
only write to that field not read from it, and the C compiler accepts
it; but it's sort of confusing/ugly. Thanks to James O'Kane.
- Page 111 (Table 6.1 caption): GnomeUIInfoType, not GnomeUIInfo Type. Thanks to Michael Johnson.
- Page 119 (Section 6.4.3): I totally mangled the tooltips
description, Owen pointed out. A GtkTooltips is meant to hold the tips
for multiple widgets. So don't use the set_tooltip()
convenience function; instead, create a single GtkTooltips for a
logical group of widgets (such as the buttons on a toolbar) and call
gtk_tooltips_set_tip() with the same GtkTooltips object for multiple
widgets. Big screwup, sorry about that...
- Page 120 (Section 6.5.2): It may be confusing that I say
the class name is capitalized, then give the studly-caps example
XTerm. A better example might be emacs and
Emacs. Thanks to James O'Kane.
- Page 131 (Section 7.3): The dialog code here is in C++, I
cut it out of some C++ code and forgot to move all the variable
declarations to the top of the scope. To compile on a C compiler, move
the variable declarations to the top of the code example. Thanks to
Jacob Berkman.
- Page 179 (Section 9.8): The destroy notification function
registered with gtk_object_set_data_full() is invoked when
the object is finalized, not when the object is
destroyed; my language was a bit sloppy. This is a fine point
and usually not important; but see Section 9.7 for an explanation.
- Page 197 (Section 10.5.2): It says you should use gtk_widget_set_events() after you realize the widget, but really you should use it before you realize the widget. Doh. Thanks to Tomi Ollila for finding this bug.
- Page 217 (Function Listing 10.8): An argument is omitted
from gdk_pointer_grab(); the third argument, between the
owner_events flag and confine_to window, should be
GdkEventMask event_mask, the events to receive during the grab.
Thanks to Stuart Parmenter (Pavlov).
- Page 222 (Section 10.7.1): The font metrics diagram is a
bit suboptimal. I recommend the one in Xlib Programming Manual,
a book worth owning anyway.
- Page 225 (Table 10.6): gdk_gc_set_font() should have parentheses
after it.
Clarifications
Some things the book tells you, that perhaps need more elaboration.
Throughout, if you're copying example code taken from GTK+ itself
(such as the GtkBox code in the chapter on widgets), you
might consider looking at the latest version of GTK+ in case bugs have
been fixed.
In chapter 3, it tells you not to use
gtk_widget_set_usize(). This is perhaps on overstatement;
sometimes it's useful if a widget has no "natural" size, such as the
height dimension of a list widget or the width of an entry
widget. However, you should almost certainly avoid it for toplevel
windows, and for container widgets in general. Use GtkTable, GtkBox,
GtkAlignment, and the built-in alignment-like properties of GtkMisc to
avoid the need to hardcode the size.
In section 3.4.5, it says that "strictly speaking, input functions
are independent of the GTK+ main loop." This is misleading. Input
functions are part of the glib main loop abstraction, which GTK+
uses. But they are not wrapped on the GTK+ level, while many of the
glib main loop features are.
Havoc Pennington