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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/*
* Copyright 2010 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 warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY 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
* version 3 along with this program. If not, see
* <http://www.gnu.org/licenses/>
*
* Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
*
*/
#include <Nux/Nux.h>
#include <Nux/NuxTimerTickSource.h>
#include <Nux/VLayout.h>
#include <Nux/HLayout.h>
#include <Nux/WindowThread.h>
#include <NuxCore/AnimationController.h>
#include <NuxGraphics/GraphicsEngine.h>
#include <NuxCore/Logger.h>
#include <UnityCore/DBusIndicators.h>
#include <gtk/gtk.h>
#include "unity-shared/MockableBaseWindow.h"
#include "unity-shared/UnitySettings.h"
#include "unity-shared/KeyGrabber.h"
#include "unity-shared/PanelStyle.h"
#include "PanelView.h"
using namespace unity;
using namespace unity::panel;
struct PanelWindow
{
PanelWindow()
: wt(nux::CreateGUIThread("Unity Panel", 1024, 24, 0, &PanelWindow::ThreadWidgetInit, this))
, animation_controller(tick_source)
{}
void Show()
{
wt->Run(nullptr);
}
private:
struct StandalonePanelView : public PanelView
{
// Used to sync menu geometries
StandalonePanelView(MockableBaseWindow* window, menu::Manager::Ptr const& indicators)
: PanelView(window, indicators)
{}
std::string GetName() const { return "StandalonePanel"; }
};
struct MockKeyGrabber : key::Grabber
{
CompAction::Vector& GetActions() { return actions_; }
void AddAction(CompAction const&) {}
void RemoveAction(CompAction const&) {}
private:
CompAction::Vector actions_;
};
void Init()
{
panel_window = new MockableBaseWindow("StandalonePanel");
auto dbus_indicators = std::make_shared<indicator::DBusIndicators>();
auto key_grabber = std::make_shared<MockKeyGrabber>();
indicators_ = std::make_shared<menu::Manager>(dbus_indicators, key_grabber);
PanelView* panel = new StandalonePanelView(panel_window.GetPointer(), indicators_);
nux::HLayout* layout = new nux::HLayout(NUX_TRACKER_LOCATION);
layout->AddView(panel, 1);
layout->SetContentDistribution(nux::MAJOR_POSITION_START);
panel_window->SetLayout(layout);
panel_window->SetBackgroundColor(nux::color::Transparent);
panel_window->ShowWindow(true);
panel_window->SetWidth(1024);
panel_window->SetXY(0, 0);
panel_window->SetMaximumHeight(panel_style.PanelHeight());
wt->window_configuration.connect([this] (int x, int y, int w, int h) {
panel_window->SetWidth(w);
});
}
static void ThreadWidgetInit(nux::NThread* thread, void* self)
{
static_cast<PanelWindow*>(self)->Init();
}
unity::Settings settings;
panel::Style panel_style;
std::shared_ptr<nux::WindowThread> wt;
nux::NuxTimerTickSource tick_source;
nux::animation::AnimationController animation_controller;
nux::ObjectPtr<MockableBaseWindow> panel_window;
menu::Manager::Ptr indicators_;
};
int main(int argc, char** argv)
{
gtk_init(&argc, &argv);
nux::NuxInitialize(0);
nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
PanelWindow().Show();
return 0;
}
|