LJ Archive

GNOME/GTK+ Programming Bible

Ben Crowder

Issue #79, November 2000

A solid introduction and reference to both GTK+ and GNOME programming.

  • Author: Arthur Griffith

  • Publisher: IDG Books Worldwide

  • URL: http://www.idg.com/

  • Price: $39.99 US

  • ISBN: 0-7645-4640-6

  • Reviewer: Ben Crowder

It all began with the GIMP. Years back, the developers of the famous image processing program realized that Motif (a toolkit for X Windows) wasn't as good as they had thought, but there wasn't much else out there to choose from. So they wrote their own widget set, GTK+. Then, later on, came GNOME, which wrapped around GTK+ and provided higher-level widgets (like the calendar and the calculator). It can all get rather confusing at times, which is where The GNOME/GTK+ Programming Bible comes in.

The book is a solid introduction and reference to both GTK+ and GNOME programming. It is liberally scattered with code (roughly a third of the book consists of examples and sample code, all of which is on the accompanying CD-ROM), and includes line-by-line explanations for most of the samples.

Chapter One introduces GTK+ and GNOME, explaining how GTK+ is object-oriented although it's written in C, as well as sketching out what signals and callbacks are. The second chapter is a tutorial on a very basic GTK+ program, a window with a button. It also covers how to create a basic GNOME window. In Chapter Three, you learn how GTK+ and GNOME pop-ups and dialogs work. The GTK+ method of packing widgets is, admittedly, different from most other windowing systems, and the fourth chapter covers just that by explaining packing boxes and tables. Virtually infinite flexibility comes with the ability to pack widgets inside of other widgets (i.e., tables within boxes within notebooks within scrolled windows within tables, ad infinitum). Chapter Five explains how this works, showing you the way to endless hours of packing pleasure. The glues that hold GTK+ together—events, signals and callbacks—are described in Chapter Six.One main point of GUIs is the ability to have graphical representations on the screen, <\#225> la icons and other pictures. Chapter Seven explains the XBM and XPM formats and how to use them in your programs. Finally, the eighth chapter covers menus and toolbars—stock menus, disabling/enabling menu items, and radio/toggle buttons in toolbars and menus.

Part II contains step-by-step instructions on a variety of GTK+/GNOME subjects. Chapter 9 covers the GnomeCanvas widget, Chapter Ten describes the GTKDrawingArea widget, and Chapter 11 explains how to use graphic contexts. Input devices are important in any type of interface, so Chapter 12 is devoted entirely to the mouse and the keyboard. Chapter 13 provides some basic instruction on using fonts, and Chapter 14 shares some tricks for working with widgets. GNOME applets are covered in the fifteenth chapter, and drag-and-drop is described in the sixteenth. MDI (Multiple Document Interface, used for having more than one document open at a time) is explained in Chapter 17. From time to time, you'll realize the widget you need doesn't exist. There may be something similar, but it doesn't quite do what you want. Chapter 18 shows you how to create your own widget, either from scratch or based on another one. Chapter 19 explores configuration (manipulating the config files found in your ~/.gnome directory) and internationalization.

The third part of the book is primarily a reference; and a very useful one at that. I would recommend this book for the third part and the appendices alone. For those who would rather compile it themselves instead of downloading a prepackaged version, chapter 20 explains how to install and build the GNOME source code. Chapter 21 is a list of GTK+ widgets, from GtkAccelLabel to GtkWindow, with information on each (such as inheritance, function lists and example code). Chapter 22 does the same for GNOME widgets. While GNOME is multi-platform, it is primarily used under Linux; thus, there are some Linux-specific issues which are covered in Chapter 23. Finally, for those programmers migrating over from Windows, Chapter 24 provides a comparative, point-by-point study of how Win32 and GNOME programming differ.

The appendices are quite useful as well, and they are where much of the meat in the reference section is located. The first appendix simply describes the contents of the CD-ROM, while the second explains how to set up your machine for software development with GNOME. The third appendix lays out the inheritance for each widget in GTK+ and GNOME, the fifth explains how to set and get arguments, and the fourth covers enumerated types used in GTK+ and GNOME (such as GTK_ACCEL_SIGNAL_VISIBLE). The sixth appendix lists all the signals, and the final appendix provides a useful list of functions, sorted by return type.

Is it worth the money? If you're interested in programming with GTK+ and/or GNOME, then the answer is a resounding yes. And even if you're not, it's a cool-looking Linux book that can sit on your desk and make you look smarter.

Ben Crowder has been heavily involved with computers for the past ten years, in almost every aspect (programming, graphics, networking, music and just about anything else you can think of). He has been working with Linux for the past two and a half years and has loved every second of it. In his spare time, he enjoys reading, writing, music and tweaking things on his Linux box. He currently lives in Utah and can be reached at crowder@netbrick.com.

LJ Archive