And … Action!

Desktop Design with GTK4

Article from Issue 253/2021
Author(s):

The Clapper media player showcases new desktop design features in GTK4.

Free software desktops such as Gnome and KDE are built on top of toolkits that provide support for the graphic elements. Gnome is built on the GTK toolkit. GTK is an important component of many GUI-based Linux systems, and a new release of GTK eventually has implications for all Linux users working in Gnome and other GTK-based desktop systems.

GTK4 [1] was released at the end of 2020, and components that rely on GTK4 have quickly followed, starting with Gnome 40 in March 2021. Recent distributions such as Fedora 34 [2] and Arch Linux already include Gnome 40. Other distributions such as Ubuntu 21.04 [3] include the GTK4 libraries in their package sources but don't use the GTK4-based desktop yet.

In practice, however, GTK4's influence in these distributions is still not very noticeable. For example, the Gnome desktop's extensions app does not look noticeably different, even though it has now been ported to GTK4: It uses the usual widgets, such as buttons, search fields, and fold-out dialogs. If you look at the Widget Factory (see the "Widget Factory" box), a test program that organizes all common widgets in a window, you probably won't notice any outstanding innovations at first glance. However, if you take a look at the animated GTK cube video on the main Widget Factory page, you can see one of the biggest changes between GTK3 and GTK4. Mousing over the video reveals the typical pause and start playback media player buttons. This cube video demonstrates that you now can put graphics or other media elements in the background of almost all window elements [4].

Widget Factory

To import the Widget Factory under Ubuntu 21.04 or Debian Experimental, use the gtk-3-examples and gtk-4-examples packages, respectively. (For Arch Linux, you'll find the example widgets in the gtk3-demos and gtk4-demos packages).

Once you've installed the packages for your distribution, you can call the programs using the gtk3-widget-factory and gtk4-widget-factory commands.

As a means of exploring some of the new features in GTK4, this article examines the new Clapper [5] media player, a Gnome desktop tool built using the GTK4 toolkit.

Clapper

The Clapper media player was built using GTK4, so it shows how some of the new GTK4 features work in practice. At first glance, Clapper reminds you of Gnome Video Player, but you will notice that the classic window bar located at the top of the application window is missing (in fact, this hasn't existed in Gnome for some time). GTK4 has pushed the envelope a bit further: The video image covers almost the entire window area, with only the control bar at the bottom remaining permanently visible. The menus can be reached via partially transparent buttons at the top of the window (Figure 1). Clapper only shows the buttons when you mouse over the window.

Figure 1: Clapper reduces the space required by the playback controls to the bare minimum.

Clapper has three modes: windowed, full-screen, and floating. The default, windowed mode shows the progress bar and window controls. In windowed mode, Clapper is visible on every virtual desktop on Gnome and will automatically slide from desktop to desktop, remaining in the foreground even when another application is active. In full-screen mode, you can select to hide the progress bar and playback controls. In floating mode (Figure 2), Clapper hides the controls and floats the window on top of other applications; the application window will automatically slide to the currently active desktop in this mode.

Figure 2: Clapper in floating mode with the controls hidden.

Due to its early stage of development, Clapper is not yet available in the package sources of the popular distributions. However, you can find a Flatpak on Clapper's GitHub page [5] that you can install across distributions. Alternatively, the developers provide packages and package sources for Debian, Fedora, and openSUSE [6]. You can also install the DEB package on Ubuntu 21.04 (Listing 1).

Listing 1

Installation on Ubuntu

sudo apt install curl
echo 'deb http://download.opensuse.org/repositories/home:/Rafostar/Debian_Unstable/ /' | sudo tee /etc/apt/sources.list.d/home:Rafostar.list
curl -fsSL https://download.opensuse.org/repositories/home:Rafostar/Debian_Unstable/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_Rafostar.gpg > /dev/null
sudo apt update
sudo apt install clapper

Eye Candy for Gnome

Other application developers are also increasingly adopting the possibilities offered by GTK4. For example, the radio receiver Shortwave [7] offers a program display area that adapts fluidly depending on the display width or desktop window size. All of this is proof of Gnome's continuous development towards optimizing itself and the various Gnome applications for use on smartphones or tablets.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News