summaryrefslogtreecommitdiff
path: root/unity-standalone
diff options
authorGord Allott <gord.allott@canonical.com>2012-05-21 15:23:27 +0100
committerGord Allott <gord.allott@canonical.com>2012-05-21 15:23:27 +0100
commit847e04974626b96a28c42fdb966a7f1df801ca23 (patch)
treeaa9c550a5422efbebf199fc5f9c203e8fc67e409 /unity-standalone
parent892506d053404f1851bc19804f9d301c4d015532 (diff)
Snapshot before refactoring components
(bzr r2356.2.1)
Diffstat (limited to 'unity-standalone')
-rw-r--r--unity-standalone/CMakeLists.txt44
-rw-r--r--unity-standalone/StandaloneUnity.cpp148
2 files changed, 192 insertions, 0 deletions
diff --git a/unity-standalone/CMakeLists.txt b/unity-standalone/CMakeLists.txt
new file mode 100644
index 000000000..354a9abce
--- /dev/null
+++ b/unity-standalone/CMakeLists.txt
@@ -0,0 +1,44 @@
+set(UNITY_SRC ../plugins/unityshell/src)
+
+find_package (PkgConfig)
+
+set (CFLAGS
+ ${CACHED_UNITY_DEPS_CFLAGS}
+ ${CACHED_UNITY_DEPS_CFLAGS_OTHER}
+ ${MAINTAINER_CFLAGS}
+ "-DGETTEXT_PACKAGE=\"unity\""
+ "-I${CMAKE_CURRENT_BINARY_DIR}"
+ )
+
+if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+ set (CFLAGS ${CFLAGS} "-fPIC")
+endif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
+
+add_definitions (${CFLAGS})
+
+set (LIBS ${CACHED_UNITY_DEPS_LIBRARIES} "-lunity-core-${UNITY_API_VERSION} -lm -lGL -lGLU")
+link_libraries (${LIBS})
+
+set (LIB_PATHS ${CACHED_UNITY_DEPS_LIBRARY_DIRS})
+link_directories (${CMAKE_BINARY_DIR}/UnityCore ${LIB_PATHS})
+
+include_directories (. .. ../services ../UnityCore ${UNITY_SRC} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
+
+#
+# Headers & Sources
+#
+set (STANDALONE_SOURCES
+ StandaloneUnity.cpp
+ )
+
+add_executable (unity-standalone StandaloneUnity.cpp)
+add_dependencies (unity-standalone
+ dash-lib
+ launcher-lib
+ panel-lib
+ unity-shared)
+target_link_libraries (unity-standalone
+ dash-lib
+ launcher-lib
+ panel-lib
+ unity-shared)
diff --git a/unity-standalone/StandaloneUnity.cpp b/unity-standalone/StandaloneUnity.cpp
new file mode 100644
index 000000000..413433f3b
--- /dev/null
+++ b/unity-standalone/StandaloneUnity.cpp
@@ -0,0 +1,148 @@
+/*
+ * 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: Gordon Allott <gord.allott@canonical.com>
+ * Neil Jagdish Patel <neil.patel@canonical.com>
+ *
+ */
+#include <gtk/gtk.h>
+
+#include "Nux/Nux.h"
+#include "Nux/VLayout.h"
+#include "Nux/WindowThread.h"
+#include "NuxGraphics/GraphicsEngine.h"
+#include <NuxCore/Logger.h>
+
+#include "unity-shared/BGHash.h"
+#include "unity-shared/FontSettings.h"
+#include "dash/DashView.h"
+#include "dash/DashController.h"
+#include "panel/PanelView.h"
+#include "panel/PanelController.h"
+#include "unity-shared/BackgroundEffectHelper.h"
+#include "launcher/FavoriteStoreGSettings.h"
+#include "launcher/LauncherController.h"
+#include "launcher/Launcher.h"
+#include "unity-shared/DashSettings.h"
+#include "unity-shared/DashStyle.h"
+#include "unity-shared/PanelStyle.h"
+#include "unity-shared/UBusWrapper.h"
+#include "unity-shared/UBusMessages.h"
+
+namespace
+{
+ static int display_width = 1280;
+ static int display_height = 720;
+ static gboolean no_window_decorations = FALSE;
+
+ static GOptionEntry entries[] =
+ {
+ {"width", 'w', 0, G_OPTION_ARG_INT, &display_width, "Display width", NULL},
+ {"height", 'h', 0, G_OPTION_ARG_INT, &display_height, "Display height", NULL},
+ {"no-window-decorations", 'd', 0, G_OPTION_ARG_NONE, &no_window_decorations, "Disables the window decorations", NULL},
+ {NULL}
+ };
+}
+
+using namespace unity;
+
+class UnityStandalone
+{
+public:
+ UnityStandalone ();
+ ~UnityStandalone ();
+
+ static void InitWindowThread (nux::NThread* thread, void* InitData);
+ void Init ();
+
+ launcher::Controller::Ptr launcher_controller;
+ dash::Controller::Ptr dash_controller;
+ panel::Controller::Ptr panel_controller;
+};
+
+UnityStandalone::UnityStandalone ()
+{
+}
+
+UnityStandalone::~UnityStandalone ()
+{
+}
+
+void UnityStandalone::Init ()
+{
+ launcher_controller.reset(new launcher::Controller(0));
+ dash_controller.reset(new dash::Controller());
+ panel_controller.reset(new panel::Controller());
+
+ dash_controller->launcher_width = launcher_controller->launcher().GetAbsoluteWidth() - 1;
+
+ UBusManager().SendMessage(UBUS_DASH_EXTERNAL_ACTIVATION, nullptr);
+}
+
+void UnityStandalone::InitWindowThread(nux::NThread* thread, void* InitData)
+{
+ UnityStandalone *self = static_cast<UnityStandalone*>(InitData);
+ self->Init();
+}
+
+int main(int argc, char **argv)
+{
+ nux::WindowThread* wt = NULL;
+ GError *error = NULL;
+ GOptionContext *context;
+
+ nux::NuxInitialize(0);
+ nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY"));
+
+ context = g_option_context_new("- Unity standalone");
+ g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
+ g_option_context_add_group(context, gtk_get_option_group(TRUE));
+ g_option_context_parse(context, &argc, &argv, &error);
+ if (error != NULL)
+ {
+ g_print("Option parsiong failed: %s\n", error->message);
+ g_error_free(error);
+ exit(1);
+ }
+
+ gtk_init(&argc, &argv);
+
+ BGHash bghash;
+ FontSettings font_settings;
+
+ // The instances for the pseudo-singletons.
+ dash::Style dash_style;
+ dash::Settings dash_settings;
+ dash_settings.SetFormFactor(dash::FormFactor::NETBOOK);
+ panel::Style panel_style;
+
+ GeisAdapter geis_adapter;
+ internal::FavoriteStoreGSettings favorite_store;
+ BackgroundEffectHelper::blur_type = BLUR_NONE;
+
+ UnityStandalone *standalone_runner = new UnityStandalone();
+ wt = nux::CreateNuxWindow("standalone-unity",
+ display_width, display_height,
+ (no_window_decorations) ? nux::WINDOWSTYLE_NOBORDER : nux::WINDOWSTYLE_NORMAL,
+ 0, /* no parent */
+ false,
+ &UnityStandalone::InitWindowThread,
+ standalone_runner);
+
+ wt->Run(NULL);
+ delete wt;
+ return 0;
+}