Ticket #2841: adjust i18n label sizes in learn key dialog.

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 <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-12-01 17:18:10 +04:00
parent f25feaab1f
commit 368e250102

View File

@ -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, ""));