gtk4 size_allocate

Quick question: what is the GTK4/Vala way to do stuff when the application window is resized, either manually or automatically (screen rotation on phone for example)?
In GTK3 is was size_allocate, but can’t find anything similar for GTK4 window.

The porting guide from GTK3 to GTK4 has a section about it →

Got it thanks: its been removed from GTK4.
How would you handle screen rotation on Pinephone? Like switching paned to vertical when the screen aspect is horiontal.

One way would be as the documentation suggests: use property notification for GtkWindow:default-width and GtkWindow:default-height. That obviously is far from having something like GtkWindow:orientation but can be worked with.

Tried window.notify[“default_width”].connect but it does nothing.
Have used widget.notify[“propertyname”].connect successfully though, is there an extra step to make this work for window?

Are you connecting to the right property?

Copied property name from Vala docs just to be sure Gtk.Window – gtk4

Interestingly window.notify.connect works, less efficient but can live with that for now.
Thanks for your help!

You must use the string name of the property, so it would be:

window.notify["default-width"].connect(() => {
  // ...

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