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

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

void
FadedesktopOptions::initOptions ()
{

    // fadetime
    mOptions[FadedesktopOptions::Fadetime].setName ("fadetime", CompOption::TypeInt);
    mOptions[FadedesktopOptions::Fadetime].rest ().set (1, 5000);
    mOptions[FadedesktopOptions::Fadetime].value().set((int) 500);

    // window_match
    mOptions[FadedesktopOptions::WindowMatch].setName ("window_match", CompOption::TypeMatch);
    mOptions[FadedesktopOptions::WindowMatch].value().set(CompMatch ("Toolbar | Utility | Dialog | Normal | Unknown"));
    mOptions[FadedesktopOptions::WindowMatch].value().match ().update ();

}

FadedesktopOptions::~FadedesktopOptions ()
{
}


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

bool
FadedesktopOptions::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 FadedesktopOptions::Fadetime:
            if (o->set (value))
            {
                if (!mNotify[FadedesktopOptions::Fadetime].empty ())
                    mNotify[FadedesktopOptions::Fadetime] (o, FadedesktopOptions::Fadetime);
                return true;
            }
            break;
        case FadedesktopOptions::WindowMatch:
            if (o->set (value))
            {
                if (!mNotify[FadedesktopOptions::WindowMatch].empty ())
                    mNotify[FadedesktopOptions::WindowMatch] (o, FadedesktopOptions::WindowMatch);
                return true;
            }
            break;
        default:
            break;
    }
    return false;

}

