LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
::In The News
::Industry
::Interviews
::Reviews
::Tips
::Tutorials
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Articles :: Reviews :: Beginning GTK+/GNOME Programming

19 November 2000

By John Looney

Unlike any other books, computer books are usually bought by people who aspire to know the book off by heart, and considering they are usually very verbose, and necessarily complex, it's usually wishful thinking. Bearing that in mind, good computer books contain:

  • Few pages - the less someone needs to get their point across, the more intelligent you can assume they are.
  • To the point - I've seen books on C that spend 80 pages on everything you can do with arrays. An intelligent programmer needs a look at some source code, and he is are sorted.
  • Relevant pictures/figures/source code - I've seen "Internet" books with full-page screenshots of Netscape with the caption "This is a web browser". These waste time, paper and brain energy.
  • No CD/floppy. I'll save the £3 extra, and download the latest version myself, thank you very much. A floppy/CD in a book these days is marketing, nothing else.
For more on this, look around photo.net for Philip Greenspun's treatise on computer books.

With this all in mind, the "Beginning GTK+/GNOME Programming", by Peter Wright, rates quite highly, on first impressions. It's not huge (though at 600 pages, considering it's a "beginners" book, it's getting there), and so you can read it on the bus, without feeling silly. The first touch I like is the "index" in the inside cover. It's a quick look at what you are in for, and by the page numbers, how much he's devoting to each section.

The book starts with an "intro to GTK+/GNOME", which I liked. Peter writes with the confidence of a tour guide, taking you through the sights, explaining in an informal manner how to make up Makefiles that know where to get the various libraries, includes etc. that you will use in learning GTK+/GNOME. This is a big difference from Havoc Pennington's GTK+/GNOME book, which assumed that if you bought his book, you knew your way around Makefiles. I thought it was nice of Peter to ease people in like this - after all, a lot of people buying this book may be coming from a scripting or MS Windows programming background.

There is a diagram on the back of the book, that suggests a "book path" of sorts. This book comes after "Beginning C", and then "Beginning Linux Programming". I think that those thinking "I'd like to get into GNOME programming" should start with one of those before moving onto this book, if they are new to programming in C on Unix.

First, we get a flyby tour of "GLib". GLib is the All-Purpose C library that the GIMP people implemented all their wheel-reinventing. It has hash tables, memory tracking, error reporting and loads of standard types, as well as anything else they thought more than one person could use in a C program. It's huge. It's great. It's stable. And this book gives it 35 pages. It covers about 10% of GLib - just enough so you can get by enough to start solving syntax errors in GTK+ code that uses GLib types. But that's all. I was less than impressed, but it's the author's call - this is a "beginners guide", after all. Perhaps a return to GLib later would be in order - it's a very complex library that every C programmer on any platform should use in their code.

All programming books contain source code. Some have ten/twenty pages of code, to bore you to tears, some rip snippets out of context, and explain them to you even if it's obvious what to do. Peter Wright seems to prefer a sprinkling of highlighted (so easy to skim/skip) commented code, with instructions like "type this in, or download it from our website". I suppose it's a tradeoff for not paying for a CD - he has to provide complete code on paper, for those that don't have Internet access. Thankfully, most programs are small ones that just show a point - though he does have on large "example application", which has it's code hidden in an appendix at the back, so you don't have to go skipping through it, in the middle of the book.

Being a GUI book, I would excuse exhuberant pictures in the book. However, they are quite restrained, usually just a widget on it's own, though ocassionally, you do get "This is the GNOME desktop" type pictures, but they are small, and don't take from the content of the book at all.

There are five appendices at the back, two of which are source code for small example applications that would have otherwise cluttered up the book. The other three are reference sources for the GNOME API, Events, and Callbacks. I couldn't help think that they weren't that useful, really. The "Amiga ROM Kernel Referece manuals" had much of this sort of information - and they were larger than A4 so that you could read a lot of it at once. You can't do that in a small book. I can't see myself reading those - I'll stick to looking through the header files on a 100 line tall terminal window. Still, if you like filler...

Onto the meat of the book. After GLib, Peter concentrates sole on GTK+, starting with compiling up a simple "hello world" program, how it works, example makefiles etc. working up to using multiple complex widgets in an application, and finishing the section with a whirlwind tour of GDK, the "graphical abstraction" part of GTK. Much like GLib can make any OS, Unix, BeOS or Windows have a common POSIX-like C API, GDK makes any graphical system look a lot like X windows. Again, complete knowledge of GDK isn't needed for a beginner to get on their feet, so he sticks to useful bits of it, like fonts and colours.

By this "halfway point" in Havoc Pennington's book, a big explanation of the GTK+ object system was given. Peter's book is written for beginners. He seems to assume that most people really aren't interested in the details as to how the GIMP people made libraries which supported a proper OO system in C - Peter just explains what you need to know to get going. Although he is more verbose, there is a very strong feeling that you are being shown a little more of GTK each time, in managable chunks. By the time you get to "Introducing GNOME", anyone could make small applications, with simple widgets.

Just as the GTK+ section started with Makefiles, the GNOME section starts with an explanation of how your source directories should look like. Though many people don't know this (and many more don't follow it), the GNU project has very strict guidelines as to what should be in a source code tarball. Peter explains that having an "src" directory with source, separate from your "INSTALL", "README", "COPYING" files, as well as internationalization files, and most importantly the "configure" script. Although he doesn't go into great depth explaining how autoconf/automake work, he makes you aware of their existance. He also explains "popt" - the command line argument parser. It's little things like that that make this book stand out in my mind.

The rest of the GNOME section concentrates on the various GNOME widgets, and downloading/compiling/using gIDE and GLADE (the GNOME Integrated Development Environment and a VB-like GUI creation tool). Again, because he is writing a beginners book, he avoids advanced concepts like session managment, CORBA, Bonobo and the like. By the end of this section, you can make GNOME-looking simple applications, and have at least played with GLADE, to see how powerful it could be.

Overall, the book is a good beginners book. It avoids using complex C algorithms, advanced GNOME concepts, and doesn't explain GLib or GDK in depth. However, it does cover more important concepts like getting you started, how your programs should look, how your source should look, and getting something on the screen, doing something pretty, which is the most important thing for starting someone off. I can just hope there would be a companion book "Advanced GTK+/GNOME programming", that would cover über-cool stuff like Bonobo and Gnorba.

If you are looking for something a little more advanced, perhaps Havoc Pennington's book is for you - it's not as well written, or as comprehensive in what the author wishes to cover as this book, though it has more complex concepts in it.


Related:
GTK Widget Set Review


About the author, John Looney.

USERS COMMENTS


                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell