summaryrefslogtreecommitdiffstats
path: root/uca-net-camera.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2017-10-10 17:03:52 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2017-10-10 17:03:52 +0200
commit74f1bde37dd4363e3fe3251b2a3567b3666d3a14 (patch)
treeab945a0717aa70ef92a8d353864d678646c34d93 /uca-net-camera.c
parent8317ec2fe9c892091c1c3d021277775e91435e95 (diff)
downloaduca-net-74f1bde37dd4363e3fe3251b2a3567b3666d3a14.tar.gz
uca-net-74f1bde37dd4363e3fe3251b2a3567b3666d3a14.tar.bz2
uca-net-74f1bde37dd4363e3fe3251b2a3567b3666d3a14.tar.xz
uca-net-74f1bde37dd4363e3fe3251b2a3567b3666d3a14.zip
Improve custom enum handling
Diffstat (limited to 'uca-net-camera.c')
-rw-r--r--uca-net-camera.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/uca-net-camera.c b/uca-net-camera.c
index b108c32..4d05863 100644
--- a/uca-net-camera.c
+++ b/uca-net-camera.c
@@ -479,6 +479,30 @@ deserialize_param_spec (UcaNetMessageProperty *prop)
return g_param_spec_string (prop->name, prop->nick, prop->blurb,
prop->spec.gstring.default_value,
prop->flags);
+ case G_TYPE_ENUM:
+ {
+ /* Register a new enum type */
+ GType type;
+ GEnumValue *values;
+
+ /* Allocate one more value to mark the end of the array */
+ values = g_new0 (GEnumValue, prop->spec.genum.n_values + 1);
+
+ for (guint i = 0; i < prop->spec.genum.n_values; i++) {
+ gchar *name;
+
+ name = g_strdup_printf ("%s_%i", prop->name, i);
+
+ values[i].value = prop->spec.genum.values[i];
+ values[i].value_name = name;
+ values[i].value_nick = name;
+ }
+
+ type = g_enum_register_static (prop->name, values);
+
+ return g_param_spec_enum (prop->name, prop->nick, prop->blurb, type,
+ prop->spec.genum.default_value, prop->flags);
+ }
CASE_NUMERIC (G_TYPE_INT, int)
CASE_NUMERIC (G_TYPE_UINT, uint)
CASE_NUMERIC (G_TYPE_FLOAT, float)