diff options
| author | Gord Allott <gord.allott@canonical.com> | 2012-02-06 06:28:40 -0500 |
|---|---|---|
| committer | Tarmac <> | 2012-02-06 06:28:40 -0500 |
| commit | 7426e5507aae1180e3407e96a8765674f475f568 (patch) | |
| tree | 195327e2bf6809ee5c3a2d8a56165693b4585d96 /standalone-clients | |
| parent | b0e17071f7f78a7eea9ad376ada49a3585b77e01 (diff) | |
| parent | 8044dc868fe34b8f2aa8a7aba12f5939293798cc (diff) | |
. Fixes: https://bugs.launchpad.net/bugs/921112, https://bugs.launchpad.net/bugs/921249, https://bugs.launchpad.net/bugs/921270, https://bugs.launchpad.net/bugs/921329. Approved by Gord Allott, John Lea.
(bzr r1900)
Diffstat (limited to 'standalone-clients')
| -rw-r--r-- | standalone-clients/CMakeLists.txt | 45 | ||||
| -rw-r--r-- | standalone-clients/StandaloneHud.cpp | 171 |
2 files changed, 212 insertions, 4 deletions
diff --git a/standalone-clients/CMakeLists.txt b/standalone-clients/CMakeLists.txt index 8a763eec9..1e2092e55 100644 --- a/standalone-clients/CMakeLists.txt +++ b/standalone-clients/CMakeLists.txt @@ -47,10 +47,10 @@ add_executable (dash ${UNITY_SRC}/BackgroundEffectHelper.h ${UNITY_SRC}/BGHash.cpp ${UNITY_SRC}/BGHash.h - ${UNITY_SRC}/DashSearchBar.cpp - ${UNITY_SRC}/DashSearchBar.h - ${UNITY_SRC}/DashSearchBarSpinner.cpp - ${UNITY_SRC}/DashSearchBarSpinner.h + ${UNITY_SRC}/SearchBar.cpp + ${UNITY_SRC}/SearchBar.h + ${UNITY_SRC}/SearchBarSpinner.cpp + ${UNITY_SRC}/SearchBarSpinner.h ${UNITY_SRC}/DashView.cpp ${UNITY_SRC}/DashView.h ${UNITY_SRC}/DashViewPrivate.cpp @@ -84,6 +84,10 @@ add_executable (dash ${UNITY_SRC}/PlacesSimpleTile.h ${UNITY_SRC}/PlacesVScrollBar.cpp ${UNITY_SRC}/PlacesVScrollBar.h + ${UNITY_SRC}/DashView.cpp + ${UNITY_SRC}/DashView.h + ${UNITY_SRC}/DashViewPrivate.cpp + ${UNITY_SRC}/DashViewPrivate.h ${UNITY_SRC}/DashStyle.cpp ${UNITY_SRC}/IconLoader.cpp ${UNITY_SRC}/IconLoader.h @@ -456,6 +460,39 @@ add_executable (bg-hash ) add_dependencies (bg-hash unity-core-${UNITY_API_VERSION}) +add_executable (hud + StandaloneHud.cpp + ${UNITY_SRC}/BackgroundEffectHelper.cpp + ${UNITY_SRC}/BackgroundEffectHelper.h + ${UNITY_SRC}/DashSettings.cpp + ${UNITY_SRC}/DashSettings.h + ${UNITY_SRC}/DashStyle.cpp + ${UNITY_SRC}/HudButton.cpp + ${UNITY_SRC}/HudIcon.cpp + ${UNITY_SRC}/HudIcon.h + ${UNITY_SRC}/HudIconTextureSource.cpp + ${UNITY_SRC}/HudIconTextureSource.h + ${UNITY_SRC}/HudView.cpp + ${UNITY_SRC}/IMTextEntry.cpp + ${UNITY_SRC}/Introspectable.cpp + ${UNITY_SRC}/IconTexture.cpp + ${UNITY_SRC}/IconLoader.cpp + ${UNITY_SRC}/IconRenderer.cpp + ${UNITY_SRC}/IconTextureSource.cpp + ${UNITY_SRC}/JSONParser.cpp + ${UNITY_SRC}/OverlayRenderer.cpp + ${UNITY_SRC}/SearchBar.cpp + ${UNITY_SRC}/SearchBarSpinner.cpp + ${UNITY_SRC}/StaticCairoText.cpp + ${UNITY_SRC}/TextureCache.cpp + ${UNITY_SRC}/Timer.cpp + ${UNITY_SRC}/UBusWrapper.cpp + ${UNITY_SRC}/ubus-server.cpp + ${UNITY_SRC}/UScreen.cpp + ${UNITY_SRC}/UScreen.h + ) +add_dependencies (hud unity-core-${UNITY_API_VERSION}) + add_executable (test-shortcut TestShortcut.cpp ${UNITY_SRC}/AbstractSeparator.cpp diff --git a/standalone-clients/StandaloneHud.cpp b/standalone-clients/StandaloneHud.cpp new file mode 100644 index 000000000..03d1aab85 --- /dev/null +++ b/standalone-clients/StandaloneHud.cpp @@ -0,0 +1,171 @@ +/* + * 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> + * + */ + +#include <sstream> +#include "Nux/Nux.h" +#include "Nux/VLayout.h" +#include "Nux/Button.h" +#include "Nux/TextureArea.h" +#include "Nux/WindowThread.h" +#include "NuxGraphics/GraphicsEngine.h" +#include <gtk/gtk.h> + +#include "HudView.h" +#include "DashStyle.h" +#include "DashSettings.h" +#include <NuxCore/Logger.h> + +namespace +{ + nux::logging::Logger logger("unity.tests.Hud"); +} + +class TestRunner +{ +public: + TestRunner (); + ~TestRunner (); + + static void InitWindowThread (nux::NThread* thread, void* InitData); + void Init (); + nux::Layout *layout; + unity::hud::View* hud_view_; + unity::dash::Settings dash_settings_; + +private: + unity::hud::Hud hud_service_; +}; + +TestRunner::TestRunner () + : hud_service_("com.canonical.hud", "/com/canonical/hud") +{ +} + +TestRunner::~TestRunner () +{ +} + +void TestRunner::Init () +{ + LOG_WARNING(logger) << "test init"; + layout = new nux::VLayout(); + + hud_view_ = new unity::hud::View(); + + layout->AddView (hud_view_, 1, nux::MINOR_POSITION_TOP, nux::MINOR_SIZE_FULL); + nux::GetWindowCompositor().SetKeyFocusArea(hud_view_->default_focus()); + + nux::GetWindowThread()->SetLayout (layout); + + // things the controller normally does + hud_service_.queries_updated.connect([&] (unity::hud::Hud::Queries queries) { + hud_view_->SetQueries(queries); + std::string icon_name = ""; + for (auto query = queries.begin(); query != queries.end(); query++) + { + if (!(*query)->icon_name.empty()) + { + LOG_DEBUG(logger) << "Setting icon name to: " << (*query)->icon_name; + icon_name = (*query)->icon_name; + break; + } + } + + hud_view_->SetIcon(icon_name); + + }); + + hud_view_->query_activated.connect([&] (unity::hud::Query::Ptr query) { + hud_service_.ExecuteQuery(query, 0); + }); + + hud_view_->query_selected.connect([&] (unity::hud::Query::Ptr query) { + hud_view_->SetIcon(query->icon_name); + }); + + hud_view_->search_changed.connect([&] (std::string search_string) { + hud_service_.RequestQuery(search_string); + }); + + hud_view_->search_activated.connect([&] (std::string search_string) { + hud_service_.ExecuteQueryBySearch(search_string, 0); + }); + + hud_service_.RequestQuery(""); + + hud_view_->SetWindowGeometry(layout->GetAbsoluteGeometry(), layout->GetGeometry()); + +} + +void TestRunner::InitWindowThread(nux::NThread* thread, void* InitData) +{ + TestRunner *self = (TestRunner *) InitData; + self->Init (); +} + +void +ControlThread (nux::NThread* thread, + void* data) +{ + // sleep for 3 seconds + nux::SleepForMilliseconds (3000); + printf ("ControlThread successfully started\n"); +} + + +int main(int argc, char **argv) +{ + nux::SystemThread* st = NULL; + nux::WindowThread* wt = NULL; + + // no real tests right now, just make sure we don't get any criticals and such + // waiting on nice perceptual diff support before we can build real tests + // for views + + g_type_init (); + gtk_init (&argc, &argv); + + nux::NuxInitialize(0); + + // Slightly higher as we're more likely to test things we know will fail + nux::logging::configure_logging("unity.hud=debug"); + + nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); + LOG_DEBUG(logger) << "starting the standalone hud"; + // The instances for the pseudo-singletons. + unity::dash::Style dash_style; + + TestRunner *test_runner = new TestRunner (); + wt = nux::CreateGUIThread(TEXT("Hud Prototype Test"), + 1200, 768, + 0, + &TestRunner::InitWindowThread, + test_runner); + + st = nux::CreateSystemThread (NULL, ControlThread, wt); + + if (st) + st->Start (NULL); + + wt->Run (NULL); + delete st; + delete wt; + return 0; +} |
