~brandontschaefer/unity/bump-to-new-nux-abi

« back to all changes in this revision

Viewing changes to lockscreen/StandaloneLockScreen.cpp

  • Committer: Andrea Azzarone
  • Date: 2013-12-28 17:34:36 UTC
  • mto: (3566.5.438 unity)
  • mto: This revision was merged to the branch mainline in revision 3703.
  • Revision ID: azzaronea@gmail.com-20131228173436-jqschonskxaj5xx3
Initial commit for the unity lockscreen. UserAuthenticator added with tests too.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
 
2
/*
 
3
 * Copyright (C) 2013 Canonical Ltd
 
4
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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/>.
 
16
 *
 
17
 * Authored by: Andrea Azzarone <andrea.azzarone@canonical.com>
 
18
 */
 
19
 
 
20
//#include "config.h"
 
21
//#include <glib/gi18n-lib.h>
 
22
#include <gtk/gtk.h>
 
23
#include <Nux/Nux.h>
 
24
//#include <Nux/NuxTimerTickSource.h>
 
25
#include <Nux/WindowThread.h>
 
26
//#include <NuxCore/AnimationController.h>
 
27
 
 
28
#include "LockScreenController.h"
 
29
//#include "unity-shared/UnitySettings.h"
 
30
 
 
31
class MockSessionManager : public unity::session::Manager
 
32
{
 
33
public:
 
34
  std::string RealName() const { return ""; }
 
35
  std::string UserName() const { return ""; }
 
36
 
 
37
  void LockScreen() {}
 
38
  void Logout() {}
 
39
  void Reboot() {}
 
40
  void Shutdown() {}
 
41
  void Suspend() {}
 
42
  void Hibernate() {}
 
43
 
 
44
  void CancelAction() {}
 
45
 
 
46
  bool CanShutdown() const {return true;}
 
47
  bool CanSuspend() const {return true;}
 
48
  bool CanHibernate() const {return true;}
 
49
};
 
50
 
 
51
struct LockScreenWindow
 
52
{
 
53
  LockScreenWindow()
 
54
    : wt(nux::CreateGUIThread("Unity LockScreen Controller", 1024, 300, 0, &LockScreenWindow::ThreadWidgetInit, this))
 
55
    //, animation_controller(tick_source)
 
56
  {}
 
57
 
 
58
  void Show()
 
59
  {
 
60
    wt->Run(nullptr);
 
61
  }
 
62
 
 
63
private:
 
64
  void Init();
 
65
 
 
66
  static void ThreadWidgetInit(nux::NThread* thread, void* self)
 
67
  {
 
68
    static_cast<LockScreenWindow*>(self)->Init();
 
69
  }
 
70
 
 
71
  //unity::Settings settings;
 
72
  std::shared_ptr<nux::WindowThread> wt;
 
73
  //nux::NuxTimerTickSource tick_source;
 
74
  //nux::animation::AnimationController animation_controller;
 
75
  std::shared_ptr<unity::lockscreen::Controller> controller;
 
76
};
 
77
 
 
78
void LockScreenWindow::Init()
 
79
{
 
80
  auto manager = std::make_shared<MockSessionManager>();
 
81
  controller = std::make_shared<unity::lockscreen::Controller>(manager);
 
82
  manager->lock_requested.emit();
 
83
}
 
84
 
 
85
int main(int argc, char** argv)
 
86
{
 
87
  gtk_init(&argc, &argv);
 
88
 
 
89
  nux::NuxInitialize(0);
 
90
  LockScreenWindow().Show();
 
91
 
 
92
  return 0;
 
93
}