[gnome-session/wip/benzea/systemd-user-switch: 11/21] manager: Add systemd-managed property



commit 297adffd6959c17971061400654e52a29d074c46
Author: Benjamin Berg <bberg redhat com>
Date:   Sat Apr 20 01:12:31 2019 +0200

    manager: Add systemd-managed property
    
    When running on systemd a few things need to change in the manager. Add
    a property for this but leave it unused for now.

 gnome-session/gsm-manager.c | 29 ++++++++++++++++++++++++++---
 gnome-session/gsm-manager.h |  4 +++-
 gnome-session/main.c        |  2 +-
 3 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index b7665bc2..bdc4594b 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -125,6 +125,7 @@ typedef enum
 struct GsmManagerPrivate
 {
         gboolean                failsafe;
+        gboolean                systemd_managed;
         GsmStore               *clients;
         GsmStore               *inhibitors;
         GsmInhibitorFlag        inhibited_actions;
@@ -180,7 +181,8 @@ enum {
         PROP_CLIENT_STORE,
         PROP_SESSION_NAME,
         PROP_FALLBACK,
-        PROP_FAILSAFE
+        PROP_FAILSAFE,
+        PROP_SYSTEMD_MANAGED
 };
 
 enum {
@@ -1762,6 +1764,14 @@ gsm_manager_get_failsafe (GsmManager *manager)
         return manager->priv->failsafe;
 }
 
+gboolean
+gsm_manager_get_systemd_managed (GsmManager *manager)
+{
+        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);
+
+        return manager->priv->systemd_managed;
+}
+
 static void
 on_client_disconnected (GsmClient  *client,
                         GsmManager *manager)
@@ -2124,6 +2134,9 @@ gsm_manager_set_property (GObject       *object,
          case PROP_CLIENT_STORE:
                 gsm_manager_set_client_store (self, g_value_get_object (value));
                 break;
+        case PROP_SYSTEMD_MANAGED:
+                self->priv->systemd_managed = g_value_get_boolean (value);
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                 break;
@@ -2380,6 +2393,14 @@ gsm_manager_class_init (GsmManagerClass *klass)
                                                               GSM_TYPE_STORE,
                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 
+        g_object_class_install_property (object_class,
+                                         PROP_SYSTEMD_MANAGED,
+                                         g_param_spec_boolean ("systemd-managed",
+                                                               NULL,
+                                                               NULL,
+                                                               FALSE,
+                                                               G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
         g_type_class_add_private (klass, sizeof (GsmManagerPrivate));
 }
 
@@ -3292,7 +3313,8 @@ gsm_manager_get (void)
 
 GsmManager *
 gsm_manager_new (GsmStore *client_store,
-                 gboolean  failsafe)
+                 gboolean  failsafe,
+                 gboolean  systemd_managed)
 {
         if (manager_object != NULL) {
                 g_object_ref (manager_object);
@@ -3302,6 +3324,7 @@ gsm_manager_new (GsmStore *client_store,
                 manager_object = g_object_new (GSM_TYPE_MANAGER,
                                                "client-store", client_store,
                                                "failsafe", failsafe,
+                                               "systemd-managed", systemd_managed,
                                                NULL);
 
                 g_object_add_weak_pointer (manager_object,
@@ -3561,7 +3584,7 @@ add_autostart_app_internal (GsmManager *manager,
                 }
         }
 
-        app = gsm_autostart_app_new (path, FALSE, &error);
+        app = gsm_autostart_app_new (path, manager->priv->systemd_managed, &error);
         if (app == NULL) {
                 g_warning ("%s", error->message);
                 g_clear_error (&error);
diff --git a/gnome-session/gsm-manager.h b/gnome-session/gsm-manager.h
index bc440cb0..9ac09e77 100644
--- a/gnome-session/gsm-manager.h
+++ b/gnome-session/gsm-manager.h
@@ -96,10 +96,12 @@ GQuark              gsm_manager_error_quark                    (void);
 GType               gsm_manager_get_type                       (void);
 
 GsmManager *        gsm_manager_new                            (GsmStore       *client_store,
-                                                                gboolean        failsafe);
+                                                                gboolean        failsafe,
+                                                                gboolean        systemd_managed);
 GsmManager *        gsm_manager_get                            (void);
 
 gboolean            gsm_manager_get_failsafe                   (GsmManager     *manager);
+gboolean            gsm_manager_get_systemd_managed            (GsmManager     *manager);
 
 gboolean            gsm_manager_add_autostart_app              (GsmManager     *manager,
                                                                 const char     *path,
diff --git a/gnome-session/main.c b/gnome-session/main.c
index da1ae7d9..e934ac1f 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -137,7 +137,7 @@ create_manager (void)
         GsmStore *client_store;
 
         client_store = gsm_store_new ();
-        manager = gsm_manager_new (client_store, failsafe);
+        manager = gsm_manager_new (client_store, failsafe, FALSE);
         g_object_unref (client_store);
 
         g_unix_signal_add (SIGTERM, term_or_int_signal_cb, manager);


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