GTK+ 2.0 Tutorial using Ocaml

Tony Gale

Ian Main

& the GTK team

Ocaml Adaptation: SooHyoung Oh

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


Table of Contents
1. Tutorial Availability
1.1. Ocaml Version Tutorial Availability
2. Introduction
2.1. GTK+ 2.0 in Ocaml
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. More on Signal Handlers
4.2. 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. Type Conversion
6.2. Widget Hierarchy
6.3. Widgets Without Windows
6.4. Structure of Widgets
7. Creating Widgets
7.1. Default Arguments
7.2. Memory Management
8. The Button Widget
8.1. Normal Buttons
8.2. Toggle Buttons
8.3. Check Buttons
8.4. Radio Buttons
9. Adjustments
9.1. Creating an Adjustment
9.2. Using Adjustments the Easy Way
9.3. Adjustment Internals
10. Range Widgets
10.1. Scrollbar Widgets
10.2. Scale Widgets
10.2.1. Creating a Scale Widget
10.2.2. Functions and Signals (well, functions, at least)
10.3. Common Range Functions
10.3.1. Setting the Update Policy
10.3.2. Getting and Setting Adjustments
10.4. Key and Mouse bindings
10.5. Example
11. Miscellaneous Widgets
11.1. Labels
11.2. Arrows
11.3. The Tooltips Object
11.4. Progress Bars
11.5. Dialogs
11.6. Rulers
11.7. Statusbars
11.8. Text Entries
11.9. Spin Buttons
11.10. Combo Box
11.11. Calendar
11.12. Color Selection
11.13. File Selections
12. Container Widgets
12.1. The EventBox
12.2. The Alignment widget
12.3. Fixed Container
12.4. Layout Container
12.5. Frames
12.6. Aspect Frames
12.7. Paned Window Widgets
12.8. Viewports
12.9. Scrolled Windows
12.10. Button Boxes
12.11. Toolbar
12.12. Notebooks
13. Menu Widget
13.1. Manual Menu Creation
13.2. Manual Menu Example
13.3. Automatic Menu Generation
13.3.1. Automatic Menu Generation Example
14. Undocumented Widgets
14.1. Accel Label
14.2. Option Menu
14.3. Menu Items
14.3.1. Check Menu Item
14.3.2. Radio Menu Item
14.3.3. Separator Menu Item
14.3.4. Tearoff Menu Item
14.4. Curves
14.5. Drawing Area
14.6. Font Selection Dialog
14.7. Message Dialog
14.8. Gamma Curve
14.9. Image
14.10. Plugs and Sockets
14.11. Tree View
14.12. Text View
15. Setting Widget Attributes
16. Timeouts and Idle Functions
16.1. Timeouts
16.2. Idle Functions
17. Advanced Event and Signal Handling
17.1. Signal Functions
17.1.1. Connecting and Disconnecting Signal Handlers
17.1.2. Blocking and Unblocking Signal Handlers
17.2. Signal Emission and Propagation
18. Clipboard
18.1. Overview
18.2. Clipboard Example
19. Drag-and-drop (DND)
19.1. Overview
19.2. Properties
19.3. Functions
19.3.1. Setting up the source widget
19.3.2. Signals on the source widget:
19.3.3. Setting up a destination widget:
19.3.4. Signals on the destination widget:
20. GTK's rc Files
20.1. Functions For rc Files
20.2. GTK's rc File Format
20.3. Example rc file
21. Scribble, A Simple Example Drawing Program
21.1. Overview
21.2. Event Handling
21.3. The DrawingArea Widget, And Drawing
22. Contributing
22.1. Ocaml Version Contributing
23. Credits
23.1. Ocaml Version Credits
24. Tutorial Copyright and Permissions Notice
24.1. Ocaml Version Tutorial Copyright and Permissions Notice
A. GTK Signals
A.1. GObj
A.1.1. GObj.gtkobj
A.1.2. GObj.widget
A.2. Widget
A.2.1. Misc signals
A.2.2. Drag signals
A.3. GData.adjustment
A.4. GRange.range
A.5. GContainer
A.5.1. GContainer.container
A.5.2. GContainer.item
A.6. GBin
A.6.1. GBin.handle_box
A.6.2. GBin.expanderhandle_box
A.7. GPack.notebook
A.8. GMenu
A.8.1. GMenu.menu_shell
A.8.2. GMenu.menu_item
A.8.3. GMenu.check_menu_item
A.9. GEdit
A.9.1. GEdit.editable
A.9.2. GEdit.entry
A.9.3. GEdit.spin_button
A.9.4. GEdit.combo_box
A.10. GButton
A.10.1. GButton.button
A.10.2. GButton.toggle_button
A.10.3. GButton.color_button
A.10.4. GButton.fontcolor_button
A.10.5. GButton.toolbar
A.10.6. GButton.tool_button
A.10.7. GButton.toggle_tool_button
A.11. GWindow
A.11.1. GWindow.dialog
A.11.2. GWindow.file_chooser_dialog
A.12. GFile
A.12.1. GFile.chooser
A.12.2. GFile.chooser_widget
A.13. GMisc
A.13.1. GMisc.calendar
A.13.2. GMisc.tips_query
A.14. GTree
A.14.1. GTree.model
A.14.2. GTree.tree_sortable
A.14.3. GTree.selection
A.14.4. GTree.view_column
A.14.5. GTree.view
A.14.6. GTree.cell_renderer_text
A.14.7. GTree.cell_renderer_toggle
B. GDK Event Types
C. Code Examples
C.1. Scribble
C.1.1. scribble.ml
List of Tables
19-1. Source widget signals
19-2. Destination widget signals