From aecf22defb6268e25eec0d02c7ddd287b5c526df Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 23 Jun 2023 00:42:50 +0200 Subject: [PATCH] =?UTF-8?q?libgimpwidgets:=20fix=20the=20non-resizing=20co?= =?UTF-8?q?mbo-box=20popup=20when=20switching=20from=20short=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … 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. --- libgimpwidgets/gimpunitcombobox.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libgimpwidgets/gimpunitcombobox.c b/libgimpwidgets/gimpunitcombobox.c index 93b34c15ee..b2ab392f81 100644 --- a/libgimpwidgets/gimpunitcombobox.c +++ b/libgimpwidgets/gimpunitcombobox.c @@ -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 {