Exemplo n.º 1
0
int
keymapMenuSelect(dialogMenuItem *self)
{
    static const struct {
        const char *country, *lang;
    } map[] = {
        {"dk", "danish"},
        {"ee", "estonian"},
        {"fi", "finnish"},
        {"de", "german"},
        {"is", "icelandic"},
        {"no", "norwegian"},
        {"pl", "pl_PL"},
        {"es", "spanish"},
        {"se", "swedish"},
        {"ch", "swiss"},
        {"gb", "uk"},
        {"gg", "uk"},
        {"ie", "uk"},
        {"im", "uk"},
        {"je", "uk"},
        {NULL, NULL}
    };
    const char *country, *lang;
    int i;
    int choice, scroll, curr, max;
    char prefix[16 + 1];

    if ((country = variable_get(VAR_COUNTRY)) != NULL)
    {
        lang = country;
        for (i = 0; map[i].country; ++i)
            if (!strcmp(country, map[i].country))
            {
                lang = map[i].lang;
                break;
            }

        snprintf(prefix, sizeof(prefix), "keymap=%s.iso", lang);
        if ((choice = keymapSetDefault(prefix)) == -1)
        {
            snprintf(prefix, sizeof(prefix), "keymap=%s", lang);
            if ((choice = keymapSetDefault(prefix)) == -1) {
#ifdef PC98
                snprintf(prefix, sizeof(prefix), "keymap=jp.pc98");
#else
                snprintf(prefix, sizeof(prefix), "keymap=us.iso");
#endif
                if ((choice = keymapSetDefault(prefix)) == -1)
                    choice = 0;
            }
        }

        dmenuSetDefaultIndex(&MenuSysconsKeymap, &choice, &scroll, &curr, &max);
        return dmenuOpen(&MenuSysconsKeymap, &choice, &scroll, &curr, &max, FALSE);
    }
    else
        return dmenuOpenSimple(&MenuSysconsKeymap, FALSE) ? DITEM_SUCCESS :
               DITEM_FAILURE;
}
Exemplo n.º 2
0
int
dmenuSubmenu(dialogMenuItem *tmp)
{
    return (dmenuOpenSimple((DMenu *)(tmp->data), FALSE) ? DITEM_SUCCESS : DITEM_FAILURE);
}