summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-03-17 09:58:37 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2018-04-13 17:02:55 +0200
commit8b4bb725d773cde2d6bf8d7876c031f08a37a68d (patch)
tree81e9e3692a6eccae2b91f12602fd0fbb5847ec55
parent919f6b6d75eb395cacbd3e8501ddc8374a8343ad (diff)
downloadNetworkManager-8b4bb725d773cde2d6bf8d7876c031f08a37a68d.tar.gz
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.
-rw-r--r--clients/common/nm-meta-setting-desc.c5
-rw-r--r--clients/common/nm-meta-setting-desc.h3
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,