<< Back to man.ChinaUnix.net

GTK+ 2.0 Tutorial

Tony Gale

Ian Main

& the GTK team

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


Table of Contents
1. Tutorial Availability
2. Introduction
3. Getting Started
3.1. Hello World in GTK
3.2. Compiling Hello World
3.3. Theory of Signals and Callbacks
3.4. Events
3.5. Stepping Through Hello World
4. Moving On
4.1. Data Types
4.2. More on Signal Handlers
4.3. An Upgraded Hello World
5. Packing Widgets
5.1. Theory of Packing Boxes
5.2. Details of Boxes
5.3. Packing Demonstration Program
5.4. Packing Using Tables
5.5. Table Packing Example
6. Widget Overview
6.1. Casting
6.2. Widget Hierarchy
6.3. Widgets Without Windows
7. The Button Widget
7.1. Normal Buttons
7.2. Toggle Buttons
7.3. Check Buttons
7.4. Radio Buttons
8. Adjustments
8.1. Creating an Adjustment
8.2. Using Adjustments the Easy Way
8.3. Adjustment Internals
9. Range Widgets
9.1. Scrollbar Widgets
9.2. Scale Widgets
9.2.1. Creating a Scale Widget
9.2.2. Functions and Signals (well, functions, at least)
9.3. Common Range Functions
9.3.1. Setting the Update Policy
9.3.2. Getting and Setting Adjustments
9.4. Key and Mouse bindings
9.5. Example
10. Miscellaneous Widgets
10.1. Labels
10.2. Arrows
10.3. The Tooltips Object
10.4. Progress Bars
10.5. Dialogs
10.6. Rulers
10.7. Statusbars
10.8. Text Entries
10.9. Spin Buttons
10.10. Combo Box
10.11. Calendar
10.12. Color Selection
10.13. File Selections
11. Container Widgets
11.1. The EventBox
11.2. The Alignment widget
11.3. Fixed Container
11.4. Layout Container
11.5. Frames
11.6. Aspect Frames
11.7. Paned Window Widgets
11.8. Viewports
11.9. Scrolled Windows
11.10. Button Boxes
11.11. Toolbar
11.12. Notebooks
12. Menu Widget
12.1. Manual Menu Creation
12.2. Manual Menu Example
12.3. Using ItemFactory
12.3.1. ItemFactory entries
12.3.2. Creating an ItemFactory
12.3.3. Making use of the menu and its menu items
12.4. Item Factory Example
13. Undocumented Widgets
13.1. Accel Label
13.2. Option Menu
13.3. Menu Items
13.3.1. Check Menu Item
13.3.2. Radio Menu Item
13.3.3. Separator Menu Item
13.3.4. Tearoff Menu Item
13.4. Curves
13.5. Drawing Area
13.6. Font Selection Dialog
13.7. Message Dialog
13.8. Gamma Curve
13.9. Image
13.10. Plugs and Sockets
13.11. Tree View
13.12. Text View
14. Setting Widget Attributes
15. Timeouts, IO and Idle Functions
15.1. Timeouts
15.2. Monitoring IO
15.3. Idle Functions
16. Advanced Event and Signal Handling
16.1. Signal Functions
16.1.1. Connecting and Disconnecting Signal Handlers
16.1.2. Blocking and Unblocking Signal Handlers
16.1.3. Emitting and Stopping Signals
16.2. Signal Emission and Propagation
17. Managing Selections
17.1. Overview
17.2. Retrieving the selection
17.3. Supplying the selection
18. Drag-and-drop (DND)
18.1. Overview
18.2. Properties
18.3. Functions
18.3.1. Setting up the source widget
18.3.2. Signals on the source widget:
18.3.3. Setting up a destination widget:
18.3.4. Signals on the destination widget:
19. GLib
19.1. Definitions
19.2. Doubly Linked Lists
19.3. Singly Linked Lists
19.4. Memory Management
19.5. Timers
19.6. String Handling
19.7. Utility and Error Functions
20. GTK's rc Files
20.1. Functions For rc Files
20.2. GTK's rc File Format
20.3. Example rc file
21. Writing Your Own Widgets
21.1. Overview
21.2. The Anatomy Of A Widget
21.3. Creating a Composite widget
21.3.1. Introduction
21.3.2. Choosing a parent class
21.3.3. The header file
21.3.4. The _get_type() function
21.3.5. The _class_init() function
21.3.6. The _init() function
21.3.7. And the rest...
21.4. Creating a widget from scratch
21.4.1. Introduction
21.4.2. Displaying a widget on the screen
21.4.3. The origins of the Dial Widget
21.4.4. The Basics
21.4.5. gtk_dial_realize()
21.4.6. Size negotiation
21.4.7. gtk_dial_expose()
21.4.8. Event handling
21.4.9. Possible Enhancements
21.5. Learning More
22. Scribble, A Simple Example Drawing Program
22.1. Overview
22.2. Event Handling
22.3. The DrawingArea Widget, And Drawing
22.4. Adding XInput support
22.4.1. Enabling extended device information
22.4.2. Using extended device information
22.4.3. Finding out more about a device
22.4.4. Further sophistications
23. Tips For Writing GTK Applications
24. Contributing
25. Credits
26. 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
18-1. Source widget signals
18-2. Destination widget signals