GTK ScrolledWindow max_content_width/height does not work with TextView

Viewed 317

I'm creating a simple "sticky note" application using GTK3. I implement the notes by wrapping a TextView in ScrolledWindow. I put them in Layout, so they are free to grow. I set min/max_content_width/height to control note size: I want it to start with some minimum size, then grow up to some point as text is entered into TextView and then once max size is reached, I want scrollbars to appear.

Minimum size works as expected, however ScolledWindow never grows - as soon as entered text stops fitting the initial area scrollbars appear. I tried setting vexpand/hexpand on both ScrolledWindow and TextView, but it didn't help.

There is little documentation on this, but as I understand it, max_content_width/height should do exactly what I need: expand ScrolledWindow up to some size, then show scrollbars. Is it some bug or am I missing something?

I'm using Rust, GTK 3.24.24 on Linux.

1 Answers

Without trying this, I think it should work to get the actual size of the Textview and setting it to the width request / height request of the ScrolledWindow, unless it is more than your max size. Probably by connecting to the TextView size changed signal.

To tell you the truth, I am not sure what max_content_width/height does in practical life.

Related