[PATCHES] ComboBox only ever upsizes when the model changes, but it should also shrink if appropriate
@dboles
Submitted by Daniel Boles Link to original bug (#769608)
Description
Created attachment 332893
gcc pkg-config --cflags gtk+-3.0
-std=c11 test.c pkg-config --libs gtk+-3.0
As in the title and demonstrated by the attached C program.
If you populate a ComboBox with some options whose values as rendered on the button are narrow (short text and/or small image), then change to a model with any wider value(s) - the ComboBox resizes up (preferred_size) to fit the new most-wide option. That's great!
But if you change to a model whose options are all narrower than the current model... the ComboBox's Button doesn't size back down appropriately. It seems like the resize does a max() relative to the current size of the Button, rather than purely among the new model's options. End result: the new width is the max of all options the CB has ever seen. Manually setting a size_request can't shrink it.
This leads to inconsistencies when using ComboBoxes with dynamically populated models of options, e.g.:
- A CB that had a nice narrow, exactly sized Button at one point in the program can later have a menu that's far too wide - based on options that are no longer there, from a previous use of the CB with a totally different model.
- The corollary is that it leads to some instances of the CB having big gaps of empty space on either side of the displayed value, and others not.
Can this be sorted so that the ComboBox's Button is always appropriately resized to fit its current model, instead of taking the max of all options it's ever had?
Thanks.
Attachment 332893, "gcc pkg-config --cflags gtk+-3.0
-std=c11 test.c pkg-config --libs gtk+-3.0
":
test.c
Version: 3.22.x