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

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

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

    // main_menu_key
    mOptions[GnomecompatOptions::MainMenuKey].setName ("main_menu_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    action.keyFromString ("<Alt>F1");
    mOptions[GnomecompatOptions::MainMenuKey].value().set (action);
    if (screen) screen->addAction (&mOptions[GnomecompatOptions::MainMenuKey].value ().action ());

    // run_key
    mOptions[GnomecompatOptions::RunKey].setName ("run_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    action.keyFromString ("<Alt>F2");
    mOptions[GnomecompatOptions::RunKey].value().set (action);
    if (screen) screen->addAction (&mOptions[GnomecompatOptions::RunKey].value ().action ());

    // command_screenshot
    mOptions[GnomecompatOptions::CommandScreenshot].setName ("command_screenshot", CompOption::TypeString);
    mOptions[GnomecompatOptions::CommandScreenshot].value().set(CompString ("gnome-screenshot"));

    // run_command_screenshot_key
    mOptions[GnomecompatOptions::RunCommandScreenshotKey].setName ("run_command_screenshot_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    action.keyFromString ("Print");
    mOptions[GnomecompatOptions::RunCommandScreenshotKey].value().set (action);
    if (screen) screen->addAction (&mOptions[GnomecompatOptions::RunCommandScreenshotKey].value ().action ());

    // command_window_screenshot
    mOptions[GnomecompatOptions::CommandWindowScreenshot].setName ("command_window_screenshot", CompOption::TypeString);
    mOptions[GnomecompatOptions::CommandWindowScreenshot].value().set(CompString ("gnome-screenshot --window"));

    // run_command_window_screenshot_key
    mOptions[GnomecompatOptions::RunCommandWindowScreenshotKey].setName ("run_command_window_screenshot_key", CompOption::TypeKey);
    state = CompAction::StateAutoGrab;
    action = CompAction ();
    action.setState (state | CompAction::StateInitKey);
    action.keyFromString ("<Alt>Print");
    mOptions[GnomecompatOptions::RunCommandWindowScreenshotKey].value().set (action);
    if (screen) screen->addAction (&mOptions[GnomecompatOptions::RunCommandWindowScreenshotKey].value ().action ());

    // command_terminal
    mOptions[GnomecompatOptions::CommandTerminal].setName ("command_terminal", CompOption::TypeString);
    mOptions[GnomecompatOptions::CommandTerminal].value().set(CompString ("gnome-terminal"));

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

}

GnomecompatOptions::~GnomecompatOptions ()
{
}


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

bool
GnomecompatOptions::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 GnomecompatOptions::MainMenuKey:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::MainMenuKey].empty ())
                    mNotify[GnomecompatOptions::MainMenuKey] (o, GnomecompatOptions::MainMenuKey);
                return true;
            }
            break;
        case GnomecompatOptions::RunKey:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::RunKey].empty ())
                    mNotify[GnomecompatOptions::RunKey] (o, GnomecompatOptions::RunKey);
                return true;
            }
            break;
        case GnomecompatOptions::CommandScreenshot:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::CommandScreenshot].empty ())
                    mNotify[GnomecompatOptions::CommandScreenshot] (o, GnomecompatOptions::CommandScreenshot);
                return true;
            }
            break;
        case GnomecompatOptions::RunCommandScreenshotKey:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::RunCommandScreenshotKey].empty ())
                    mNotify[GnomecompatOptions::RunCommandScreenshotKey] (o, GnomecompatOptions::RunCommandScreenshotKey);
                return true;
            }
            break;
        case GnomecompatOptions::CommandWindowScreenshot:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::CommandWindowScreenshot].empty ())
                    mNotify[GnomecompatOptions::CommandWindowScreenshot] (o, GnomecompatOptions::CommandWindowScreenshot);
                return true;
            }
            break;
        case GnomecompatOptions::RunCommandWindowScreenshotKey:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::RunCommandWindowScreenshotKey].empty ())
                    mNotify[GnomecompatOptions::RunCommandWindowScreenshotKey] (o, GnomecompatOptions::RunCommandWindowScreenshotKey);
                return true;
            }
            break;
        case GnomecompatOptions::CommandTerminal:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::CommandTerminal].empty ())
                    mNotify[GnomecompatOptions::CommandTerminal] (o, GnomecompatOptions::CommandTerminal);
                return true;
            }
            break;
        case GnomecompatOptions::RunCommandTerminalKey:
            if (o->set (value))
            {
                if (!mNotify[GnomecompatOptions::RunCommandTerminalKey].empty ())
                    mNotify[GnomecompatOptions::RunCommandTerminalKey] (o, GnomecompatOptions::RunCommandTerminalKey);
                return true;
            }
            break;
        default:
            break;
    }
    return false;

}

