Dakota West
Dakota West

Reputation: 461

How can I limit the size of a widget in GTK?

I would like to limit the growth of a GTK text view (controlled by the program, not user) to only the size of its container. When the window resizes, I want it to resize, otherwise I want it to fit where it belongs. It tries to expand horizontally indefinitely instead of wrapping at its current width.

Upvotes: 2

Views: 2055

Answers (2)

Boris Burkov
Boris Burkov

Reputation: 14436

Indeed, you can put your widget into a ScrolledWindow, but beware: this will help only if POLICY is set to POLICY_AUTOMATIC or POLICY_ALWAYS - then ScrolledWindow will request only a minimal amount of space, required to draw its scrollbars.

If POLICY is POLICY_NEVER, ScrolledWindow will request as much size as it child requests, and the toplevel window will grow beyond its normal size. See gtkscrolledwindow.c, comment in the very beginning.

Upvotes: 1

LiuLang
LiuLang

Reputation: 773

Try to put that textview into a scrolledwindow.

Upvotes: 0

Related Questions