1
votes

I'm using GTK3+ (3.22) on Ubuntu server 18 (beta2) / x11 / openbox. Language is C. I'm porting an embedded application from GTK2 which did not seem to do dynamic resizing of label widgets when the text content reached a certain limit. On GTK3 the label (and button) widgets now seem to resize when the text content is close to the maximum size that can be displayed.

In the case of a button widget placed into a FIXED container on a window. I have tried the following...

The gtk_widget_set_size_request seems only to set a default or minimum, not a max:

gtk_widget_set_size_request( GTK_WIDGET( GuiBottomFarLeftButton ) , GuiBottomButtonWidth , GuiBottomButtonHeight );

I have tried gtk_widget_size_allocate but that doesn't seem to limit the maximum size.

GtkAllocation gtkallocTestSize = { GuiBottomButtonFarLeftX , GuiBottomButtonY , GuiBottomButtonWidth , GuiBottomButtonHeight};
gtk_widget_size_allocate( GTK_WIDGET( GuiBottomFarLeftButton ) , &gtkallocTestSize );

There does not appear to be a gtk_widget_... function that limits the maximum size or sizing behavior that I can find. So far I have not found a way to limit the maximum size of a specific widget. I would settle for a way to limit the maximum width as the vertical size of the controls seems to behave as it did under GTK2 in the application I'm working on. In most cases the resizing is only effecting the layout by 10 to 20 pixels but this creates a really bad user experience.

Is there a way to disable the resizing on a widget or limit it's maximum size? Or some other work around that actually functions on latest GTK3+ (3.22)?

1
This is due to changes in the algorithms used to compute the widget size between GTK+ 2 and GTK+ 3. The behavior you want was mostly a problem in GTK+ 2, because labels for example couldn't span on multiple lines automatically. This was the ground for height-for-width- and width-for-height geometry management.liberforce
Also you should add an MCVE.liberforce

1 Answers

0
votes

UX is a hard balance of optimisation. In general you should not assume that the gtk2 behaviour is what you want to replicate. The body of knowledge re: UX has increased since then and changes are in general positive. You will either be clipping text, decreasing font sizes or oversizing widgets. You can't have it all.

Scrolled windows help in many cases but obviously not for buttons and labels. In this case it is best to keep text short and use tooltips for anything that needs a more lengthy explanation.