diff --git a/lib/wp/settings.c b/lib/wp/settings.c index fcdf1665..0f7bf561 100644 --- a/lib/wp/settings.c +++ b/lib/wp/settings.c @@ -90,13 +90,15 @@ wp_settings_spec_new (WpSpaJson * spec_json) /* Parse mandatory fields */ if (!wp_spa_json_object_get (spec_json, - "name", "s", &name, "description", "s", &desc, "type", "s", &type_str, "default", "J", &def_value, NULL)) return NULL; + /* Parse optional fields */ + wp_spa_json_object_get (spec_json, "name", "s", &name, NULL); + /* Parse type and check if values are correct */ if (g_str_equal (type_str, "bool")) { type = WP_SETTINGS_SPEC_TYPE_BOOL; @@ -153,7 +155,8 @@ wp_settings_spec_new (WpSpaJson * spec_json) * \brief Gets the human-readable name of a settings spec * \ingroup wpsettings * \param self the settings spec object - * \returns the human-readable name of the settings spec + * \returns (nullable): the human-readable name of the settings spec, + * or NULL if none */ const gchar * wp_settings_spec_get_name (WpSettingsSpec * self) diff --git a/src/tools/wpctl.c b/src/tools/wpctl.c index c4a4199e..1c59d2ab 100644 --- a/src/tools/wpctl.c +++ b/src/tools/wpctl.c @@ -1453,7 +1453,8 @@ print_setting (WpSettings *s, const gchar *key) printf ("- Id: %s\n", key); /* print spec */ - printf (" Name: %s\n", dgettext (GETTEXT_PACKAGE, name)); + if (name) + printf (" Name: %s\n", dgettext (GETTEXT_PACKAGE, name)); printf (" Desc: %s\n", dgettext (GETTEXT_PACKAGE, desc)); printf (" Type: %s\n", settings_spec_type_to_string (val_type)); printf (" Default: %s", wp_spa_json_get_data (def)); diff --git a/tests/scripts/config/wireplumber.conf b/tests/scripts/config/wireplumber.conf index dcb2d521..06a50b50 100644 --- a/tests/scripts/config/wireplumber.conf +++ b/tests/scripts/config/wireplumber.conf @@ -11,13 +11,11 @@ context.modules = [ wireplumber.settings.schema = { ## Bluetooth bluetooth.use-persistent-storage = { - name = "Persistent storage" description = "Whether to use persistent BT storage or not" type = "bool" default = true } bluetooth.autoswitch-to-headset-profile = { - name = "Auto-switch to headset profile" description = "Whether to autoswitch to BT headset profile or not" type = "bool" default = true @@ -25,19 +23,16 @@ wireplumber.settings.schema = { ## Device device.restore-profile = { - name = "Restore profile" description = "Whether to restore device profile or not" type = "bool" default = true } device.restore-routes = { - name = "Restore routes" description = "Whether to restore device routes or not" type = "bool" default = true } device.routes.default-sink-volume = { - name = "Default sink volume" description = "The default volume for sink devices" type = "float" default = 0.064 @@ -45,7 +40,6 @@ wireplumber.settings.schema = { max = 1.0 } device.routes.default-source-volume = { - name = "Default source volume" description = "The default volume for source devices" type = "float" default = 1.0 @@ -55,13 +49,11 @@ wireplumber.settings.schema = { ## Linking linking.allow-moving-streams = { - name = "Allow moving streams" description = "Whether to allow metadata to move streams at runtime or not" type = "bool" default = true } linking.follow-default-target = { - name = "Follow default target" description = "Whether to allow streams follow the default device or not" type = "bool" default = true @@ -69,7 +61,6 @@ wireplumber.settings.schema = { ## Monitor monitor.camera-discovery-timeout = { - name = "Discovery timeout" description = "The camera discovery timeout in milliseconds" type = "int" default = 1000 @@ -79,37 +70,31 @@ wireplumber.settings.schema = { ## Node node.features.audio.no-dsp = { - name = "No DSP" description = "Whether to never convert audio to F32 format or not" type = "bool" default = false } node.features.audio.monitor-ports = { - name = "Monitor ports" description = "Whether to enable monitor ports on audio nodes or not" type = "bool" default = true } node.features.audio.control-port = { - name = "Control ports" description = "Whether to enable control ports on audio nodes or not" type = "bool" default = false } node.stream.restore-props = { - name = "Restore properties" description = "Whether to restore properties on stream nodes or not" type = "bool" default = true } node.stream.restore-target = { - name = "Restore target" description = "Whether to restore target on stream nodes or not" type = "bool" default = true } node.stream.default-playback-volume = { - name = "Default playback volume" description = "The default volume for playback nodes" type = "float" default = 1.0 @@ -117,7 +102,6 @@ wireplumber.settings.schema = { max = 1.0 } node.stream.default-capture-volume = { - name = "Default capture volume" description = "The default volume for capture nodes" type = "float" default = 1.0 @@ -125,13 +109,11 @@ wireplumber.settings.schema = { max = 1.0 } node.filter.forward-format = { - name = "Forward format" description = "Whether to forward format on filter nodes or not" type = "bool" default = false } node.restore-default-targets = { - name = "Restore default target" description = "Whether to restore default targets or not" type = "bool" default = true diff --git a/tests/wp/settings.c b/tests/wp/settings.c index 51ece7d9..cfa20a73 100644 --- a/tests/wp/settings.c +++ b/tests/wp/settings.c @@ -877,6 +877,13 @@ test_get_set_save_reset_delete (TestSettingsFixture *self, gconstpointer data) g_assert_cmpstr (wp_spa_json_get_data (j), ==, "{}"); g_clear_pointer (&j, wp_spa_json_unref); } + + /* Name omitted */ + { + spec = wp_settings_get_spec (s, "test-setting-no-name"); + name = wp_settings_spec_get_name (spec); + g_assert_null (name); + } } static void diff --git a/tests/wp/settings/wireplumber.conf b/tests/wp/settings/wireplumber.conf index f1f411a8..fed9a99a 100644 --- a/tests/wp/settings/wireplumber.conf +++ b/tests/wp/settings/wireplumber.conf @@ -56,6 +56,12 @@ wireplumber.settings.schema = { type = "object" default = {} } + test-setting-no-name = { + # optional name field omitted + description = "test-setting-no-name description" + type = "bool" + default = false + } } wireplumber.settings = {