/*
 * Copyright (C) 2009 Emweb bv, Herent, Belgium.
 *
 * See the LICENSE file for terms of use.
 */

#include "DeferredWidget.h"
#include "Notification.h"
#include "TopicTemplate.h"

#include <Wt/WMenu.h>

Notification::Notification()
{
#if 0
  addText(tr("notification-intro"), this);
#endif
}

void Notification::populateSubMenu(Wt::WMenu *menu)
{
  menu->addItem("WNotification",
                deferCreate([this]{ return wnotification(); }))
    ->setPathComponent("");

  menu->addItem("WBadge",
                deferCreate([this]{ return wbadge(); }));

  menu->addItem("WFavicon",
                deferCreate([this]{ return wfavicon(); }));
}


#include "examples/AskNotificationPermission.cpp"
#include "examples/NotificationSend.cpp"
#include "examples/NotificationChat.cpp"

std::unique_ptr<Wt::WWidget> Notification::wnotification()
{
  auto result = std::make_unique<TopicTemplate>("notification-wnotification");

  result->bindWidget("AskNotificationPermission", AskNotificationPermission());
  result->bindWidget("NotificationSend", NotificationSend());
  result->bindWidget("NotificationChat", NotificationChat());

  return std::move(result);
}

#include "examples/Badge.cpp"
#include "examples/BadgeInPopupMenu.cpp"

std::unique_ptr<Wt::WWidget> Notification::wbadge()
{
  auto result = std::make_unique<TopicTemplate>("notification-wbadge");

  result->bindWidget("Badge", Badge());
  result->bindWidget("BadgeInPopupMenu", BadgeInPopupMenu());

  return std::move(result);
}

#include "examples/ChangeFavicon.cpp"
#include "examples/FaviconPair.cpp"

std::unique_ptr<Wt::WWidget> Notification::wfavicon()
{
  auto result = std::make_unique<TopicTemplate>("notification-wfavicon");

  result->bindWidget("ChangeFavicon", ChangeFavicon());
  result->bindWidget("FaviconPair", FaviconPair());

  return std::move(result);
}