GTK 4 Tutorial for beginners

Contents of this Repository

This tutorial illustrates how to write C programs with the GTK 4 library. It focuses on beginners so the contents are limited to the basics. The table of contents is at the end of this abstract.

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.

GTK 4 Documentation

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 GTK 4 programs.


This tutorial is under development and unstable. Even though the codes of the examples have been tested on GTK 4 (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.

How to get a HTML or PDF version

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 GTK 4 Tutorial”) that describes how to make them.

Table of contents

  1. Prerequisite and License
  2. Installing GTK 4 into Linux distributions
  3. GtkApplication and GtkApplicationWindow
  4. Widgets (1)
  5. Widgets (2)
  6. String and memory management
  7. Widgets (3)
  8. Defining a child object
  9. The User Interface (UI) file and GtkBuilder
  10. Build system
  11. Initialization and destruction of instances
  12. Signals
  13. Functions in TfeTextView
  14. Functions in GtkNotebook
  15. tfeapplication.c
  16. tfe5 source files
  17. Menu and action
  18. Stateful action
  19. Ui file for menu and action entries
  20. GtkMenuButton, accelerators, font, pango and gsettings
  21. Template XML and composite widget
  22. GtkDrawingArea and Cairo
  23. Periodic Events
  24. Combine GtkDrawingArea and TfeTextView
  25. Tiny turtle graphics interpreter
  26. GtkListView
  27. GtkGridView and activate signal
  28. GtkExpression
  29. GtkColumnView

This website uses Bootstrap.