]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blobdiff - src/session-config.c
Load all users only when really needed
[sojka/lightdm.git] / src / session-config.c
index d843605583f10bab2ab162ad362b739e3e371efb..c0476d15027f96cd8c316095670175b9f42287a3 100644 (file)
@@ -16,17 +16,20 @@ struct SessionConfigPrivate
     /* Session type */
     gchar *session_type;
 
-    /* Desktop name */
-    gchar *desktop_name;
+    /* Desktop names */
+    gchar **desktop_names;
 
     /* Command to run */
     gchar *command;
+
+    /* TRUE if can run a greeter inside the session */
+    gboolean allow_greeter;
 };
 
 G_DEFINE_TYPE (SessionConfig, session_config, G_TYPE_OBJECT);
 
 SessionConfig *
-session_config_new_from_file (const gchar *filename, GError **error)
+session_config_new_from_file (const gchar *filename, const gchar *default_session_type, GError **error)
 {
     GKeyFile *desktop_file;
     SessionConfig *config;
@@ -49,8 +52,22 @@ session_config_new_from_file (const gchar *filename, GError **error)
     config->priv->command = command;
     config->priv->session_type = g_key_file_get_string (desktop_file, G_KEY_FILE_DESKTOP_GROUP, "X-LightDM-Session-Type", NULL);
     if (!config->priv->session_type)
-        config->priv->session_type = g_strdup ("x");
-    config->priv->desktop_name = g_key_file_get_string (desktop_file, G_KEY_FILE_DESKTOP_GROUP, "X-LightDM-DesktopName", NULL);
+        config->priv->session_type = g_strdup (default_session_type);
+
+    config->priv->desktop_names = g_key_file_get_string_list (desktop_file, G_KEY_FILE_DESKTOP_GROUP, "DesktopNames", NULL, NULL);
+    if (!config->priv->desktop_names)
+    {
+        gchar *name;
+
+        name = g_key_file_get_string (desktop_file, G_KEY_FILE_DESKTOP_GROUP, "X-LightDM-DesktopName", NULL);
+        if (name)
+        {
+            config->priv->desktop_names = g_malloc (sizeof (gchar *) * 2);
+            config->priv->desktop_names[0] = name;
+            config->priv->desktop_names[1] = NULL;
+        }
+    }
+    config->priv->allow_greeter = g_key_file_get_boolean (desktop_file, G_KEY_FILE_DESKTOP_GROUP, "X-LightDM-Allow-Greeter", NULL);
 
     g_key_file_free (desktop_file);
 
@@ -71,11 +88,18 @@ session_config_get_session_type (SessionConfig *config)
     return config->priv->session_type;
 }
 
-const gchar *
-session_config_get_desktop_name (SessionConfig *config)
+gchar **
+session_config_get_desktop_names (SessionConfig *config)
 {
     g_return_val_if_fail (config != NULL, NULL);
-    return config->priv->desktop_name;
+    return config->priv->desktop_names;
+}
+
+gboolean
+session_config_get_allow_greeter (SessionConfig *config)
+{
+    g_return_val_if_fail (config != NULL, FALSE);
+    return config->priv->allow_greeter;
 }
 
 static void
@@ -90,7 +114,7 @@ session_config_finalize (GObject *object)
     SessionConfig *self = SESSION_CONFIG (object);
 
     g_free (self->priv->session_type);
-    g_free (self->priv->desktop_name);
+    g_strfreev (self->priv->desktop_names);
     g_free (self->priv->command);
 
     G_OBJECT_CLASS (session_config_parent_class)->finalize (object);