From 368e250102af9b111e25f8e0dbba2db4fb0660cb Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 1 Dec 2012 17:18:10 +0400 Subject: [PATCH] Ticket #2841: adjust i18n label sizes in learn key dialog. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Learn keys dialogue shows "smaller buttons" when localized key names include special chars (as the "á" in "Avanzar página" for es_ES locale). "%Ns" formats for g_snprintf are not reliable for multibyte encodings. For larger buttons (> 16 characters), padding size must be zero. Thanks David Martin for the original patch. Signed-off-by: Andrew Borodin --- src/learn.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/learn.c b/src/learn.c index 7020c2e5c..3886fd70c 100644 --- a/src/learn.c +++ b/src/learn.c @@ -296,10 +296,17 @@ init_learn (void) for (i = 0; i < learn_total; i++) { char buffer[BUF_TINY]; + char *label; + int padding; learnkeys[i].ok = FALSE; learnkeys[i].sequence = NULL; - g_snprintf (buffer, sizeof (buffer), "%-16s", _(key_name_conv_tab[i].longname)); + + label = _(key_name_conv_tab[i].longname); + padding = 16 - str_term_width1 (label); + padding = max (0, padding); + g_snprintf (buffer, sizeof (buffer), "%s%*s", label, padding, ""); + learnkeys[i].button = WIDGET (button_new (y, x, B_USER + i, NARROW_BUTTON, buffer, learn_button)); learnkeys[i].label = WIDGET (label_new (y, x + 19, ""));