Ejemplo n.º 1
0
MenuItem *
Menu::FindMarked()
{
    MenuItemIterator iterator = ItemIterator();
    MenuItem *item;

    while ((item = iterator.Next()) != NULL) {
        if (item->IsMarked())
            return item;
    }

    return NULL;
}
Ejemplo n.º 2
0
static void
apply_safe_mode_options(Menu *menu)
{
    MenuItemIterator iterator = menu->ItemIterator();
    MenuItem *item;
    char buffer[2048];
    int32 pos = 0;

    buffer[0] = '\0';

    while ((item = iterator.Next()) != NULL) {
        if (item->Type() == MENU_ITEM_SEPARATOR || !item->IsMarked()
                || item->Data() == NULL || (uint32)pos > sizeof(buffer))
            continue;

        size_t totalBytes = snprintf(buffer + pos, sizeof(buffer) - pos,
                                     "%s true\n", (const char *)item->Data());
        pos += std::min(totalBytes, sizeof(buffer) - pos - 1);
    }

    add_safe_mode_settings(buffer);
}