From 8b4bb725d773cde2d6bf8d7876c031f08a37a68d Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Sat, 17 Mar 2018 09:58:37 +0100 Subject: [PATCH] clients: meta: add enum getter-only nicks Add a new a new field to enum type descriptors that specify a list of nicks valid only for getter functions. It is useful when the get function must return a string different from the enum nick and that string can't be used to set a value. --- clients/common/nm-meta-setting-desc.c | 5 ++++- clients/common/nm-meta-setting-desc.h | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index 52d5f1e390..0cdc23cec4 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -827,6 +827,7 @@ _get_fcn_gobject_enum (ARGS_GET_FCN) GType gtype_prop; nm_auto_unref_gtypeclass GTypeClass *gtype_class = NULL; nm_auto_unref_gtypeclass GTypeClass *gtype_prop_class = NULL; + const struct _NMUtilsEnumValueInfo *value_infos = NULL; gboolean has_gtype = FALSE; nm_auto_unset_gvalue GValue gval = G_VALUE_INIT; gint64 v; @@ -931,7 +932,9 @@ _get_fcn_gobject_enum (ARGS_GET_FCN) /* the gobject_enum.value_infos are currently ignored for the getter. They * only declare additional aliases for the setter. */ - s = nm_utils_enum_to_str (gtype, (int) v); + if (property_info->property_typ_data) + value_infos = property_info->property_typ_data->subtype.gobject_enum.value_infos_get; + s = _nm_utils_enum_to_str_full (gtype, (int) v, ", ", value_infos); if (!format_numeric) RETURN_STR_TO_FREE (g_steal_pointer (&s)); diff --git a/clients/common/nm-meta-setting-desc.h b/clients/common/nm-meta-setting-desc.h index e61b1fc4a6..d314289b8e 100644 --- a/clients/common/nm-meta-setting-desc.h +++ b/clients/common/nm-meta-setting-desc.h @@ -241,7 +241,8 @@ struct _NMMetaPropertyTypData { GType (*get_gtype) (void); int min; int max; - const struct _NMUtilsEnumValueInfo *value_infos; + const struct _NMUtilsEnumValueInfo *value_infos_get; /* nicks for get function */ + const struct _NMUtilsEnumValueInfo *value_infos; /* nicks for set function */ void (*pre_set_notify) (const NMMetaPropertyInfo *property_info, const NMMetaEnvironment *environment, gpointer environment_user_data,