Beginning GTK+/Gnome Programming

Beginning GTK+/Gnome Programming


GTK+ and GNOME provide you with a very powerful, yet easy-to-learn, object-oriented set of libraries to help you develop professional graphical interfaces. GTK+ and GNOME are exciting development technologies that allow you to create and manipulate windows, buttons, dialogs, menus, tool tips, status bars, toolbars, progress bars, horizontal and vertical scroll bars.…  See more details below


GTK+ and GNOME provide you with a very powerful, yet easy-to-learn, object-oriented set of libraries to help you develop professional graphical interfaces. GTK+ and GNOME are exciting development technologies that allow you to create and manipulate windows, buttons, dialogs, menus, tool tips, status bars, toolbars, progress bars, horizontal and vertical scroll bars. They also have facilities for handling colors and fonts. Programming in GTK+ and GNOME is made even easier by the availability of the powerful integrated development environment gIDE and project builder Glade. The visual appeal of the user interface that GTK+ /GNOME can create is limited only by the developer's imagination.

You'll learn all this and more from this book.

Who is this book for?

If you would like to contribute to the next big leap for Linux - the move into the desktop market, then this book is for you. It's useful for both the beginner who would like to learn about the infinite possibilities offered by the open source user interface programming, and the experienced programmer who would like to develop Linux applications with user-friendly graphical interfaces.

Have you installed Linux? Do you know simple C programming? That is all you need to start reading this book and developing very sophisticated and attractive graphical interfaces.

Read More

Editorial Reviews

Lou Grinzo

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

Read More

Product Details

Publication date:
Beginning Ser.
Edition description:
Product dimensions:
(w) x (h) x 0.05(d)

Read an Excerpt

Chapter 1: Welcome to GTK+/GNOME

Why does anyone set out to learn to write code using a new language or technology? You may be saying, "to write applications", but ultimately it's because the new technology offers something that you haven't had before. In the case of a language for example, it may be that the language offers new database or object-oriented programming facilities. In the case of a technology, it may be as simple as the technology allowing you to develop for a new platform.

GTK+ and GNOME fall into the latter category, representing technology that allows you to easily develop applications for Linux. However, as you'll see throughout the rest of the book, there are a great many other reasons to learn and develop with GTK+ and GNOME. Did you realize that GTK+ is becoming a very capable cross-platform development technology? GTK+ is currently available for Windows, Linux, as well as numerous flavors of UNIX and UNIX-inspired operating systems. While GTK+ actually makes developing a GUI easy and (in some cases) fun, GNOME takes it even further by providing a very high level set of functions that enable you to create a powerful, fully functional user interface in record time. Of course, another good reason to develop with these technologies is that they are free, in the freedom sense of the word, as well as of course in the financial cost sense. We'll briefly discuss what that means and why it's so important to programmers everywhere.

In this chapter though, we'll kick back and take it easy. It's important to have a good grasp of the GTK+ and GNOME world, what they mean to both developers and free software, what they consist of in terms of libraries and ofcourse what it's actually like to develop an application with these technologies. This lays a nice firm foundation to build on through the rest of the book.

So, grab a coffee, settle into your favorite coding chair and prepare to start on a journey that will hopefully change the way you develop applications from this point forward.

The X Window System

It's pretty hard to appreciate just how good or bad something is unless it's compared against something else. GTK+ and GNOME were both originally developed in order to simplify the process of creating applications based on the X Window System. However, it's worth taking a look at just what the X Window System really is, and how it came to be in the first place.

X (the X Window System is commonly just referred to as X) was first released from the Massachusetts Institute of Technology back in 1984. The Laboratory for Computer Science at M.I.T. had set themselves the goal of creating a windowing, graphical user environment that would work both locally on a single machine, and also allow client machines to make use of the services provided by a single host. X can still do just that today. It works on a client/server model, where the host computer provides generic graphical services which a client application (be it on the host computer or remotely) can make use of.

Today Linux ships with a version of X, free of any restrictive licenses or exorbitant distribution costs; it's aptly named XFree86. The Free part refers to the fact that it is available for both no cost, and with no restrictions placed on what the user can do with it. The 86 part of the name refers to the fact that XFree86 was developed to run on the Intel x86 family of processors (8086, 286, 386, 486, Pentium and beyond).

However, XFree86 is not a typical graphical user environment like, say, Windows, MacOS, or BeOS. Simply installing it on a machine doesn't mean that you can do anything useful with it at all. You see X does little more than provide services that applications can use to draw on the screen and find out what the user is doing with the keyboard and mouse. It provides no user interface of its own, no way of running applications, navigating around the computer's hard disk, or in fact any of the nice features that users have come to expect. That is all the domain of the window manager.

The window manager is basically an interface between the user and X itself. It handles the drawing of borders around windows and generally controls everything else to do with a running application's look and feel. In addition, most window managers provide some kind of virtual desktop system, where the user can effectively pretend that they have two, three, four or more X displays available to them, switching between each and the applications running on each with a simple click of the mouse.

In the screenshot of Window Maker above (Window Maker is a common window manager) for example, the icon at the top left of the screen enables quick access to the different virtual workspaces that the window manager offers. Window managers also offer the user some mechanism for actually running software. In the case of Window Maker the icons down the right hand side of the screen provide rapid access to common applications. In addition, right clicking the mouse brings up a convenient menu system for access to yet more functionality...

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >