diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-09 14:35:06 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-09 14:35:06 +0200 |
commit | 805129cf7452e37c6d1042a87fadd297098fac9c (patch) | |
tree | 86208942d470786da52454b70d5f544793613c6f /plugins | |
parent | 21bce1b4a01ff6735325457297aa9bd8fcdebe8f (diff) | |
download | libuca-805129cf7452e37c6d1042a87fadd297098fac9c.tar.gz libuca-805129cf7452e37c6d1042a87fadd297098fac9c.tar.bz2 libuca-805129cf7452e37c6d1042a87fadd297098fac9c.tar.xz libuca-805129cf7452e37c6d1042a87fadd297098fac9c.zip |
Fix #149: Make timestamp mode an enum
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/pco/uca-pco-camera.c | 40 | ||||
-rw-r--r-- | plugins/pco/uca-pco-camera.h | 7 |
2 files changed, 21 insertions, 26 deletions
diff --git a/plugins/pco/uca-pco-camera.c b/plugins/pco/uca-pco-camera.c index 352c5f0..ccccf82 100644 --- a/plugins/pco/uca-pco-camera.c +++ b/plugins/pco/uca-pco-camera.c @@ -77,6 +77,7 @@ G_DEFINE_TYPE(UcaPcoCamera, uca_pco_camera, UCA_TYPE_CAMERA) * @UCA_PCO_CAMERA_TIMESTAMP_BINARY: Embed a BCD-coded timestamp in the first * bytes * @UCA_PCO_CAMERA_TIMESTAMP_ASCII: Embed a visible ASCII timestamp in the image + * @UCA_PCO_CAMERA_TIMESTAMP_BOTH: Embed both types of timestamps */ /** @@ -769,13 +770,14 @@ static void uca_pco_camera_set_property(GObject *object, guint property_id, cons case PROP_TIMESTAMP_MODE: { - guint16 modes[] = { - TIMESTAMP_MODE_OFF, /* 0 */ - TIMESTAMP_MODE_BINARY, /* 1 = 1 << 0 */ - TIMESTAMP_MODE_ASCII, /* 2 = 1 << 1 */ - TIMESTAMP_MODE_BINARYANDASCII, /* 3 = 1 << 0 | 1 << 1 */ + guint16 table[] = { + TIMESTAMP_MODE_OFF, + TIMESTAMP_MODE_BINARY, + TIMESTAMP_MODE_BINARYANDASCII, + TIMESTAMP_MODE_ASCII, }; - pco_set_timestamp_mode(priv->pco, modes[g_value_get_flags(value)]); + + pco_set_timestamp_mode(priv->pco, table[g_value_get_flags(value)]); } break; @@ -1055,23 +1057,15 @@ static void uca_pco_camera_get_property(GObject *object, guint property_id, GVal case PROP_TIMESTAMP_MODE: { guint16 mode; - pco_get_timestamp_mode(priv->pco, &mode); + UcaPcoCameraTimestamp table[] = { + UCA_PCO_CAMERA_TIMESTAMP_NONE, + UCA_PCO_CAMERA_TIMESTAMP_BINARY, + UCA_PCO_CAMERA_TIMESTAMP_BOTH, + UCA_PCO_CAMERA_TIMESTAMP_ASCII + }; - switch (mode) { - case TIMESTAMP_MODE_OFF: - g_value_set_flags(value, UCA_PCO_CAMERA_TIMESTAMP_NONE); - break; - case TIMESTAMP_MODE_BINARY: - g_value_set_flags(value, UCA_PCO_CAMERA_TIMESTAMP_BINARY); - break; - case TIMESTAMP_MODE_BINARYANDASCII: - g_value_set_flags(value, - UCA_PCO_CAMERA_TIMESTAMP_BINARY | UCA_PCO_CAMERA_TIMESTAMP_ASCII); - break; - case TIMESTAMP_MODE_ASCII: - g_value_set_flags(value, UCA_PCO_CAMERA_TIMESTAMP_ASCII); - break; - } + pco_get_timestamp_mode(priv->pco, &mode); + g_value_set_enum (value, table[mode]); } break; @@ -1280,7 +1274,7 @@ static void uca_pco_camera_class_init(UcaPcoCameraClass *klass) G_PARAM_READABLE); pco_properties[PROP_TIMESTAMP_MODE] = - g_param_spec_flags("timestamp-mode", + g_param_spec_enum("timestamp-mode", "Timestamp mode", "Timestamp mode", UCA_TYPE_PCO_CAMERA_TIMESTAMP, UCA_PCO_CAMERA_TIMESTAMP_NONE, diff --git a/plugins/pco/uca-pco-camera.h b/plugins/pco/uca-pco-camera.h index 73ae44e..d134fb1 100644 --- a/plugins/pco/uca-pco-camera.h +++ b/plugins/pco/uca-pco-camera.h @@ -55,9 +55,10 @@ typedef enum { } UcaPcoCameraAcquireMode; typedef enum { - UCA_PCO_CAMERA_TIMESTAMP_NONE = 0, - UCA_PCO_CAMERA_TIMESTAMP_BINARY = 1 << 0, - UCA_PCO_CAMERA_TIMESTAMP_ASCII = 1 << 1 + UCA_PCO_CAMERA_TIMESTAMP_NONE, + UCA_PCO_CAMERA_TIMESTAMP_BINARY, + UCA_PCO_CAMERA_TIMESTAMP_ASCII, + UCA_PCO_CAMERA_TIMESTAMP_BOTH } UcaPcoCameraTimestamp; /** |