From: Michael Terry Date: Mon, 18 Nov 2013 15:27:40 +0000 (-0500) Subject: Allow 'type' config field to be a string list X-Git-Url: http://rtime.felk.cvut.cz/gitweb/sojka/lightdm.git/commitdiff_plain/543fea00630edaf327f62e8688c582c174b31ecb Allow 'type' config field to be a string list --- diff --git a/src/configuration.c b/src/configuration.c index e3b15df8..5268c8d9 100644 --- a/src/configuration.c +++ b/src/configuration.c @@ -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) { diff --git a/src/configuration.h b/src/configuration.h index 6c7b300d..cae56912 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -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); diff --git a/src/lightdm.c b/src/lightdm.c index 3bf5ad77..686a1f83 100644 --- a/src/lightdm.c +++ b/src/lightdm.c @@ -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; } }