]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Allow 'type' config field to be a string list
authorMichael Terry <michael.terry@canonical.com>
Mon, 18 Nov 2013 15:27:40 +0000 (10:27 -0500)
committerMichael Terry <michael.terry@canonical.com>
Mon, 18 Nov 2013 15:27:40 +0000 (10:27 -0500)
src/configuration.c
src/configuration.h
src/lightdm.c

index e3b15df8ae95c285140a4dd61e82ae0d09df49d0..5268c8d904d0651ee60bf917dbdfccd5b2c4b6d5 100644 (file)
@@ -89,6 +89,18 @@ config_get_string (Configuration *config, const gchar *section, const gchar *key
     return g_key_file_get_string (config->priv->key_file, section, key, NULL);
 }
 
+void
+config_set_string_list (Configuration *config, const gchar *section, const gchar *key, const gchar **value, gsize length)
+{
+    g_key_file_set_string_list (config->priv->key_file, section, key, value, length);
+}
+
+gchar **
+config_get_string_list (Configuration *config, const gchar *section, const gchar *key)
+{
+    return g_key_file_get_string_list (config->priv->key_file, section, key, NULL, NULL);
+}
+
 void
 config_set_integer (Configuration *config, const gchar *section, const gchar *key, gint value)
 {
index 6c7b300dcc3f4874e75b7463b39524ff739b4767..cae56912d1eec9fa37813de0a996adca057634f1 100644 (file)
@@ -48,6 +48,10 @@ void config_set_string (Configuration *config, const gchar *section, const gchar
 
 gchar *config_get_string (Configuration *config, const gchar *section, const gchar *key);
 
+void config_set_string_list (Configuration *config, const gchar *section, const gchar *key, const gchar **value, gsize length);
+
+gchar **config_get_string_list (Configuration *config, const gchar *section, const gchar *key);
+
 void config_set_integer (Configuration *config, const gchar *section, const gchar *key, gint value);
 
 gint config_get_integer (Configuration *config, const gchar *section, const gchar *key);
index 3bf5ad77dd0db43b22c40ade8503720542d1ec3b..686a1f83256c5f5b0e5557adb0f486304fca0974 100644 (file)
@@ -1199,19 +1199,21 @@ main (int argc, char **argv)
     for (i = groups; *i; i++)
     {
         gchar *config_section = *i;
-        gchar *type;
-        Seat *seat;
+        gchar **types;
+        gchar **type;
+        Seat *seat = NULL;
         const gchar *const seatpfx = "Seat:";
 
         if (!g_str_has_prefix (config_section, seatpfx))
             continue;
 
         g_debug ("Loading seat %s", config_section);
-        type = config_get_string (config_get_instance (), config_section, "type");
-        if (!type)
-            type = config_get_string (config_get_instance (), "SeatDefaults", "type");
-        seat = seat_new (type);
-        g_free (type);
+        types = config_get_string_list (config_get_instance (), config_section, "type");
+        if (!types)
+            types = config_get_string_list (config_get_instance (), "SeatDefaults", "type");
+        for (type = types; !seat && *type; type++)
+            seat = seat_new (*type);
+        g_strfreev (types);
         if (seat)
         {
             const gsize seatpfxlen = strlen(seatpfx);
@@ -1232,14 +1234,16 @@ main (int argc, char **argv)
     /* If no seats start a default one */
     if (n_seats == 0 && config_get_boolean (config_get_instance (), "LightDM", "start-default-seat"))
     {
-        gchar *type;
-        Seat *seat;
+        gchar **types;
+        gchar **type;
+        Seat *seat = NULL;
 
         g_debug ("Adding default seat");
 
-        type = config_get_string (config_get_instance (), "SeatDefaults", "type");
-        seat = seat_new (type);
-        g_free (type);
+        types = config_get_string_list (config_get_instance (), "SeatDefaults", "type");
+        for (type = types; !seat && *type; type++)
+            seat = seat_new (*type);
+        g_strfreev (types);
         if (seat)
         {
             set_seat_properties (seat, NULL);
@@ -1250,7 +1254,7 @@ main (int argc, char **argv)
         }
         else
         {
-            g_warning ("Failed to create default seat %s", type);
+            g_warning ("Failed to create default seat");
             return EXIT_FAILURE;
         }
     }