From bdb47a82fa02e10352fe188e3b4a67d5f637424c Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sat, 2 Sep 2017 21:22:38 +0200 Subject: [PATCH] Honour the display width variable property --- src/ui/gui/psppire-dict.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index 3bc39e4095..f491ebff71 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -99,6 +99,22 @@ gi (GListModel *list, guint id) gtk_button_set_label (GTK_BUTTON (button), var_get_name (v)); gtk_widget_set_tooltip_text (button, var_get_label (v)); + + PangoRectangle rect; + + PangoContext *context = gtk_widget_create_pango_context (button); + PangoLayout *layout = pango_layout_new (context); + + pango_layout_set_text (layout, "M", 1); + + pango_layout_get_extents (layout, NULL, &rect); + + g_object_unref (G_OBJECT (layout)); + g_object_unref (G_OBJECT (context)); + + gtk_widget_set_size_request (button, + var_get_display_width (v) * rect.width / PANGO_SCALE, + -1); } return button; -- 2.30.2