/*
 * 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 "obs_options.h"

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

void
ObsOptions::initOptions ()
{
    unsigned int state;
    CompAction action;
    CompOption::Value::Vector list;
    CompOption::Value value;

    // opacity_increase_key
    mOptions[ObsOptions::OpacityIncreaseKey].setName ("opacity_increase_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    mOptions[ObsOptions::OpacityIncreaseKey].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::OpacityIncreaseKey].value ().action ());

    // opacity_increase_button
    mOptions[ObsOptions::OpacityIncreaseButton].setName ("opacity_increase_button", CompOption::TypeButton);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitButton);
    action.buttonFromString ("<Alt>Button4");
    mOptions[ObsOptions::OpacityIncreaseButton].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::OpacityIncreaseButton].value ().action ());

    // opacity_decrease_key
    mOptions[ObsOptions::OpacityDecreaseKey].setName ("opacity_decrease_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    mOptions[ObsOptions::OpacityDecreaseKey].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::OpacityDecreaseKey].value ().action ());

    // opacity_decrease_button
    mOptions[ObsOptions::OpacityDecreaseButton].setName ("opacity_decrease_button", CompOption::TypeButton);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitButton);
    action.buttonFromString ("<Alt>Button5");
    mOptions[ObsOptions::OpacityDecreaseButton].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::OpacityDecreaseButton].value ().action ());

    // default_opacity_spawn_value
    mOptions[ObsOptions::DefaultOpacitySpawnValue].setName ("default_opacity_spawn_value", CompOption::TypeInt);
    mOptions[ObsOptions::DefaultOpacitySpawnValue].rest ().set (1, 100);
    mOptions[ObsOptions::DefaultOpacitySpawnValue].value().set((int) 100);

    // opacity_step
    mOptions[ObsOptions::OpacityStep].setName ("opacity_step", CompOption::TypeInt);
    mOptions[ObsOptions::OpacityStep].rest ().set (1, 10);
    mOptions[ObsOptions::OpacityStep].value().set((int) 5);

    // opacity_matches
    mOptions[ObsOptions::OpacityMatches].setName ("opacity_matches", CompOption::TypeList);
    list.clear ();
    mOptions[ObsOptions::OpacityMatches].value().set (CompOption::TypeMatch, list);

    // opacity_values
    mOptions[ObsOptions::OpacityValues].setName ("opacity_values", CompOption::TypeList);
    mOptions[ObsOptions::OpacityValues].rest ().set (0, 100);
    list.clear ();
    value.set((int) 90);
    list.push_back (value);
    mOptions[ObsOptions::OpacityValues].value().set (CompOption::TypeInt, list);

    // brightness_increase_key
    mOptions[ObsOptions::BrightnessIncreaseKey].setName ("brightness_increase_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    mOptions[ObsOptions::BrightnessIncreaseKey].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::BrightnessIncreaseKey].value ().action ());

    // brightness_increase_button
    mOptions[ObsOptions::BrightnessIncreaseButton].setName ("brightness_increase_button", CompOption::TypeButton);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitButton);
    mOptions[ObsOptions::BrightnessIncreaseButton].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::BrightnessIncreaseButton].value ().action ());

    // brightness_decrease_key
    mOptions[ObsOptions::BrightnessDecreaseKey].setName ("brightness_decrease_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    mOptions[ObsOptions::BrightnessDecreaseKey].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::BrightnessDecreaseKey].value ().action ());

    // brightness_decrease_button
    mOptions[ObsOptions::BrightnessDecreaseButton].setName ("brightness_decrease_button", CompOption::TypeButton);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitButton);
    mOptions[ObsOptions::BrightnessDecreaseButton].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::BrightnessDecreaseButton].value ().action ());

    // default_brightness_spawn_value
    mOptions[ObsOptions::DefaultBrightnessSpawnValue].setName ("default_brightness_spawn_value", CompOption::TypeInt);
    mOptions[ObsOptions::DefaultBrightnessSpawnValue].rest ().set (1, 100);
    mOptions[ObsOptions::DefaultBrightnessSpawnValue].value().set((int) 100);

    // brightness_step
    mOptions[ObsOptions::BrightnessStep].setName ("brightness_step", CompOption::TypeInt);
    mOptions[ObsOptions::BrightnessStep].rest ().set (1, 10);
    mOptions[ObsOptions::BrightnessStep].value().set((int) 5);

    // brightness_matches
    mOptions[ObsOptions::BrightnessMatches].setName ("brightness_matches", CompOption::TypeList);
    list.clear ();
    mOptions[ObsOptions::BrightnessMatches].value().set (CompOption::TypeMatch, list);

    // brightness_values
    mOptions[ObsOptions::BrightnessValues].setName ("brightness_values", CompOption::TypeList);
    mOptions[ObsOptions::BrightnessValues].rest ().set (0, 100);
    list.clear ();
    value.set((int) 90);
    list.push_back (value);
    mOptions[ObsOptions::BrightnessValues].value().set (CompOption::TypeInt, list);

    // saturation_increase_key
    mOptions[ObsOptions::SaturationIncreaseKey].setName ("saturation_increase_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    mOptions[ObsOptions::SaturationIncreaseKey].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::SaturationIncreaseKey].value ().action ());

    // saturation_increase_button
    mOptions[ObsOptions::SaturationIncreaseButton].setName ("saturation_increase_button", CompOption::TypeButton);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitButton);
    mOptions[ObsOptions::SaturationIncreaseButton].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::SaturationIncreaseButton].value ().action ());

    // saturation_decrease_key
    mOptions[ObsOptions::SaturationDecreaseKey].setName ("saturation_decrease_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    mOptions[ObsOptions::SaturationDecreaseKey].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::SaturationDecreaseKey].value ().action ());

    // saturation_decrease_button
    mOptions[ObsOptions::SaturationDecreaseButton].setName ("saturation_decrease_button", CompOption::TypeButton);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitButton);
    mOptions[ObsOptions::SaturationDecreaseButton].value().set (action);
    if (screen) screen->addAction (&mOptions[ObsOptions::SaturationDecreaseButton].value ().action ());

    // default_saturation_spawn_value
    mOptions[ObsOptions::DefaultSaturationSpawnValue].setName ("default_saturation_spawn_value", CompOption::TypeInt);
    mOptions[ObsOptions::DefaultSaturationSpawnValue].rest ().set (1, 100);
    mOptions[ObsOptions::DefaultSaturationSpawnValue].value().set((int) 100);

    // saturation_step
    mOptions[ObsOptions::SaturationStep].setName ("saturation_step", CompOption::TypeInt);
    mOptions[ObsOptions::SaturationStep].rest ().set (1, 10);
    mOptions[ObsOptions::SaturationStep].value().set((int) 5);

    // saturation_matches
    mOptions[ObsOptions::SaturationMatches].setName ("saturation_matches", CompOption::TypeList);
    list.clear ();
    mOptions[ObsOptions::SaturationMatches].value().set (CompOption::TypeMatch, list);

    // saturation_values
    mOptions[ObsOptions::SaturationValues].setName ("saturation_values", CompOption::TypeList);
    mOptions[ObsOptions::SaturationValues].rest ().set (0, 100);
    list.clear ();
    value.set((int) 90);
    list.push_back (value);
    mOptions[ObsOptions::SaturationValues].value().set (CompOption::TypeInt, list);

}

ObsOptions::~ObsOptions ()
{
}


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

bool
ObsOptions::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 ObsOptions::OpacityIncreaseKey:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::OpacityIncreaseKey].empty ())
                    mNotify[ObsOptions::OpacityIncreaseKey] (o, ObsOptions::OpacityIncreaseKey);
                return true;
            }
            break;
        case ObsOptions::OpacityIncreaseButton:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::OpacityIncreaseButton].empty ())
                    mNotify[ObsOptions::OpacityIncreaseButton] (o, ObsOptions::OpacityIncreaseButton);
                return true;
            }
            break;
        case ObsOptions::OpacityDecreaseKey:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::OpacityDecreaseKey].empty ())
                    mNotify[ObsOptions::OpacityDecreaseKey] (o, ObsOptions::OpacityDecreaseKey);
                return true;
            }
            break;
        case ObsOptions::OpacityDecreaseButton:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::OpacityDecreaseButton].empty ())
                    mNotify[ObsOptions::OpacityDecreaseButton] (o, ObsOptions::OpacityDecreaseButton);
                return true;
            }
            break;
        case ObsOptions::DefaultOpacitySpawnValue:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::DefaultOpacitySpawnValue].empty ())
                    mNotify[ObsOptions::DefaultOpacitySpawnValue] (o, ObsOptions::DefaultOpacitySpawnValue);
                return true;
            }
            break;
        case ObsOptions::OpacityStep:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::OpacityStep].empty ())
                    mNotify[ObsOptions::OpacityStep] (o, ObsOptions::OpacityStep);
                return true;
            }
            break;
        case ObsOptions::OpacityMatches:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::OpacityMatches].empty ())
                    mNotify[ObsOptions::OpacityMatches] (o, ObsOptions::OpacityMatches);
                return true;
            }
            break;
        case ObsOptions::OpacityValues:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::OpacityValues].empty ())
                    mNotify[ObsOptions::OpacityValues] (o, ObsOptions::OpacityValues);
                return true;
            }
            break;
        case ObsOptions::BrightnessIncreaseKey:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::BrightnessIncreaseKey].empty ())
                    mNotify[ObsOptions::BrightnessIncreaseKey] (o, ObsOptions::BrightnessIncreaseKey);
                return true;
            }
            break;
        case ObsOptions::BrightnessIncreaseButton:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::BrightnessIncreaseButton].empty ())
                    mNotify[ObsOptions::BrightnessIncreaseButton] (o, ObsOptions::BrightnessIncreaseButton);
                return true;
            }
            break;
        case ObsOptions::BrightnessDecreaseKey:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::BrightnessDecreaseKey].empty ())
                    mNotify[ObsOptions::BrightnessDecreaseKey] (o, ObsOptions::BrightnessDecreaseKey);
                return true;
            }
            break;
        case ObsOptions::BrightnessDecreaseButton:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::BrightnessDecreaseButton].empty ())
                    mNotify[ObsOptions::BrightnessDecreaseButton] (o, ObsOptions::BrightnessDecreaseButton);
                return true;
            }
            break;
        case ObsOptions::DefaultBrightnessSpawnValue:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::DefaultBrightnessSpawnValue].empty ())
                    mNotify[ObsOptions::DefaultBrightnessSpawnValue] (o, ObsOptions::DefaultBrightnessSpawnValue);
                return true;
            }
            break;
        case ObsOptions::BrightnessStep:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::BrightnessStep].empty ())
                    mNotify[ObsOptions::BrightnessStep] (o, ObsOptions::BrightnessStep);
                return true;
            }
            break;
        case ObsOptions::BrightnessMatches:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::BrightnessMatches].empty ())
                    mNotify[ObsOptions::BrightnessMatches] (o, ObsOptions::BrightnessMatches);
                return true;
            }
            break;
        case ObsOptions::BrightnessValues:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::BrightnessValues].empty ())
                    mNotify[ObsOptions::BrightnessValues] (o, ObsOptions::BrightnessValues);
                return true;
            }
            break;
        case ObsOptions::SaturationIncreaseKey:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::SaturationIncreaseKey].empty ())
                    mNotify[ObsOptions::SaturationIncreaseKey] (o, ObsOptions::SaturationIncreaseKey);
                return true;
            }
            break;
        case ObsOptions::SaturationIncreaseButton:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::SaturationIncreaseButton].empty ())
                    mNotify[ObsOptions::SaturationIncreaseButton] (o, ObsOptions::SaturationIncreaseButton);
                return true;
            }
            break;
        case ObsOptions::SaturationDecreaseKey:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::SaturationDecreaseKey].empty ())
                    mNotify[ObsOptions::SaturationDecreaseKey] (o, ObsOptions::SaturationDecreaseKey);
                return true;
            }
            break;
        case ObsOptions::SaturationDecreaseButton:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::SaturationDecreaseButton].empty ())
                    mNotify[ObsOptions::SaturationDecreaseButton] (o, ObsOptions::SaturationDecreaseButton);
                return true;
            }
            break;
        case ObsOptions::DefaultSaturationSpawnValue:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::DefaultSaturationSpawnValue].empty ())
                    mNotify[ObsOptions::DefaultSaturationSpawnValue] (o, ObsOptions::DefaultSaturationSpawnValue);
                return true;
            }
            break;
        case ObsOptions::SaturationStep:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::SaturationStep].empty ())
                    mNotify[ObsOptions::SaturationStep] (o, ObsOptions::SaturationStep);
                return true;
            }
            break;
        case ObsOptions::SaturationMatches:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::SaturationMatches].empty ())
                    mNotify[ObsOptions::SaturationMatches] (o, ObsOptions::SaturationMatches);
                return true;
            }
            break;
        case ObsOptions::SaturationValues:
            if (o->set (value))
            {
                if (!mNotify[ObsOptions::SaturationValues].empty ())
                    mNotify[ObsOptions::SaturationValues] (o, ObsOptions::SaturationValues);
                return true;
            }
            break;
        default:
            break;
    }
    return false;

}

