Some days ago the release of the new version of GTK 4.0 was announced, version that was in development for several months and that becomes the new stable branch of the project. This new version presents very interesting features, of which we can highlight the improvements in media playback.
GTK is a set of software libraries for creating graphical interfacesGTK was originally developed for the needs of GIMP image processing software. Currently, its scope is no longer limited to just GIMP, but is used in other projects. For example, GTK is at the heart of the GNU network object model environment (GNOME), but it can also be used to write applications for other Linux environments, as well as applications for Microsoft Windows and Apple macOS.
“GTK 4.0 is the result of the hard work of a small team of dedicated developers. We'll have a separate article to go over the stats, but the quick summary is that since November 3.89.1 version 2016, we've added over 18,000 commits and made over 20 development releases.
“Congratulations and a big thank you to everyone who participated in this effort, and in particular Benjamin, Emmanuele, Timm, Carlos, Jonas, and Christian! «
About the new version of GTK 4.0
GTK 4.0 introduces new widgets and changes to existing elements, built-in support for media playback, improvements in GPU acceleration, such as work on your new Vulkan rendering engine, and better compatibility with macOS. We can also notice improvements in data transfer, redesigned shaders, GPU accelerated scrolling, improvements in OpenGL rendering beyond the Vulkan job, restoration of the job in HTMl5 Broadway, better Windows support etc.
Let's look at some points a little more in depth.
Media management in GT4
- GTK 4 will allow GTK applications to display animations more easily; be it programmatic animation, webm archive or live broadcast.
- GTK 4 brings a new API called GdkPaintable that was inspired by the CSS Houdini effort. It is very flexible (anything you can draw can be a GdkPaintable). The content can be resized (like svg) or changed over time (like webm).
- If you have more specialized needs, anything that can be captured in a GtkSnapshot can be converted to a drawing with gtk_snapshot_to_paintable (). If you are creating a custom widget that wants to draw an object to paint, it is very simple. Just call gdk_paintable_snapshot ().
- You can have multimedia control using the GtkVideo widget.
Data transfer in GTK4
Traditional methods of transferring data User-initiated between desktop applications are the clipboard or drag and drop. GTK + supports these methods but, until GTK3, the APIs that the toolkit had for this type of data transfer were finely disguised copies of the corresponding X11 APIs. This is not too surprising, since the entire GDK API has been modeled in X11. Unfortunately, the implementation includes results such as incremental transfers and string format conversions.
For GTK4, the team decided to abandon this approach, opting for a modernization. This is the concept of the new approach:
“If the data your application wants to send is not a string, it is probably an object, like GFile, GdkTexture, or GdkRGBA. The receiver side application may not use GTK or GLib and therefore is not aware of these types. And even if you do, there is no way to move objects from one process to another in one piece.
“Inside it, data transfer works by sending a file descriptor from the source application and the destination application by reading a stream of bytes. The protocols for the clipboard and DND use mime types such as text / uri-list, image / png, or application / x-color to identify the format of the byte stream.
Sending an object involves negotiating a two-sided compatible data format, serializing the object on the source side into a byte stream of that format, transferring the data, and deserializing the object on the destination side. «
In addition, GTK4 comes with new APIs.
“The first API we introduce to handle these types is the GdkContentFormats object. It can contain a list of formats, which can be GTypes or mime. We use GdkContentFormats objects to describe the formats in which an application can offer data, as well as the formats in which an application can receive data ”.