Libadwaita: Using UI definitions

Is there a way to write .ui files using widgets from libadwaita?

I’m new to GTK and libadwaita, so excuse me if I missed something completely obvious. I’m currently experimenting with using Rust and the libadwaita crate. The only thing that is a bit annoying is that I have to define my UI in Rust code, which makes it a bit unreadable and cluttered. So the solution would be to put that in a .ui file and loading that at runtime/compile time.

The issue is that GtkBuilder doesn’t recognize objects from libadwaita (e.g. AdwApplicationWindow).

I have tried to add the library to the UI definition, but this doesn’t change anything. I suppose GTK ignores that?

Is this behaviour intended or is it too early to expect that for a new library like libadwaita?

Using the Adw* types in a UI file should just work. You have to make sure that you either call adw::init() in your GApplication::startup() or use an AdwApplication which does this for you though, otherwise the Adw* types won’t be registered to the GType type system as as such GtkBuilder can’t find them when building the .UI templates.

1 Like

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