GTK+ 1.2 Tutorial

Tony Gale

Ian Main

This is a tutorial on how to use GTK (the GIMP Toolkit) through its C interface.


Table of Contents
1. Introduction
2. Getting Started
Hello World in GTK
Compiling Hello World
Theory of Signals and Callbacks
Events
Stepping Through Hello World
3. Moving On
Data Types
More on Signal Handlers
An Upgraded Hello World
4. Packing Widgets
Theory of Packing Boxes
Details of Boxes
Packing Demonstration Program
Packing Using Tables
Table Packing Example
5. Widget Overview
Casting
Widget Hierarchy
Widgets Without Windows
6. The Button Widget
Normal Buttons
Toggle Buttons
Check Buttons
Radio Buttons
7. Adjustments
Creating an Adjustment
Using Adjustments the Easy Way
Adjustment Internals
8. Range Widgets
Scrollbar Widgets
Scale Widgets
Creating a Scale Widget
Functions and Signals (well, functions, at least)
Common Range Functions
Setting the Update Policy
Getting and Setting Adjustments
Key and Mouse bindings
Vertical Range Widgets
Horizontal Range Widgets
Example
9. Miscellaneous Widgets
Labels
Arrows
The Tooltips Object
Progress Bars
Dialogs
Pixmaps
Rulers
Statusbars
Text Entries
Spin Buttons
Combo Box
Calendar
Color Selection
File Selections
10. Container Widgets
The EventBox
The Alignment widget
Fixed Container
Layout Container
Frames
Aspect Frames
Paned Window Widgets
Viewports
Scrolled Windows
Button Boxes
Toolbar
Notebooks
11. CList Widget
Creating a CList widget
Modes of operation
Working with titles
Manipulating the list itself
Adding rows to the list
Setting text and pixmaps in the cells
Storing data pointers
Working with selections
The signals that bring it together
A CList example
12. CTree Widget
Creating a CTree
Adding and Removing nodes
Setting CTree Attributes
Utilizing row data
13. Tree Widget
Creating a Tree
Adding a Subtree
Handling the Selection List
Tree Widget Internals
Signals
Functions and Macros
Tree Item Widget
Signals
Functions and Macros
Tree Example
14. Menu Widget
Manual Menu Creation
Manual Menu Example
Using ItemFactory
Item Factory Example
15. Text Widget
Creating and Configuring a Text box
Text Manipulation
Keyboard Shortcuts
Motion Shortcuts
Editing Shortcuts
Selection Shortcuts
A GtkText Example
16. Undocumented Widgets
CTree
Curves
Drawing Area
Font Selection Dialog
Gamma Curve
Image
Packer
Plugs and Sockets
Preview
17. Setting Widget Attributes
18. Timeouts, IO and Idle Functions
Timeouts
Monitoring IO
Idle Functions
19. Advanced Event and Signal Handling
Signal Functions
Connecting and Disconnecting Signal Handlers
Blocking and Unblocking Signal Handlers
Emitting and Stopping Signals
Signal Emission and Propagation
20. Managing Selections
Overview
Retrieving the selection
Supplying the selection
21. GLib
Definitions
Doubly Linked Lists
Singly Linked Lists
Memory Management
Timers
String Handling
Utility and Error Functions
22. GTK's rc Files
Functions For rc Files
GTK's rc File Format
Example rc file
23. Writing Your Own Widgets
Overview
The Anatomy Of A Widget
Creating a Composite widget
Introduction
Choosing a parent class
The header file
The _get_type() function
The _class_init() function
The _init() function
And the rest...
Creating a widget from scratch
Introduction
Displaying a widget on the screen
The origins of the Dial Widget
The Basics
gtk_dial_realize()
Size negotiation
gtk_dial_expose()
Event handling
Possible Enhancements
Learning More
24. Scribble, A Simple Example Drawing Program
Overview
Event Handling
The DrawingArea Widget, And Drawing
Adding XInput support
Enabling extended device information
Using extended device information
Finding out more about a device
Further sophistications
25. Tips For Writing GTK Applications
26. Contributing
27. Credits
28. Tutorial Copyright and Permissions Notice
A. GTK Signals
GtkObject
GtkWidget
GtkData
GtkContainer
GtkCalendar
GtkEditable
GtkTipsQuery
GtkCList
GtkNotebook
GtkList
GtkMenuShell
GtkToolbar
GtkTree
GtkButton
GtkItem
GtkWindow
GtkHandleBox
GtkToggleButton
GtkMenuItem
GtkListItem
GtkTreeItem
GtkCheckMenuItem
GtkInputDialog
GtkColorSelection
GtkStatusBar
GtkCTree
GtkCurve
GtkAdjustment
B. GDK Event Types
C. Code Examples
Tictactoe
tictactoe.h
tictactoe.c
ttt_test.c
GtkDial
gtkdial.h
gtkdial.c
dial_test.c
Scribble
scribble-simple.c
scribble-xinput.c
D. List Widget
Signals
Functions
Example
List Item Widget
Signals
Functions
Example