[Preview] Testing GtkAda4 with Alire on Ubuntu 26.04

Hi everyone,

If you are running Ubuntu 26.04, you can now try out the GtkAda4 crate directly via Alire.

Prerequisites:

  • alr (Alire package manager) installed.
  • GTK4 4.22+ development libraries:
# Installs GTK 4.22.4 on Ubuntu 26.04
sudo apt install libgtk-4-dev

Quick Start:

alr init --bin gtkada4_test
cd gtkada4_test
alr with gtkada4 --use=https://github.com/AdaCore/gtkada
Requested changes:

   ✓ gtkada4 ^27.0.0 (add)
                          
Changes to dependency solution:

   New solution is incomplete.
   +📌      gtkada4    27.0.0   (new,path=alire/cache/pins/gtkada4,url=https://github.com/AdaCore/gtkada)
   +📦      make       4.4.1    (new,indirect,system package)
   +📦      pkg_config 2.5.1    (new,indirect,system package)
   Missing:
   +❗      libgtk4    >=4.22.2 (new,missing:unknown,indirect)

Do you want to proceed?
[Y] Yes  [N] No  (default is No) 

At this point Alire will complain that libgtk4>=4.22 is not found. You should type Yes to proceed! Now you can build the crate:

alr build

You also can build gtkada_demo:

alr exec -- gprbuild -P gtkada_demo/gtkada_demo.gpr

If you had configured Alire to avoid shared dependency (alr settings --global --set dependencies.shared false) then you can lauch the demo as

./alire/cache/pins/gtkada4/gtkada_demo/gtkada_demo

Oherwise find it somewhere in $HOME/.local/share/alire/

Feel free to test it out and report any issues or feedback here. Happy hacking with Ada and GTK4!

I was able to build the crate and run the demo successfully on Fedora 44, with the minor deviation that the libepoxy development packages were also needed:

sudo dnf install gtk4-devel libepoxy-devel
alr init --bin gtk4ada_test
cd gtk4ada_test/
alr with gtkada4 --use=https://github.com/AdaCore/gtkada
alr build
  ...
✓ Build finished successfully in 89.59 seconds.
alr exec -- gprbuild -P gtkada_demo/gtkada_demo.gpr
  ...
Link
   [link]         gtkada_demo.adb

./alire/cache/pins/gtkada4/gtkada_demo/gtkada_demo

And there is first GtkAda4 application ever, see gtkada4 folder in

:slight_smile:

Thanks for the preview — first-day feedback (Debian forky/sid, GNAT FSF 16.1 via Alire, GTK 4.24.1). Good news first: the binding works really well. Built the crate fine, and a minimal GTK4 window (title + one Continue button) runs on Wayland exactly as expected.

Four remarks, all first-hand:

  1. gtkada_demo still ships GTK3-era sources that cannot compile
    About 30 demo files (create_main_loop.adb, …) still use Gtk.Main.Main, Main_Quit, Show_All, Widget_Handler.Connect — none of which exist in gtkada4. The build stays green because the rewritten gtkada_demo.adb (GApplication-based) no longer withes them, and gprbuild only compiles the main’s closure (100 .adb sources, 68 compiled). Confusing for anyone grepping the demo for API usage: it hands out GTK3 answers. Suggestion: delete those files or mark them clearly as “GTK3 archive, will not build”.

  2. An application window must be created from activate — reproduced in pure C
    Creating a Gtk_Application_Window in the main body, before Application.Run, segfaults in GTK 4.24.1 instance init (signal emission during init). I reproduced it identically from pure C (SIGSEGV, same g_object_new → type-instance-init chain), so it is GTK-side behaviour, not a GtkAda bug. Meanwhile gtk_main.ads still says Gtk.Main.Init is “usually not necessary” with GtkApplication, without mentioning the lifecycle rule; creating the window from the activate handler (or Gtk.Main.Init + a plain window) works. A word in the demo or docs would spare newcomers the GTK3-era pattern that segfaults.

  3. No canonical “hello window” example
    Gtk.Main.Main is gone and GMainLoop is not bound, so the only documented event loop is Glib.Application.Run; the alternative pump (Glib.Main.Main_Context_Iteration) appears only in testsuite code. A minimal-window example would spare everyone the archaeology.

  4. Accessibility notes
    (testing a GUI-automation angle): GTK 4.24 defaults to AccessKit, so GTK_A11Y=atspi is needed to expose the tree on org.a11y.Bus; with it, roles/accessible names are correctly exposed and DoAction on a button works end to end. One wrinkle: the app registers on the bus as “Unnamed” despite a proper application id (org.guiverb.probe) — the frame carries the right name, the app node doesn’t. Screen readers care about that app-level name.

Happy to file the repro cases where you prefer (issues or here).

Does GTK4 support multithreading? If yes how does it interplay with Ada tasks? Tasking is the only reason to justify migration.

On my side, I’m interested in the accessibility architecture inside the kit for the needs of my current experimentation.

On Gtk3, you need the (now deprecated) ATK + an atk-bridge addon.
On Gtk4, accessibility is part of the widget itself, from the ground up, and AT-SPI is a native backend.

Gtk4 is much simpler for my test case.

GTK4 doesn’t support multithreading by nature of some platforms, only main thread can execute any UI related code.

Major change in GTK4 is switch to new rendering model. It is GPU friendly, and rendering can be off-loaded from CPU and main thread.

OK, but rendering is only a problem for Cairo. Specifically in GTK problems are caused by poor performance of GtkListStore and GtkTreeStore.

Cairo is not used by new rendering model. It can be used by application to create images, and these images can be passed to rendering model, however it is not recommended now.

MVC model was reimplemented too. I don’t have any experimental information related to performance of it.

PS. In Gtk+ 3, list store and tree store are not expected to manage significant amount of data. If application wants to manage hundreds of items, it can provide own implementation of tree model interface.

I expected them to address real issues like threading, event handling, localization, support for a wider range of surfaces/backends.

Since GTK5 seems to be on the horizon I would stick to GtkAda for GTK3.

alas… :unamused: