Getting GTK apps to fit the phone screen

How are people getting GTK apps to fit on the phone screen? I have been looking through the GTK documentation (I am using gtk-rs but most of it is the same as the standard GTK4 stuff).

At present I can not find a way to get my app to fit the phone screen. I think most of the standard librem5 apps are built using GTK so there must be a method to get the window to fit the phone. I have found options like default_width/height however these are almost always overridden. Even very basic stuff like a stack switcher with 4 tabs will set the width of the app far wider than the phone screen.

Is there a better construct to use than a stack switcher to get some buttons on the screen or is there a way to modify the tabs on the stack switcher to set the width at a size more suitable for the phone.

The best thing I have come up with so far to keep the width of the app the same is to use a scrollable container however it looks terrible and is very clunky to use.

This is a screenshot of a stack switcher when the screen size is set to 360x720. It breaks out immediately. Is there a way to edit these tabs to fit the phone screen or is there a better way of doing this altogether?

I don’t know much, but maybe this could help?
Adw – 1 (gnome.org)
What’s the Fuss About GNOME’s Libadwaita Library in Linux World? (itsfoss.com)

1 Like

You might need to include the libadwaita crate (https://crates.io/crates/libadwaita). Their documentation can be found here: https://world.pages.gitlab.gnome.org/Rust/libadwaita-rs/.

Some examples I’ve found of Rust GTK apps that use libadwaita and are adaptive are:

The libadwaita crate was the way to go. For the most part it involved switching to the constructs in the libadwaita library which took some time however the app is now usable on the phone.

It still twitches as different widgets get loaded on to the screen but it’s only moving a few pixels at a time now. This is a bit annoying but at least half the app isn’t shooting off of the screen.

1 Like