~brandontschaefer/unity/enable-compose-key

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
/*
 * Copyright (C) 2013 Canonical Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by: Marco Trevisan <marco@ubuntu.com>
 */

#include "config.h"
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <Nux/Nux.h>
#include <Nux/NuxTimerTickSource.h>
#include <Nux/WindowThread.h>
#include <NuxCore/AnimationController.h>

#include "unity-shared/BackgroundEffectHelper.h"
#include "SessionController.h"
#include "unity-shared/UnitySettings.h"

using namespace unity;

class MockSessionManager : public session::Manager
{
public:
  MockSessionManager() = default;

  std::string RealName() const { return "Marco Trevisan"; }
  std::string UserName() const { return "marco"; }

  void LockScreen() { std::cout << "LockScreen" << std::endl; }
  void Logout() { std::cout << "Logout" << std::endl; }
  void Reboot() { std::cout << "Reboot" << std::endl; }
  void Shutdown() { std::cout << "Shutdown" << std::endl; }
  void Suspend() { std::cout << "Suspend" << std::endl; }
  void Hibernate() { std::cout << "Hibernate" << std::endl; }

  void CancelAction() { std::cout << "CancelAction" << std::endl; }

  bool CanShutdown() const {return true;}
  bool CanSuspend() const {return true;}
  bool CanHibernate() const {return true;}
};

struct SessionWindow
{
  SessionWindow()
    : wt(nux::CreateGUIThread("Unity Session Controller", 1024, 300, 0, &SessionWindow::ThreadWidgetInit, this))
    , animation_controller(tick_source)
  {}

  void Show()
  {
    wt->Run(nullptr);
  }

private:
  void Init();

  static void ThreadWidgetInit(nux::NThread* thread, void* self)
  {
    static_cast<SessionWindow*>(self)->Init();
  }

  unity::Settings settings;
  std::shared_ptr<nux::WindowThread> wt;
  nux::NuxTimerTickSource tick_source;
  nux::animation::AnimationController animation_controller;
  session::Controller::Ptr controller;
};

void SessionWindow::Init()
{
  BackgroundEffectHelper::blur_type = BLUR_NONE;
  auto manager = std::make_shared<MockSessionManager>();
  controller = std::make_shared<session::Controller>(manager);
  manager->shutdown_requested.emit(false);
}

int main(int argc, char** argv)
{
  gtk_init(&argc, &argv);

  nux::NuxInitialize(0);
  SessionWindow().Show();

  return 0;
}