libgimpwidgets: fix the non-resizing combo-box popup when switching from short…

… to long format of unit names.

We can clearly see that the main part of the widget is correctly resized but not
the popup. Unfortunately we don't have access to the popup widget which is
private data, so the best workaround I found so far was to pop the menu down and
up, which basically provokes a redraw to the correct size after contents change.

This fixes MR !385.
This commit is contained in:
Jehan 2023-06-23 00:42:50 +02:00
parent dc3eb3b340
commit aecf22defb
1 changed files with 14 additions and 0 deletions

View File

@ -102,6 +102,20 @@ gimp_unit_combo_box_popup_shown (GimpUnitComboBox *widget)
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), cell,
"text", GIMP_UNIT_STORE_UNIT_LONG_FORMAT,
NULL);
/* XXX This is ugly but it seems that GtkComboBox won't resize its popup
* menu when the contents changes (it only resizes the main "chosen item"
* area). We force a redraw by popping down then up after a contents
* change.
*/
g_signal_handlers_disconnect_by_func (widget,
G_CALLBACK (gimp_unit_combo_box_popup_shown),
NULL);
gtk_combo_box_popdown (GTK_COMBO_BOX (widget));
gtk_combo_box_popup (GTK_COMBO_BOX (widget));
g_signal_connect (widget, "notify::popup-shown",
G_CALLBACK (gimp_unit_combo_box_popup_shown),
NULL);
}
else
{