The github page of this tutorial is also available. Click here.
This tutorial illustrates how to write C programs with the Gtk4 library. It focuses on beginners so the contents are limited to the basics. The table of contents is at the end of this abstract.
- Section 3 to 21 describes the basics, with the example of a simple editor
tfe
(Text File Editor). - Section 22 to 25 describes GtkDrawingArea.
- Section 26 to 29 describes the list model and the list view (GtkListView, GtkGridView and GtkColumnView). It also describes GtkExpression.
The latest version of the tutorial is located at Gtk4-tutorial github repository. You can read it from there directly without having to download anything.
Please refer to Gtk API Reference and Gnome Developer Documentation Website for further information.
These websites are newly opened lately (Aug/2021). The old documentation is located at Gtk Reference Manual and Gnome Developer Center. The new website is in progress at present, so you might need to refer to the old version.
If you want to know about GObject and the type system, please refer to GObject tutorial. The GObject details are easy to understand and also necessary to know when writing Gtk4 programs.
This tutorial is under development and unstable.
Even though the codes of the examples have been tested on Gtk4 version 4.0, bugs may still exist.
If you find any bugs, errors or mistakes in the tutorial and C examples, please let me know.
You can post it to github issues.
You can also post corrected files as a commit to pull request.
When you make corrections, correct the source files, which are under the 'src' directory,
then run rake
to create to create the output file. The GFM files under the 'gfm' directory are automatically updated.
If you have a question, feel free to post it as an issue. All questions are helpful and will make this tutorial get better.
If you want to get a HTML or PDF version, you can make them with rake
, which is a ruby version of make.
Type rake html
for HTML.
Type rake pdf
for PDF.
There is a documentation ("How to build Gtk4 Tutorial") that describes how to make them.
- Prerequisite and License
- Installing Gtk4 into Linux distributions
- GtkApplication and GtkApplicationWindow
- Widgets (1)
- Widgets (2)
- String and memory management
- Widgets (3)
- Defining a Child object
- The User Interface (UI) file and GtkBuilder
- Build system
- Initialization and destruction of instances
- Signals
- Functions in TfeTextView
- Functions in GtkNotebook
- tfeapplication.c
- tfe5 source files
- Menu and action
- Stateful action
- Ui file for menu and action entries
- GtkMenuButton, accelerators, font, pango and gsettings
- Template XML and composite widget
- GtkDrawingArea and Cairo
- Periodic Events
- Combine GtkDrawingArea and TfeTextView
- Tiny turtle graphics interpreter
- GtkListView
- GtkGridView and activate signal
- GtkExpression
- GtkColumnView