gtk/gtkaccelgroup.c: Fix build on Visual Studio

Visual Studio does not allow one to initialize structure members with
non-constant expressions, caused by using strlen(s), so fix this by
using sizeof(s) - 1 instead.
This commit is contained in:
Chun-wei Fan 2020-04-29 00:07:27 +08:00
parent ac3d3c647e
commit d0a8d263ac

View File

@ -574,18 +574,20 @@ char *
gtk_accelerator_name (guint accelerator_key,
GdkModifierType accelerator_mods)
{
#define TXTLEN(s) sizeof (s) - 1
static const struct {
guint mask;
const char *text;
gsize text_len;
} mask_text[] = {
{ GDK_SHIFT_MASK, "<Shift>", strlen ("<Shift>") },
{ GDK_CONTROL_MASK, "<Control>", strlen ("<Control>") },
{ GDK_ALT_MASK, "<Alt>", strlen ("<Alt>") },
{ GDK_META_MASK, "<Meta>", strlen ("<Meta>") },
{ GDK_SUPER_MASK, "<Super>", strlen ("<Super>") },
{ GDK_HYPER_MASK, "<Hyper>", strlen ("<Hyper>") }
{ GDK_SHIFT_MASK, "<Shift>", TXTLEN ("<Shift>") },
{ GDK_CONTROL_MASK, "<Control>", TXTLEN ("<Control>") },
{ GDK_ALT_MASK, "<Alt>", TXTLEN ("<Alt>") },
{ GDK_META_MASK, "<Meta>", TXTLEN ("<Meta>") },
{ GDK_SUPER_MASK, "<Super>", TXTLEN ("<Super>") },
{ GDK_HYPER_MASK, "<Hyper>", TXTLEN ("<Hyper>") }
};
#undef TXTLEN
GdkModifierType saved_mods;
guint l;
guint name_len;