~unity-team/unity/trusty-1066971

« back to all changes in this revision

Viewing changes to unity-standalone/StandaloneUnity.cpp

  • Committer: Gord Allott
  • Date: 2012-05-21 14:23:27 UTC
  • mto: This revision was merged to the branch mainline in revision 2365.
  • Revision ID: gord.allott@canonical.com-20120521142327-uw4yo0m8iuirscym
Snapshot before refactoring components

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as published
 
6
 * by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * version 3 along with this program.  If not, see
 
15
 * <http://www.gnu.org/licenses/>
 
16
 *
 
17
 * Authored by: Gordon Allott <gord.allott@canonical.com>
 
18
 *              Neil Jagdish Patel <neil.patel@canonical.com>
 
19
 *
 
20
 */
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "Nux/Nux.h"
 
24
#include "Nux/VLayout.h"
 
25
#include "Nux/WindowThread.h"
 
26
#include "NuxGraphics/GraphicsEngine.h"
 
27
#include <NuxCore/Logger.h>
 
28
 
 
29
#include "unity-shared/BGHash.h"
 
30
#include "unity-shared/FontSettings.h"
 
31
#include "dash/DashView.h"
 
32
#include "dash/DashController.h"
 
33
#include "panel/PanelView.h"
 
34
#include "panel/PanelController.h"
 
35
#include "unity-shared/BackgroundEffectHelper.h"
 
36
#include "launcher/FavoriteStoreGSettings.h"
 
37
#include "launcher/LauncherController.h"
 
38
#include "launcher/Launcher.h"
 
39
#include "unity-shared/DashSettings.h"
 
40
#include "unity-shared/DashStyle.h"
 
41
#include "unity-shared/PanelStyle.h"
 
42
#include "unity-shared/UBusWrapper.h"
 
43
#include "unity-shared/UBusMessages.h"
 
44
 
 
45
namespace
 
46
{
 
47
  static int display_width = 1280;
 
48
  static int display_height = 720;
 
49
  static gboolean no_window_decorations = FALSE;
 
50
 
 
51
  static GOptionEntry entries[] =
 
52
  {
 
53
    {"width", 'w', 0, G_OPTION_ARG_INT, &display_width, "Display width", NULL},
 
54
    {"height", 'h', 0, G_OPTION_ARG_INT, &display_height, "Display height", NULL},
 
55
    {"no-window-decorations", 'd', 0, G_OPTION_ARG_NONE, &no_window_decorations, "Disables the window decorations", NULL},
 
56
    {NULL}
 
57
  };
 
58
}
 
59
 
 
60
using namespace unity;
 
61
 
 
62
class UnityStandalone
 
63
{
 
64
public:
 
65
  UnityStandalone ();
 
66
  ~UnityStandalone ();
 
67
 
 
68
  static void InitWindowThread (nux::NThread* thread, void* InitData);
 
69
  void Init ();
 
70
 
 
71
  launcher::Controller::Ptr launcher_controller;
 
72
  dash::Controller::Ptr dash_controller;
 
73
  panel::Controller::Ptr panel_controller;
 
74
};
 
75
 
 
76
UnityStandalone::UnityStandalone ()
 
77
{
 
78
}
 
79
 
 
80
UnityStandalone::~UnityStandalone ()
 
81
{
 
82
}
 
83
 
 
84
void UnityStandalone::Init ()
 
85
{
 
86
  launcher_controller.reset(new launcher::Controller(0));
 
87
  dash_controller.reset(new dash::Controller());
 
88
  panel_controller.reset(new panel::Controller());
 
89
 
 
90
  dash_controller->launcher_width = launcher_controller->launcher().GetAbsoluteWidth() - 1;
 
91
 
 
92
  UBusManager().SendMessage(UBUS_DASH_EXTERNAL_ACTIVATION, nullptr);
 
93
}
 
94
 
 
95
void UnityStandalone::InitWindowThread(nux::NThread* thread, void* InitData)
 
96
{
 
97
  UnityStandalone *self = static_cast<UnityStandalone*>(InitData);
 
98
  self->Init();
 
99
}
 
100
 
 
101
int main(int argc, char **argv)
 
102
{
 
103
  nux::WindowThread* wt = NULL;
 
104
  GError *error = NULL;
 
105
  GOptionContext *context;
 
106
 
 
107
  nux::NuxInitialize(0);
 
108
  nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
 
109
  
 
110
  context = g_option_context_new("- Unity standalone");
 
111
  g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
 
112
  g_option_context_add_group(context, gtk_get_option_group(TRUE));
 
113
  g_option_context_parse(context, &argc, &argv, &error);
 
114
  if (error != NULL)
 
115
  {
 
116
    g_print("Option parsiong failed: %s\n", error->message);
 
117
    g_error_free(error);
 
118
    exit(1);
 
119
  }
 
120
 
 
121
  gtk_init(&argc, &argv);
 
122
 
 
123
  BGHash bghash;
 
124
  FontSettings font_settings;
 
125
 
 
126
  // The instances for the pseudo-singletons.
 
127
  dash::Style dash_style;
 
128
  dash::Settings dash_settings;
 
129
  dash_settings.SetFormFactor(dash::FormFactor::NETBOOK);
 
130
  panel::Style panel_style;
 
131
 
 
132
  GeisAdapter geis_adapter;
 
133
  internal::FavoriteStoreGSettings favorite_store;
 
134
  BackgroundEffectHelper::blur_type = BLUR_NONE;
 
135
 
 
136
  UnityStandalone *standalone_runner = new UnityStandalone();
 
137
  wt = nux::CreateNuxWindow("standalone-unity",
 
138
                            display_width, display_height,
 
139
                            (no_window_decorations) ? nux::WINDOWSTYLE_NOBORDER : nux::WINDOWSTYLE_NORMAL,
 
140
                            0, /* no parent */
 
141
                            false,
 
142
                            &UnityStandalone::InitWindowThread,
 
143
                            standalone_runner);
 
144
 
 
145
  wt->Run(NULL);
 
146
  delete wt;
 
147
  return 0;
 
148
}