I’m having trouble controlling the width of GtkLabel in my app. Here’s the context:
- There’s a window showing icons in a grid, each one having an associated label.
- The layout looks fine in English, but in many translations the labels are too long, making the layout too sparse.
- Up till now I’ve truncated/ellipsized long labels at 15 characters. That works, but users whose language is not English don’t like it much!
- So my next thought is: insist on the label-width limit but get long labels to wrap onto a second line if necessary. (The labels include spaces so word-wrapping should work.)
The thing is that I can’t get the wrapping to work as intended. I’m trying two APIs for the widget that includes the labels: GtkGrid and (yes, I know it’s deprecated) GtkTable. In each case there’s a problem.
- With GtkGrid, the labels end up wider than the specified maximum number of characters (15).
- With GtkTable, some of the labels end up wrapped onto 3 lines, even though they would fit on 2 lines given the 15-character width limit.