1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
3
* Copyright (C) 2013 Canonical Ltd
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 3 as
7
* published by the Free Software Foundation.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Authored by: Marco Trevisan <marco@ubuntu.com>
21
#include <glib/gi18n-lib.h>
24
#include <Nux/NuxTimerTickSource.h>
25
#include <Nux/WindowThread.h>
26
#include <NuxCore/AnimationController.h>
27
#include <UnityCore/SessionManager.h>
29
#include "unity-shared/BackgroundEffectHelper.h"
30
#include "SessionController.h"
31
#include "unity-shared/UnitySettings.h"
33
using namespace unity;
35
class MockSessionManager : public session::Manager
38
MockSessionManager() = default;
40
std::string RealName() const { return "Marco Trevisan"; }
41
std::string UserName() const { return "marco"; }
43
void Logout() { std::cout << "Logout" << std::endl; }
44
void Reboot() { std::cout << "Reboot" << std::endl; }
45
void Shutdown() { std::cout << "Shutdown" << std::endl; }
46
void Suspend() { std::cout << "Suspend" << std::endl; }
47
void Hibernate() { std::cout << "Hibernate" << std::endl; }
49
void ConfirmLogout() { std::cout << "ConfirmLogout" << std::endl; }
50
void ConfirmReboot() { std::cout << "ConfirmReboot" << std::endl; }
51
void ConfirmShutdown() { std::cout << "ConfirmShutdown" << std::endl; }
52
void CancelAction() { std::cout << "CancelAction" << std::endl; }
53
void ClosedDialog() { std::cout << "ClosedDialog" << std::endl; }
55
bool CanShutdown() const {return true;}
56
bool CanSuspend() const {return true;}
57
bool CanHibernate() const {return false;}
64
struct StandaloneController : Controller
66
StandaloneController(session::Manager::Ptr const& manager)
70
nux::Point GetOffsetPerMonitor(int monitor) override
81
: wt(nux::CreateGUIThread("Unity Session Controller", 1024, 300, 0, &SessionWindow::ThreadWidgetInit, this))
82
, animation_controller(tick_source)
93
static void ThreadWidgetInit(nux::NThread* thread, void* self)
95
static_cast<SessionWindow*>(self)->Init();
98
unity::Settings settings;
99
std::shared_ptr<nux::WindowThread> wt;
100
nux::NuxTimerTickSource tick_source;
101
nux::animation::AnimationController animation_controller;
102
session::Controller::Ptr controller;
105
void SessionWindow::Init()
107
BackgroundEffectHelper::blur_type = BLUR_NONE;
108
auto manager = std::make_shared<MockSessionManager>();
109
controller = std::make_shared<session::StandaloneController>(manager);
113
int main(int argc, char** argv)
115
gtk_init(&argc, &argv);
117
nux::NuxInitialize(0);
118
SessionWindow().Show();