From 11337282626e4d84752735858db2b0bbab4fcab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 11 Mar 2014 00:15:43 +0100 Subject: UnityScreen: show the shortcut hint on first run (bzr r3702.5.2) --- plugins/unityshell/src/unityshell.cpp | 36 +++++++++++++++++++++++++++++++++++ plugins/unityshell/src/unityshell.h | 2 ++ 2 files changed, 38 insertions(+) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 37328a3c8..0eb7c386f 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -138,6 +138,7 @@ const unsigned int SCROLL_UP_BUTTON = 7; const int MAX_BUFFER_AGE = 11; const int FRAMES_TO_REDRAW_ON_RESUME = 10; const std::string RELAYOUT_TIMEOUT = "relayout-timeout"; +const std::string FIRST_RUN_STAMP = "first_run.stamp"; } // namespace local } // anon namespace @@ -3619,6 +3620,7 @@ void UnityScreen::initLauncher() auto shortcuts_modeller = std::make_shared(); shortcut_controller_ = std::make_shared(base_window_raiser, shortcuts_modeller); AddChild(shortcut_controller_.get()); + ShowFirstRunHints(); // Setup Session Controller auto manager = std::make_shared(); @@ -3693,6 +3695,40 @@ CompAction::Vector& UnityScreen::getActions() return menus_->KeyGrabber()->GetActions(); } +void UnityScreen::ShowFirstRunHints() +{ + sources_.AddTimeoutSeconds(1, [this] { + auto const& cache_dir = glib::gchar_to_string(g_get_user_cache_dir())+"/unity/"; + if (!g_file_test((cache_dir+local::FIRST_RUN_STAMP).c_str(), G_FILE_TEST_EXISTS)) + { + // We focus the panel, so the shortcut hint will be hidden at first user input + auto const& panels = panel_controller_->panels(); + if (!panels.empty()) + { + auto panel_win = static_cast(panels.front()->GetTopLevelViewWindow()); + SaveInputThenFocus(panel_win->GetInputWindowId()); + } + shortcut_controller_->Show(); + + if (g_mkdir_with_parents(cache_dir.c_str(), 0700) >= 0) + { + glib::Error error; + g_file_set_contents((cache_dir+local::FIRST_RUN_STAMP).c_str(), "", 0, &error); + + if (error) + { + LOG_ERROR(logger) << "Impossible to save the unity stamp file: " << error; + } + } + else + { + LOG_ERROR(logger) << "Impossible to create unity cache folder!"; + } + } + return false; + }); +} + /* Window init */ namespace diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 5a8e22b91..f45464ccc 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -302,6 +302,8 @@ private: void DamageBlurUpdateRegion(nux::Geometry const&); + void ShowFirstRunHints(); + std::unique_ptr tick_source_; std::unique_ptr animation_controller_; -- cgit v1.2.3 From 6b81ba5340f26a9de8675dc14a67a5cb1333d88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 11 Mar 2014 00:32:46 +0100 Subject: ShortcutController: make the view closable on first run (bzr r3702.5.3) --- plugins/unityshell/src/unityshell.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins') diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 0eb7c386f..88e4caa62 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -3708,6 +3708,7 @@ void UnityScreen::ShowFirstRunHints() auto panel_win = static_cast(panels.front()->GetTopLevelViewWindow()); SaveInputThenFocus(panel_win->GetInputWindowId()); } + shortcut_controller_->first_run = true; shortcut_controller_->Show(); if (g_mkdir_with_parents(cache_dir.c_str(), 0700) >= 0) -- cgit v1.2.3