Subject: Re: bug#56607: 29.0.50; (setq auto-resize-tool-bars 'grow-only) has no effect (pgtk)

From: Richard Hansen <[email-masked]>
Date: Mon, 18 Jul 2022 01:43:32 -0400

On 7/18/22 00:35, Po Lu wrote:
> Richard Hansen <[email-masked]> writes:
> 
>> Can the dimensions of the toolbar be inspected?
> 
> Yes, the height and width are constant when the tool bar is on the top
> or bottom.  When the tool bar is on the left or right of the frame, then
> resizing can happen, but in that case I'm not sure how it works.
> 
>> If so, we can force the container widget to never shrink if
>> `auto-resize-tool-bars' is `grow-only'.
> 
> GTK never resizes the tool bar itself, so I'm not sure how that would
> make a difference.

What I mean is we would inspect the size of the toolbar (before any clipping required to fit inside the container widget) then adjust the size of the container widget appropriately.

> 
>> If the toolbar width changes, we could do the (un)wrapping ourselves: 
>> move the buttons to/from another toolbar underneath the upper toolbar. 
>> The lower toolbar would still be inside the same container widget as 
>> the upper toolbar, and `grow-only' would pay attention to the sum of 
>> the heights of the toolbars.  Would that work?
> 
> Maybe, but it's a lot of trouble to create such a feature that the GTK 
> developers are bound to break at some point.

That's a good point.  Out of curiosity I looked into GTK4 and they did away with the toolbar class.  Users should instead use a GtkBox containing buttons, and apply appropriate styling.  libadwaita provides a toolbar style class for this purpose [1].  I'm guessing it would be straightforward to implement toolbar button wrapping in GTK4, if/when Emacs migrates to it.

[1] https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/style-classes.html#toolbars

> 
> I'd rather just disable auto-resize-tool-bars under GTK.  That's not a 
> feature GTK tool bars are designed to support.

Fair enough.  In the meantime I filed bug#56627 about the inconsistent toolbar button icon sizing.  Maybe that issue is easier to fix.