An Introduction to the GIMP Tool Kit
The GIMP tool kit gtk+ is the GUI libraries written for use in the GIMP as an alternative to Motif. (See the GIMP series of articles by Michael Hammel in the November to January issues of LJ.) Although gtk+ was created for the GIMP, it can be used for any GUI application. In fact, recently the gtk+ distribution has been split out from the GIMP distribution in anticipation of the 1.0 release.
Like all GUI tool kits, gtk+ provides a variety of GUI components, a.k.a. widgets. One thing that sets gtk+ apart from tool kits such as Motif is the breadth of the widgets provided. Naturally, all tool kits provide some form of a button widget. gtk+ also provides components such as tabbed notebooks and fully functional color pickers not included in the core widgets of other tools kits. Screen shots are provided in Figures 1 and 2 as examples of the appearance of gtk+ widgets.

Figure 1. Notebook Widget

Figure 2. Color Selection Widget
Another advantage of gtk+ is that it's not limited to a single language. Even though gtk+ is written in C and was originally intended for use from C, there are bindings to many other languages. Just a few of them are C++, Objective C, Python, Scheme, Perl—the list goes on and on with new additions frequently. Chances are someone has already started on bindings for your favorite language.
Best of all, gtk+ is under the Library GNU Public License (LGPL), so there are absolutely no licensing concerns when writing software.
The GIMP tool kit is made up of three different layers. Each layer has its own distinct functionality and depends on the layers below it. The three layers are:
glib: This is a support library that is of general usefulness in many C programs, even non-GUI applications. Most of its utilities are common data structures, such as linked lists (GList), and convenience functions, to ease porting between Unices, e.g., wrappers around malloc and free (gmalloc and gfree).
gdk: This library is basically a thin layer over Xlib and some of Xt to handle the basics of drawing on the X display and handling X events. Having this library means that applications writers never have to see the underlying X libraries to get work done. This library also contains several useful functions for things like handling timers, polling file descriptors and more.
gtk: This library is the meat of gtk+, where all the GUI elements are defined. This library relies heavily on gdk and glib to do its job.
For someone with experience in C programming, gtk+ should be fairly easy to pick up. The internals of gtk+ use some advanced C features like function pointers and some tricks with structs, but application writers should never need to worry about the internals of gtk+. Naturally, any experience with other GUI tool kits (especially Motif) will make learning gtk+ easier.
For a long time the only documentation of gtk+ was the source code, and the sample application, the GIMP. Fortunately, the gtk+ tutorial at http://levien.com/slow/gtk/ has filled that void.
However, gtk+ is a moving target (still being developed) so be wary. If there's any doubt about the validity of some documentation, always double check it against the source code. And, as always, nothing can beat actually writing code to test an option out.
There is also a mailing list dedicated to discussing gtk+. To subscribe, send mail to gtk-list-request@redhat.com with a subject of “subscribe email-address”, replacing email-address with your e-mail address.
When learning about gtk+, remember that it is still under development, but it is certainly usable for non-trivial applications, the GIMP, for example. There are still plenty of minor bugs and even a few major ones you'll have to work around. For example, at the time of this writing, the text widget still needed a lot of work. But in the two months or more before anyone will read this article in print a lot can happen. The best place to check on the current status of the gtk+ libraries and to get the source is at http://www.gimp.org/gtk/.
Otto is a developer at Red Hat Software who is currently very busy with the next release of Red Hat Linux. He can be contacted by e-mail at otto@redhat.com.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- RSS Feeds
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- What's the tweeting protocol?
- Readers' Choice Awards
- BASH script to log IPs on public web server
3 hours 26 min ago - DynDNS
7 hours 2 min ago - Reply to comment | Linux Journal
7 hours 34 min ago - All the articles you talked
9 hours 58 min ago - All the articles you talked
10 hours 1 min ago - All the articles you talked
10 hours 2 min ago - myip
14 hours 27 min ago - Keeping track of IP address
16 hours 18 min ago - Roll your own dynamic dns
21 hours 32 min ago - Please correct the URL for Salt Stack's web site
1 day 43 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
this article
I have just started reading up about gimp and realise that it is a powerful image edit tool!
Re: An Introduction to the GIMP Tool Kit
search about "GIMP"