From fd371119869a58fff5835e6d975e6209999ae599 Mon Sep 17 00:00:00 2001 From: Antonio Cardace Date: Wed, 15 Apr 2020 10:10:58 +0200 Subject: [PATCH] clients: allow properties to be hidden if they have the default value (cherry picked from commit b94fcb2a9408134a1e0c26cecb196de2c3f21873) --- clients/common/nm-meta-setting-desc.c | 30 +++++++++++++++++++-------- clients/common/nm-meta-setting-desc.h | 1 + 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index 03f9b313ce..efad09ec57 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -8156,6 +8156,8 @@ _meta_type_property_info_get_fcn (const NMMetaAbstractInfo *abstract_info, gpointer *out_to_free) { const NMMetaPropertyInfo *info = (const NMMetaPropertyInfo *) abstract_info; + gboolean is_default_local = FALSE; + gconstpointer r; nm_assert (!out_to_free || !*out_to_free); nm_assert (out_flags && !*out_flags); @@ -8173,15 +8175,25 @@ _meta_type_property_info_get_fcn (const NMMetaAbstractInfo *abstract_info, return _get_text_hidden (get_type); } - return info->property_type->get_fcn (info, - environment, - environment_user_data, - target, - get_type, - get_flags, - out_flags, - out_is_default, - out_to_free); + if ( info->hide_if_default + && !out_is_default) + out_is_default = &is_default_local; + + r = info->property_type->get_fcn (info, + environment, + environment_user_data, + target, + get_type, + get_flags, + out_flags, + out_is_default, + out_to_free); + + if ( info->hide_if_default + && *out_is_default) + *out_flags |= NM_META_ACCESSOR_GET_OUT_FLAGS_HIDE; + + return r; } diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h index c728a1502c..2ba48f5de2 100644 --- a/clients/common/nm-meta-setting-desc.h +++ b/clients/common/nm-meta-setting-desc.h @@ -376,6 +376,7 @@ struct _NMMetaPropertyInfo { bool is_secret:1; bool is_cli_option:1; + bool hide_if_default:1; const char *prompt;