bool XmasWidget::LoadWidget(std::string, double _x, double _y, std::string _id)
{
        std::string witem = "calaos/widget/xmas";
        if (!LoadEdje(witem))
        {
                return false;
        }

        setLayer(500);
        EdjeObject::Show();

        clip = evas_object_rectangle_add(evas);
        evas_object_show(clip);
        edje_object_part_swallow(edje, "widget.swallow", clip);

        Resize(1024, 768);

        //create some flakes
        for (int i = 0;i < MAX_FLAKE;i++)
        {
                std::string type;
                if (i < MAX_FLAKE / 3) type = "flake_small";
                else if (i >= MAX_FLAKE / 3 && i < (MAX_FLAKE / 3) * 2) type = "flake_medium";
                else type = "flake_large";

                EdjeObject *o = new EdjeObject(theme, evas);
                if (!o->LoadEdje("calaos/widget/xmas/" + type))
                    cError() << "Error loading edje group calaos/widget/xmas/" + type;
                o->setLayer(500);
                evas_object_clip_set(o->getEvasObject(), clip);

                Flake *flake = new Flake(o);

                int tx = random() % clipw;
                int ty = random() % cliph;

                flake->Move(tx + clipx, ty + clipy);
                flake->Show();
                flake->setStart(ecore_time_get() + (double)(random() % (flake->getHeight() * 10)) / (double)flake->getHeight());

                if (type == "flake_small") flake->setSpeed(1);
                if (type == "flake_medium") flake->setSpeed(2);
                if (type == "flake_large") flake->setSpeed(3);

                flakes.push_back(flake);
        }

        return true;
}
ScreenSuspendView::ScreenSuspendView(Evas *_e, Evas_Object *p):
        EdjeObject(ApplicationMain::getTheme(), _e),
        parent(p)
{
        evas_object_data_set(edje, "ScreenSuspendView", this);

        try
        {
                LoadEdje("calaos/screen_suspend");
        }
        catch(exception const& e)
        {
                Utils::logger("root") << Priority::CRIT << "ScreenSuspendView: Can't load edje" << log4cpp::eol;
                throw;
        }

        Move(0, 0);
        setLayer(5000);

        evas_object_event_callback_add(parent, EVAS_CALLBACK_RESIZE, _window_resize_cb, this);

        object_signal.connect(sigc::mem_fun(*this, &ScreenSuspendView::edjeCallback));

        ScreenManager::instance().wakeup_screen.connect([=]()
        {
                EmitSignal("now,wakeup", "calaos");
                EmitSignal("event,repeat,activate", "calaos");
                is_during_wakeup = false;
        });

        ScreenManager::instance().wakeup_screen_start.connect([=]()
        {
                if(is_during_wakeup)
                        return;

                EmitSignal("start,wakeup", "calaos");
                is_during_wakeup = true;

                if(Utils::get_config_option("dpms_block") == "true")
                {
                        //TODO, use a pin code instead of the full password here
                        //and show a PIN code keyboard only with numbers
//                        ApplicationMain::Instance().ShowKeyboard(
//                                                _("Locked screen, please enter your password to unlock."),
//                                                sigc::mem_fun(*this, &ScreenSuspendView::keyboardCallback),
//                                                false
//                        );
                }
        });

        ScreenManager::instance().suspend_screen.connect([=]()
        {
                //TOFIX
                //ApplicationMain::Instance().ForceCloseKeyboard();
        });

        ScreenManager::instance().suspend_screen_start.connect([=]()
        {
                EmitSignal("event,repeat,deactivate", "calaos");
                EmitSignal("start,suspend", "calaos");
                is_during_suspend = true;
        });
}