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.
This commit is contained in:
Beniamino Galvani 2018-03-17 09:58:37 +01:00
parent 919f6b6d75
commit 8b4bb725d7
2 changed files with 6 additions and 2 deletions

View file

@ -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));

View file

@ -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,