diff options
| -rw-r--r-- | UnityCore/GnomeSessionManager.cpp | 22 | ||||
| -rw-r--r-- | UnityCore/GnomeSessionManagerImpl.h | 3 | ||||
| -rw-r--r-- | UnityCore/SessionManager.h | 4 | ||||
| -rw-r--r-- | shutdown/SessionView.cpp | 33 |
4 files changed, 53 insertions, 9 deletions
diff --git a/UnityCore/GnomeSessionManager.cpp b/UnityCore/GnomeSessionManager.cpp index 466a61125..6ed64cac4 100644 --- a/UnityCore/GnomeSessionManager.cpp +++ b/UnityCore/GnomeSessionManager.cpp @@ -126,6 +126,19 @@ GnomeManager::Impl::Impl(GnomeManager* manager, bool test_mode) }); } + { + dm_proxy_ = std::make_shared<glib::DBusProxy>("org.freedesktop.DisplayManager", + "/org/freedesktop/DisplayManager", + "org.freedesktop.DisplayManager", + G_BUS_TYPE_SYSTEM); + + dm_proxy_->Connect("SessionAdded", sigc::hide(sigc::mem_fun(this, &Impl::UpdateHaveOtherOpenSessions))); + dm_proxy_->Connect("SessionRemoved", sigc::hide(sigc::mem_fun(this, &Impl::UpdateHaveOtherOpenSessions))); + + manager_->have_other_open_sessions = false; + UpdateHaveOtherOpenSessions(); + } + CallLogindMethod("CanHibernate", nullptr, [this] (GVariant* variant, glib::Error const& err) { if (err) { @@ -422,6 +435,15 @@ void GnomeManager::Impl::LockScreen(bool prompt) prompt ? manager_->prompt_lock_requested.emit() : manager_->lock_requested.emit(); } +void GnomeManager::Impl::UpdateHaveOtherOpenSessions() +{ + dm_proxy_->GetProperty("Sessions", [this](GVariant* variant) { + GVariantIter *sessions; + g_variant_get(variant, "ao", &sessions); + manager_->have_other_open_sessions = g_variant_iter_n_children(sessions) > 1; + }); +} + // Public implementation GnomeManager::GnomeManager() diff --git a/UnityCore/GnomeSessionManagerImpl.h b/UnityCore/GnomeSessionManagerImpl.h index 1045b78db..ce8ace253 100644 --- a/UnityCore/GnomeSessionManagerImpl.h +++ b/UnityCore/GnomeSessionManagerImpl.h @@ -54,6 +54,7 @@ struct GnomeManager::Impl void EnsureCancelPendingAction(); void LockScreen(bool prompt); + GVariant* OnShellMethodCall(std::string const& method, GVariant* parameters); void CallGnomeSessionMethod(std::string const& method, GVariant* parameters = nullptr, glib::DBusProxy::CallFinishedCallback const& cb = nullptr); @@ -61,6 +62,7 @@ struct GnomeManager::Impl void CallLogindMethod(std::string const& method, GVariant* parameters = nullptr, glib::DBusProxy::CallFinishedCallback const& cb = nullptr); void CallConsoleKitMethod(std::string const& method, GVariant* parameters = nullptr); bool InteractiveMode(); + void UpdateHaveOtherOpenSessions(); GnomeManager* manager_; bool test_mode_; @@ -73,6 +75,7 @@ struct GnomeManager::Impl glib::DBusObject::Ptr shell_object_; glib::DBusProxy::Ptr login_proxy_; glib::DBusProxy::Ptr presence_proxy_; + glib::DBusProxy::Ptr dm_proxy_; }; } // namespace session diff --git a/UnityCore/SessionManager.h b/UnityCore/SessionManager.h index fb45e5253..018175ee0 100644 --- a/UnityCore/SessionManager.h +++ b/UnityCore/SessionManager.h @@ -23,6 +23,8 @@ #include <sigc++/sigc++.h> #include <memory> +#include <NuxCore/Property.h> + namespace unity { namespace session @@ -36,6 +38,8 @@ public: Manager() = default; virtual ~Manager() = default; + nux::Property<bool> have_other_open_sessions; + virtual std::string RealName() const = 0; virtual std::string UserName() const = 0; virtual std::string HostName() const = 0; diff --git a/shutdown/SessionView.cpp b/shutdown/SessionView.cpp index d824f445e..93c984cea 100644 --- a/shutdown/SessionView.cpp +++ b/shutdown/SessionView.cpp @@ -79,6 +79,7 @@ View::View(Manager::Ptr const& manager) GetBoundingArea()->mouse_click.connect([this] (int, int, unsigned long, unsigned long) { request_close.emit(); }); have_inhibitors.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateText))); + manager_->have_other_open_sessions.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateText))); mode.SetSetterFunction([this] (Mode& target, Mode new_mode) { if (new_mode == Mode::SHUTDOWN && !manager_->CanShutdown()) @@ -104,24 +105,33 @@ View::View(Manager::Ptr const& manager) void View::UpdateText() { - const char* message = nullptr; + std::string message; + std::string other_users_msg; auto const& real_name = manager_->RealName(); auto const& name = (real_name.empty() ? manager_->UserName() : real_name); + other_users_msg = _("Other users are currently logged in to this computer," + "shutting down now will also close these other sessions.\n"); + if (mode() == Mode::SHUTDOWN) { title_->SetText(_("Shut Down")); title_->SetVisible(true); + if (manager_->have_other_open_sessions()) + { + message += other_users_msg; + } + if (have_inhibitors()) { - message = _("Hi %s, you have open files that you might want to save " \ - "before shutting down. Are you sure you want to continue?"); + message += _("Hi %s, you have open files that you might want to save " \ + "before shutting down. Are you sure you want to continue?"); } else { - message = _("Goodbye, %s. Are you sure you want to close all programs " \ - "and shut down the computer?"); + message += _("Goodbye, %s. Are you sure you want to close all programs " \ + "and shut down the computer?"); } } else if (mode() == Mode::LOGOUT) @@ -144,27 +154,32 @@ void View::UpdateText() { title_->SetVisible(false); + if (manager_->have_other_open_sessions()) + { + message += other_users_msg; + } + if (have_inhibitors()) { if (buttons_layout_->GetChildren().size() > 3) { // We have enough buttons to show the message without a new line. - message = _("Hi %s, you have open files you might want to save. " \ + message += _("Hi %s, you have open files you might want to save. " \ "Would you like to…"); } else { - message = _("Hi %s, you have open files you might want to save.\n" \ + message += _("Hi %s, you have open files you might want to save.\n" \ "Would you like to…"); } } else { - message = _("Goodbye, %s. Would you like to…"); + message += _("Goodbye, %s. Would you like to…"); } } - subtitle_->SetText(glib::String(g_strdup_printf(message, name.c_str())).Str()); + subtitle_->SetText(glib::String(g_strdup_printf(message.c_str(), name.c_str())).Str()); } void View::Populate() |
