As the Linux phenomenon (some would say "spectacle") continues to roll across and change the computing landscape, it's also evolving. New applications are being ported to or written for Linux, and more companies are joining its merry caravan on a daily basis -- even if with varying degrees of sincerity. One of the more interesting signs of growing industry support for Linux is the availability of books, particularly those for programmers from major publishers, which makes Peter Wright's Beginning GTK+/GNOME Programming (BGGP) all the more interesting.
In BGGP, Wright presents a well-balanced and surprisingly complete overview of GUI programming for Linux using the GTK+ toolkit and the GNOME libraries. While it might be tempting to think of this book as "Petzold for Linux" (referring to Charles Petzold's classic Programming Windows), that wouldn't be accurate. Wright limits himself to GUI programming with GTK+ and GNOME, and doesn't cover shared memory operations, IPC (interprocess communication) mechanisms, file handling, or any of the other topics that typically fill an intro-to-Linux programming book. If anything, devoting the entire book to this topic makes it more useful, as many programmers will learn Linux in stages, with GUI programming being its own portion of the education.
BGGP contains 19 chapters and five appendices that take you from an introduction to the system libraries and components, through the basics of building an application that uses them, and then on to the expected grand tour of the available widgets. The book's subject matter is inherently layered -- GNOME is built atop the GTK+ libraries -- and Wright follows its lead, spending chapters 3 through 10 on GTK+, and chapters 11 through 15 on GNOME. Aside from being a natural way to present the material, this should also help you restrict yourself to using just the facilities of GTK+, so that your programs will run on systems that don't have the GNOME libraries installed, a common situation among KDE users.
In covering the widgets, Wright presents numerous examples and does an admirable job of anticipating how programmers will want to use various widgets and then presenting the material in a logical progression. For example, in his chapter on menus, he starts with the basics of creating menus and connecting them to your custom signal handlers, then adds radio buttons to the menu entries and using keyboard accelerators. He then discusses GTK+'s item factory facility, which can somewhat automate the process of creating menus, and finally treats using context/pop-up menus.
It's worth mentioning that throughout the book, Wright assumes that you are familiar with C, a safe enough bet in a book aimed at Linux programmers, but he still wisely avoids using "black-belt level" C, and codes his examples in a clean and readable style.
Two of the more useful chapters, in terms of boosting your programming productivity, are 16 and 17, which present the GNOME integrated development environment (gIDE) and Glade, a RAD-like GUI design tool, respectively. Books like this one often make the mistake of marching lockstep through an API and ignoring the real-world considerations we all have to face, such as tool selection. Luckily, this one didn't follow that pattern.
BGGP spends a fair amount of time on the low-level mechanics of working with dialogs and application windows, controlling the layout of widgets within a window, modality issues, closing down windows properly, and so on. I suspect these parts of the book will be used often as references.
There are still a few things to nit-pick about regarding this book. First and most trivially, there's no CD-ROM. While the code samples are freely available from Wrox's web site, it's a bit bothersome to pay $40.00 for a book (even a good one like BGGP) and still have to go hunt down the source code online.
A more serious issue is some of Wright's coding samples. No author can illustrate every conceivable way to combine the facilities of large and complex APIs, obviously, but some of Wright's examples were a little on the simplistic side. Chapters 18 and 19 do present a pair of more involved examples, but there were several places earlier in the book where I had hoped he would provide a somewhat more extensive program, or even illustrated why a particular API he mentioned was useful, such as gtk_signal_disconnect().
Finally, I would have liked to find more in BGGP about making applications that integrate and react with GNOME. Wright does mention how to add a configuration file to an application that will make your program appear on the GNOME menu (in the calculator example in Chapter 17), but in today's minefield of library version and other distribution issues, more on this topic would have been welcome. Perhaps this topic was a victim of the book's tight focus on being an introduction, but it's never too early to start cultivating good habits in these areas among programmers.
Anyone who needs to come up to speed in GTK+ and GNOME programming should benefit from reading BGGP. Even though it's probably not the only book you'll want on your shelf about this topic, the author's tight focus, thoroughness, and comfortable writing style make it a relatively painless way to learn (or relearn) GUI programming.
Electronic Review of Computer Books