/*
 * This file is autogenerated with bcop:
 * The Compiz option code generator
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */


#include <core/core.h>

#include "showrepaint_options.h"

ShowrepaintOptions::ShowrepaintOptions (bool init /* = true */) :
    mOptions (ShowrepaintOptions::OptionNum),
    mNotify (ShowrepaintOptions::OptionNum)
{
    if (init)
        initOptions ();
}

void
ShowrepaintOptions::initOptions ()
{
    unsigned int state;
    CompAction action;

    // toggle_key
    mOptions[ShowrepaintOptions::ToggleKey].setName ("toggle_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    action.keyFromString ("<Super><Alt>r");
    mOptions[ShowrepaintOptions::ToggleKey].value().set (action);
    if (screen) screen->addAction (&mOptions[ShowrepaintOptions::ToggleKey].value ().action ());

    // intensity
    mOptions[ShowrepaintOptions::Intensity].setName ("intensity", CompOption::TypeInt);
    mOptions[ShowrepaintOptions::Intensity].rest ().set (0, 100);
    mOptions[ShowrepaintOptions::Intensity].value().set((int) 20);

}

ShowrepaintOptions::~ShowrepaintOptions ()
{
}


CompOption::Vector &
ShowrepaintOptions::getOptions ()
{
    return mOptions;
}

bool
ShowrepaintOptions::setOption (const CompString &name, CompOption::Value &value)
{
    CompOption   *o;
    unsigned int index;

    o = CompOption::findOption (mOptions, name, &index);

    if (!o)
        return false;

    switch (index)
    {
        case ShowrepaintOptions::ToggleKey:
            if (o->set (value))
            {
                if (!mNotify[ShowrepaintOptions::ToggleKey].empty ())
                    mNotify[ShowrepaintOptions::ToggleKey] (o, ShowrepaintOptions::ToggleKey);
                return true;
            }
            break;
        case ShowrepaintOptions::Intensity:
            if (o->set (value))
            {
                if (!mNotify[ShowrepaintOptions::Intensity].empty ())
                    mNotify[ShowrepaintOptions::Intensity] (o, ShowrepaintOptions::Intensity);
                return true;
            }
            break;
        default:
            break;
    }
    return false;

}

