GTK+ 2.0 Tutorial

Tony Gale

Ian Main

& the GTK team


Table of Contents
1. Introduction
2. Getting Started
2.1. Hello World in GTK
2.2. Compiling Hello World
2.3. Theory of Signals and Callbacks
2.4. Events
2.5. Stepping Through Hello World
3. Moving On
3.1. Data Types
3.2. More on Signal Handlers
3.3. An Upgraded Hello World
4. Packing Widgets
4.1. Theory of Packing Boxes
4.2. Details of Boxes
4.3. Packing Demonstration Program
4.4. Packing Using Tables
4.5. Table Packing Example
5. Widget Overview
5.1. Casting
5.2. Widget Hierarchy
5.3. Widgets Without Windows
6. The Button Widget
6.1. Normal Buttons
6.2. Toggle Buttons
6.3. Check Buttons
6.4. Radio Buttons
7. Adjustments
7.1. Creating an Adjustment
7.2. Using Adjustments the Easy Way
7.3. Adjustment Internals
8. Range Widgets
8.1. Scrollbar Widgets
8.2. Scale Widgets
8.2.1. Creating a Scale Widget
8.2.2. Functions and Signals (well, functions, at least)
8.3. Common Range Functions
8.3.1. Setting the Update Policy
8.3.2. Getting and Setting Adjustments
8.4. Key and Mouse bindings
8.5. Example
9. Miscellaneous Widgets
9.1. Labels
9.2. Arrows
9.3. The Tooltips Object
9.4. Progress Bars
9.5. Dialogs
9.6. Rulers
9.7. Statusbars
9.8. Text Entries
9.9. Spin Buttons
9.10. Combo Box
9.11. Calendar
9.12. Color Selection
9.13. File Selections
10. Container Widgets
10.1. The EventBox
10.2. The Alignment widget
10.3. Fixed Container
10.4. Layout Container
10.5. Frames
10.6. Aspect Frames
10.7. Paned Window Widgets
10.8. Viewports
10.9. Scrolled Windows
10.10. Button Boxes
10.11. Toolbar
10.12. Notebooks
11. Menu Widget
11.1. Manual Menu Creation
11.2. Manual Menu Example
11.3. Using ItemFactory
11.4. Item Factory Example
12. Undocumented Widgets
12.1. Accel Label
12.2. Option Menu
12.3. Menu Items
12.3.1. Check Menu Item
12.3.2. Radio Menu Item
12.3.3. Separator Menu Item
12.3.4. Tearoff Menu Item
12.4. Curves
12.5. Drawing Area
12.6. Font Selection Dialog
12.7. Message Dialog
12.8. Gamma Curve
12.9. Image
12.10. Plugs and Sockets
12.11. Tree View
12.12. Text View
13. Setting Widget Attributes
14. Timeouts, IO and Idle Functions
14.1. Timeouts
14.2. Monitoring IO
14.3. Idle Functions
15. Advanced Event and Signal Handling
15.1. Signal Functions
15.1.1. Connecting and Disconnecting Signal Handlers
15.1.2. Blocking and Unblocking Signal Handlers
15.1.3. Emitting and Stopping Signals
15.2. Signal Emission and Propagation
16. Managing Selections
16.1. Overview
16.2. Retrieving the selection
16.3. Supplying the selection
17. Drag-and-drop (DND)
17.1. Overview
17.2. Properties
17.3. Functions
17.3.1. Setting up the source widget
17.3.2. Signals on the source widget:
17.3.3. Setting up a destination widget:
17.3.4. Signals on the destination widget:
18. GLib
18.1. Definitions
18.2. Doubly Linked Lists
18.3. Singly Linked Lists
18.4. Memory Management
18.5. Timers
18.6. String Handling
18.7. Utility and Error Functions
19. GTK's rc Files
19.1. Functions For rc Files
19.2. GTK's rc File Format
19.3. Example rc file
20. Writing Your Own Widgets
20.1. Overview
20.2. The Anatomy Of A Widget
20.3. Creating a Composite widget
20.3.1. Introduction
20.3.2. Choosing a parent class
20.3.3. The header file
20.3.4. The _get_type() function
20.3.5. The _class_init() function
20.3.6. The _init() function
20.3.7. And the rest...
20.4. Creating a widget from scratch
20.4.1. Introduction
20.4.2. Displaying a widget on the screen
20.4.3. The origins of the Dial Widget
20.4.4. The Basics
20.4.5. gtk_dial_realize()
20.4.6. Size negotiation
20.4.7. gtk_dial_expose()
20.4.8. Event handling
20.4.9. Possible Enhancements
20.5. Learning More
21. Scribble, A Simple Example Drawing Program
21.1. Overview
21.2. Event Handling
21.3. The DrawingArea Widget, And Drawing
21.4. Adding XInput support
21.4.1. Enabling extended device information
21.4.2. Using extended device information
21.4.3. Finding out more about a device
21.4.4. Further sophistications
22. Tips For Writing GTK Applications
23. Contributing
24. Credits
25. Tutorial Copyright and Permissions Notice
A. GTK Signals
A.1. GtkObject
A.2. GtkWidget
A.3. GtkData
A.4. GtkContainer
A.5. GtkCalendar
A.6. GtkEditable
A.7. GtkNotebook
A.8. GtkList
A.9. GtkMenuShell
A.10. GtkToolbar
A.11. GtkButton
A.12. GtkItem
A.13. GtkWindow
A.14. GtkHandleBox
A.15. GtkToggleButton
A.16. GtkMenuItem
A.17. GtkCheckMenuItem
A.18. GtkInputDialog
A.19. GtkColorSelection
A.20. GtkStatusBar
A.21. GtkCurve
A.22. GtkAdjustment
B. GDK Event Types
C. Code Examples
C.1. Tictactoe
C.1.1. tictactoe.h
C.1.2. tictactoe.c
C.1.3. ttt_test.c
C.2. GtkDial
C.2.1. gtkdial.h
C.2.2. gtkdial.c
C.2.3. dial_test.c
C.3. Scribble
C.3.1. scribble-simple.c
C.3.2. scribble-xinput.c
List of Tables
17-1. Source widget signals
17-2. Destination widget signals