GTK
GTK is a tookit for creating GUI apps, mostly targeting Linux systems and the Gnome Platform. It uses the GObject (GLib Object System) base type system.
GLib and GObject
GObject is a library that is a base for many other Gnome libraries (like GTK). It is a common base layer providing OOP paradigm to the C language. It may be seen as an alternative to C++ or ObjectiveC, since it enables developers to create classes, but in this case, directly in C (however, in a rather tedious way, since it’s still “just” C)!
GObject is a part of GLib and uses the same version numbers. GLib contains:
- GObject - type system
- GThread - threading
- GIO - I/O operations
- others…
Some features of GObject that are often used in GTK apps are:
- the
GObject
root base type - signals (like events in .NET)
Bindings
The GObject libraries are written in the C language. However, there are a bunch of bindings for many other programming languages that open the toolkit to a vast group of developers. Examples of supported languages include:
- C (obviously)
- JavaScript
- Python
- Rust
- Vala
- C#
- and more…
Since there is a lot of GObject-based libraries, there is an established way of generating bindings for them - GObject Introspection. The bindings, under the hood, call the C libraries code via mechanisms similar to PInvoke.
Software Stack
Nowadays, the applications developed in GTK use the following tooling/services:
- GTK as a base for the app and widgets library
- other GObject-based libs - lots of libraries, like Soup for HTTP
- language bindings
- Libadwaita as both the widgets library and design system
- Gnome Builder as an IDE
- Flatpak for packaging the apps
- Flathub for distribution of the apps
Resources
Popularity of GTK apps development would certainly benefit from more materials being available on the topic. These are the resources that I find the most valuable:
- Gnome Developer Portal - a documentation and guides for developing for the Gnome Platform.
- GJS Guide - the Guide to GJS with a bunch of information about GObject itself.
- elementary Developer Docs - Elementary OS encourages the use of Vala and Granite widgets library, which might not be the most popular technologies out there, but the docs are a solid guide to building GTK apps, which will be useful for any developer starting out with GTK.
- Gtk Inspector - an app that allows for live inspection of GTK apps, similar to dev tools in web browsers.
- GTK API Documentation - API reference for GTK, GDK, Pango, and many other libs
- GJS API - all the APIs exposed by GJS
- Vala API - same as above, but for Vala