[gnome-session/wip/benzea/systemd-user-switch: 4/13] manager: Allow fetching the configured session without manager



commit 110237b95d8f5c9ed6d5cef2ca15272236fd179b
Author: Benjamin Berg <bberg redhat com>
Date:   Sat Apr 20 01:14:31 2019 +0200

    manager: Allow fetching the configured session without manager
    
    When starting on systemd we need to know the session to start for the
    target name. However, we don't need anything else from the manager, so
    allow calling the function with NULL.

 gnome-session/gsm-manager.c | 10 ++++++++--
 gnome-session/gsm-manager.h |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index 291ff865..c9eba1f6 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -1455,10 +1455,16 @@ gsm_manager_start (GsmManager *manager)
         start_phase (manager);
 }
 
-const char *
+char *
 _gsm_manager_get_default_session (GsmManager     *manager)
 {
-        return g_settings_get_string (manager->priv->session_settings,
+        g_autoptr(GSettings) session_settings = NULL;
+
+        if (manager)
+                session_settings = g_object_ref (manager->priv->session_settings);
+        else
+                session_settings  = g_settings_new (SESSION_SCHEMA);
+        return g_settings_get_string (session_settings,
                                       KEY_SESSION_NAME);
 }
 
diff --git a/gnome-session/gsm-manager.h b/gnome-session/gsm-manager.h
index 9ac09e77..3ce4350f 100644
--- a/gnome-session/gsm-manager.h
+++ b/gnome-session/gsm-manager.h
@@ -116,7 +116,7 @@ gboolean            gsm_manager_add_legacy_session_apps        (GsmManager     *
 
 void                gsm_manager_start                          (GsmManager     *manager);
 
-const char *        _gsm_manager_get_default_session           (GsmManager     *manager);
+char *              _gsm_manager_get_default_session           (GsmManager     *manager);
 
 void                _gsm_manager_set_active_session            (GsmManager     *manager,
                                                                 const char     *session_name,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]