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

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

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

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

    // window_types
    mOptions[AddhelperOptions::WindowTypes].setName ("window_types", CompOption::TypeMatch);
    mOptions[AddhelperOptions::WindowTypes].value().set(CompMatch ("Toolbar | Utility | Dialog | ModalDialog | Fullscreen | Normal"));
    mOptions[AddhelperOptions::WindowTypes].value().match ().update ();

    // ononinit
    mOptions[AddhelperOptions::Ononinit].setName ("ononinit", CompOption::TypeBool);
    mOptions[AddhelperOptions::Ononinit].value().set(false);

    // brightness
    mOptions[AddhelperOptions::Brightness].setName ("brightness", CompOption::TypeInt);
    mOptions[AddhelperOptions::Brightness].rest ().set (1, 100);
    mOptions[AddhelperOptions::Brightness].value().set((int) 30);

    // saturation
    mOptions[AddhelperOptions::Saturation].setName ("saturation", CompOption::TypeInt);
    mOptions[AddhelperOptions::Saturation].rest ().set (0, 100);
    mOptions[AddhelperOptions::Saturation].value().set((int) 50);

    // opacity
    mOptions[AddhelperOptions::Opacity].setName ("opacity", CompOption::TypeInt);
    mOptions[AddhelperOptions::Opacity].rest ().set (1, 100);
    mOptions[AddhelperOptions::Opacity].value().set((int) 100);

}

AddhelperOptions::~AddhelperOptions ()
{
}


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

bool
AddhelperOptions::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 AddhelperOptions::ToggleKey:
            if (o->set (value))
            {
                if (!mNotify[AddhelperOptions::ToggleKey].empty ())
                    mNotify[AddhelperOptions::ToggleKey] (o, AddhelperOptions::ToggleKey);
                return true;
            }
            break;
        case AddhelperOptions::WindowTypes:
            if (o->set (value))
            {
                if (!mNotify[AddhelperOptions::WindowTypes].empty ())
                    mNotify[AddhelperOptions::WindowTypes] (o, AddhelperOptions::WindowTypes);
                return true;
            }
            break;
        case AddhelperOptions::Ononinit:
            if (o->set (value))
            {
                if (!mNotify[AddhelperOptions::Ononinit].empty ())
                    mNotify[AddhelperOptions::Ononinit] (o, AddhelperOptions::Ononinit);
                return true;
            }
            break;
        case AddhelperOptions::Brightness:
            if (o->set (value))
            {
                if (!mNotify[AddhelperOptions::Brightness].empty ())
                    mNotify[AddhelperOptions::Brightness] (o, AddhelperOptions::Brightness);
                return true;
            }
            break;
        case AddhelperOptions::Saturation:
            if (o->set (value))
            {
                if (!mNotify[AddhelperOptions::Saturation].empty ())
                    mNotify[AddhelperOptions::Saturation] (o, AddhelperOptions::Saturation);
                return true;
            }
            break;
        case AddhelperOptions::Opacity:
            if (o->set (value))
            {
                if (!mNotify[AddhelperOptions::Opacity].empty ())
                    mNotify[AddhelperOptions::Opacity] (o, AddhelperOptions::Opacity);
                return true;
            }
            break;
        default:
            break;
    }
    return false;

}

