GTK+

GTK+ started as the Gimp Toolkit, GTK. Gimp pioneered the cross platform library for graphics. The Gnome group grabbed GTK, split GTK into smaller components, and added stuff to make GTK+.

Everything is broken all the time

GTK+ version 3.10 was broken. 3.18 was broken. The latest release, 3.22, is unknown. There appears to be no plan to fix the GTK+ development process.

GTK+ is the latest version of GTK. GTK started as a library of code in Gimp, giving GTK the name Gimp ToolKit. GTK became a library within GTK+. GTK+ added an outer layer for connection into Gnome based projects in Linux. You can now get GTK+ for any operating system and programming language.

I tried to use GTK+ 3.10 because 3.10 was installed on my development machine. 3.10 was broken. I installed GTK+ 3.18, the latest at the time, but that broke Linux. Back to 3.10. On a recent project, the Linux OS had a working GTK+ 3.18 but that broke when I tried to use it in a program. The latest version is 3.22 and I could not install that without breaking the operating system.

GTK+ structure

GTK+ is a library of functionality based on GDK, ATK, GIO, and Pango. Pango and GDK use Cairo for low level graphics. ATK, GDK, and GIO use GLib. GTK+ can talk direct with Cairo and GLib.

ATK

ATK is the Accessibility ToolKit. ATK is automatically included in GTK+. You can read about the Gnome view of accessibility at https://wiki.gnome.org/Accessibility.

Cairo

Cairo is a vector graphics library for drawing 2D graphics. GTK started with something else then switched to Cairo.

GIO

GIO, the Gnome Input/Output library, is included in GLib. GIO provides low level input and output functions at the file system level.

GLib

GLib contains three low level libraries extracted from GTK by the Gnome group. GLib contains code to handle lists and other non graphics elements used to create higher level graphics structures. You can combine Glib with Cairo to create a list of graphical elements or a structure of containers including graphical elements like borders and scroll bars.

GObject

GObject is the GLib Object System. GObject adds a type of object oriented programming to the C language. GObject can bind with other languages to help you mix languages within an application.

GObject provides a standard base class named GObject. GTK+ uses GObject as the base for GtkObject.

Pango

Pango is the text layout engine used in GTK+ for anything more than the most simple text. Cairo can draw basic text but not for multiple languages or complex type. Pango can use FreeType and other options to handle every language. GTK+ passes all text to Pango to ensure the text is presented using the correct characters for the language.

My experience

The following comments are based on 3.10 as that was the only code that worked.

You get lots of code with named like GtkBox. They are all GtkWidgets or GtkContainers. You build your screen layout using containers plus widgets then fill the containers with other containers and widgets. Some of the layers chew up memory or make the code slow or both. If you do not need a container, do not use it.

The containers are designed for one off static building at the start of your application. Any other use is broken. Simple updates often require emptying containers and redrawing everything.

There are row/column oriented containers including GtkGrid. GtkGrid is missing about half the code needed to use a grid. I started with GtkGrid for one display but had to throw it away and write my own grid layout.

GTK used to let you specify layout details including horizontal alignment. Half the horizontal alignment settings do not work.

GTK used to let you specify background colour when you defined a widget. Now you cannot. Some of the background colour settings are gone and many of the remaining settings do nothing. You are supposed to use a style sheet for settings but the style sheet code is equally broken.

I tested style sheet settings for a range of widgets including containers. Style sheet settings worked on only a few widgets. The style sheet settings only cover background colours, text colours, border settings, and work only on some widgets. You can add styling to every GtkWidget but only to a random selection of specific widgets.

Widgets can have names and they are used a bit like names in HTML. You can select some things by name but not many. The same problem exists in GTK+ 3.18.

GTK+ 3.18 did not fix anything for my application. Compared to GTK+ 3.10, all 3.18 did was take away some of the settings that worked. GTK+ 3 versions are full of documentation telling you a feature is going away. In some cases, you are told to use something else. In many cases, there is no reference to the replacement.

Often a replacement is a style sheet setting but the style sheet setting might not work. Based on communications from people working with GTK+ 3.18, the style sheet settings are still a long way away from replacing the removed settings.

My application in development went through many GTK+ versions. I used a GTK scrolling window container but that broke down when I added a significant amount of data. The scrolling window broke when I was testing with less than one tenth of the data. I had to replace the scrolling window with my own code using manually drawn containers with a scroll bar on one side.

I displayed some data in a row/column layout. GtkGrid was the recommended container. GtkGrid was too slow to handle a large amount of data and locked up with less than half of the test data. I had to replace GtkGrid with manually created containers.

The manually created container system produced a layout that looks like rubbish. I could not manually fix the layout through settings because they were removed. The style sheet did not have replacement settings.

Alternatives

Qt and wxWidgets are the alternatives but require a shift from the C programming language to the C++ programming language. C++ is slower and more difficult. C++ is supposed to fix some problems with C but does not fix all the problems with C. C++ introduces many problems that do not exist in C. Overall, my application development in C++ would be slower than in C. Qt or wxWidgets would have to work miracles to make up for the problems with C++.

Qt went through a difficult phase when it was not open source. Now it is half open. I will wait until Qt is completely open before using Qt.

WxWidgets looks nice. I am impressed by at least one program developed in wxWidgets. WxWidgets is the one alternative to GTK+ that I would try if I had the time to mess with C++.

Documentation

The GTK+ Web site is https://www.gtk.org/.

The GTK+ version 3 reference manual is at https://developer.gnome.org/gtk3/ with versions from 3.0 up to 3.22. Version 3.22.30 has "stable" and "unstable" versions of the documentation. You can find the GTK+ version on your Linux machine by opening the Synaptic Package Manager and searching for libgtk. My machine has libgkt-3-0 version 3.18.9.

The documentation for GTK+ version 3.18.9 is marked as based on version 3.18.4.

Other languages

You can use GTK+ in languages other than C. Sometimes the alternatives do not work easily. I tested GTK+ with the Rust programming language. Rust does not connect to the GObject system used in GTK+. You add a package named Gtk-rs to Rust then Gtk-rs talks to GTK+. Making the connection work is difficult because you have to learn all the special Rust package handling then set a confusing list of options in Gtk-rs to make Gtk-rs work with the right version of GTK+. I deleted Gtk-rs and Rust.

Python and some other languages are supposed to talk direct with GTK+. I do not know how they handle all the GTK+ version incompatibilities and inconsistencies.

Conclusion

The GTK+ developers are not interested in you using GTK+. They appear to develop GTK+ purely for use in Gnome projects. Based on all the parts that did not work, none of the Gnome projects require anything useful in normal applications. If you are developing anything other than Gnome applications, research exactly what is installed in your operating system before committing to a specific version of GTK+.

Tags