What is the recommended way of developing against GTK 4?

Hi,

I want to improve myself on developing desktop applications and I want to do it with GTK4. I’m on Ubuntu 20.04 LTS. What is the recommended way of developing against GTK 4?

I saw that GTK 3 and 4 libraries can work on the same system but I prefer not to install if possible. Is there a VM, container or similar approach?

Flatpak

You can use the org.gnome.Sdk//master, which already contains GTK 4 and start developing without altering your system

1 Like

Flatpak is the way to go for GNOME applications yes, but I would advice against using the Nightly runtime due to its unstable nature. It might randomly break API and eat your lunch so beware dragons if you choose to use it.

Here is a snippet that works with the GNOME 3.38 runtime which you can use instead.

    "modules" : [
        {
            "name" : "pango",
            "buildsystem" : "meson",
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://download.gnome.org/sources/pango/1.48/pango-1.48.0.tar.xz",
                    "sha256" : "391f26f3341c2d7053e0fb26a956bd42360dadd825efe7088b1e9340a65e74e6"
                }
            ]
        },
        {
            "name" : "libsass",
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://github.com/sass/libsass/archive/3.6.4.tar.gz",
                    "sha256" : "f9484d9a6df60576e791566eab2f757a97fd414fce01dd41fc0a693ea5db2889"
                },
                {
                    "type" : "script",
                    "dest-filename" : "autogen.sh",
                    "commands" : [
                        "autoreconf -si"
                    ]
                }
            ]
        },
        {
            "name" : "sassc",
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://github.com/sass/sassc/archive/3.6.1.tar.gz",
                    "sha256" : "8cee391c49a102b4464f86fc40c4ceac3a2ada52a89c4c933d8348e3e4542a60"
                },
                {
                    "type" : "script",
                    "dest-filename" : "autogen.sh",
                    "commands" : [
                        "autoreconf -si"
                    ]
                }
            ]
        },
        {
            "name" : "gtk4",
            "buildsystem" : "meson",
            "config-opts" : [
                "-Ddemos=false",
                "-Dbuild-examples=false",
                "-Dbuild-tests=false",
                "-Dvulkan=disabled",
                "-Dmedia-ffmpeg=disabled"
            ],
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://download.gnome.org/sources/gtk/4.0/gtk-4.0.0.tar.xz",
                    "sha256" : "d46cf5b127ea27dd9e5d2ff6ed500cb4067eeb2cb1cd2c313ccde8013b0b9bf9"
                }
            ]
        },
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.