diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2014-08-13 14:52:51 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2014-08-13 14:52:51 +0200 |
commit | fa7e40e0f6b4c4669f17583d5194b05d5df9e742 (patch) | |
tree | 4ac0ac99502280cbed19c64c4040d60d960a253f /src/uca-camera.c | |
parent | 972bc48715450e61ae79c705b95ddabcc2b1bbc9 (diff) | |
parent | a389a30e57a038dcfc83dc2814d56a4a1c9a6084 (diff) | |
download | uca-fa7e40e0f6b4c4669f17583d5194b05d5df9e742.tar.gz uca-fa7e40e0f6b4c4669f17583d5194b05d5df9e742.tar.bz2 uca-fa7e40e0f6b4c4669f17583d5194b05d5df9e742.tar.xz uca-fa7e40e0f6b4c4669f17583d5194b05d5df9e742.zip |
Merge pull request #42 from ufo-kit/fix-41-access-specifications
Fix #41 access specifications
Diffstat (limited to 'src/uca-camera.c')
-rw-r--r-- | src/uca-camera.c | 99 |
1 files changed, 80 insertions, 19 deletions
diff --git a/src/uca-camera.c b/src/uca-camera.c index 27af765..fce3d12 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -76,6 +76,11 @@ GQuark uca_unit_quark () return g_quark_from_static_string ("uca-unit-quark"); } +GQuark uca_writable_quark () +{ + return g_quark_from_static_string ("uca-writable-quark"); +} + enum { LAST_SIGNAL }; @@ -980,6 +985,26 @@ uca_camera_grab (UcaCamera *camera, gpointer data, GError **error) return result; } +static GParamSpec * +get_param_spec_by_name (UcaCamera *camera, + const gchar *prop_name) +{ + UcaCameraClass *klass; + GObjectClass *oclass; + GParamSpec *pspec; + + klass = UCA_CAMERA_GET_CLASS (camera); + oclass = G_OBJECT_CLASS (klass); + pspec = g_object_class_find_property (oclass, prop_name); + + if (pspec == NULL) { + g_warning ("Camera does not have property `%s'", prop_name); + return NULL; + } + + return pspec; +} + /** * uca_camera_register_unit: * @camera: A #UcaCamera object @@ -995,20 +1020,12 @@ uca_camera_register_unit (UcaCamera *camera, const gchar *prop_name, UcaUnit unit) { - UcaCameraClass *klass; - GObjectClass *oclass; GParamSpec *pspec; - klass = UCA_CAMERA_GET_CLASS (camera); - oclass = G_OBJECT_CLASS (klass); - pspec = g_object_class_find_property (oclass, prop_name); + pspec = get_param_spec_by_name (camera, prop_name); - if (pspec == NULL) { - g_warning ("Camera does not have property `%s'", prop_name); - return; - } - - uca_camera_set_property_unit (pspec, unit); + if (pspec != NULL) + uca_camera_set_property_unit (pspec, unit); } /** @@ -1026,21 +1043,65 @@ UcaUnit uca_camera_get_unit (UcaCamera *camera, const gchar *prop_name) { - UcaCameraClass *klass; - GObjectClass *oclass; GParamSpec *pspec; gpointer data; - klass = UCA_CAMERA_GET_CLASS (camera); - oclass = G_OBJECT_CLASS (klass); - pspec = g_object_class_find_property (oclass, prop_name); + pspec = get_param_spec_by_name (camera, prop_name); - if (pspec == NULL) { - g_warning ("Camera does not have property `%s'", prop_name); + if (pspec == NULL) return UCA_UNIT_NA; - } data = g_param_spec_get_qdata (pspec, UCA_UNIT_QUARK); return data == NULL ? UCA_UNIT_NA : GPOINTER_TO_INT (data); } +/** + * uca_camera_set_writable: + * @camera: A #UcaCamera object + * @prop_name: Name of property + * @writable: %TRUE if property can be written during acquisition + * + * Sets a flag that defines if @prop_name can be written during an acquisition. + * + * Since: 1.6 + */ +void +uca_camera_set_writable (UcaCamera *camera, + const gchar *prop_name, + gboolean writable) +{ + GParamSpec *pspec; + + pspec = get_param_spec_by_name (camera, prop_name); + + if (pspec != NULL) { + if (g_param_spec_get_qdata (pspec, UCA_WRITABLE_QUARK) != NULL) + g_warning ("::%s is already fixed", pspec->name); + else + g_param_spec_set_qdata (pspec, UCA_WRITABLE_QUARK, GINT_TO_POINTER (writable)); + } +} + +/** + * uca_camera_is_writable_during_acquisition: + * @camera: A #UcaCamera object + * @prop_name: Name of property + * + * Check if @prop_name can be written at run-time. This is %FALSE if the + * property is read-only, if uca_camera_set_writable() has not been called or + * uca_camera_set_writable() was called with %FALSE. + * + * Returns: %TRUE if the property can be written at acquisition time. + * Since: 1.6 + */ +gboolean +uca_camera_is_writable_during_acquisition (UcaCamera *camera, + const gchar *prop_name) +{ + GParamSpec *pspec; + + pspec = get_param_spec_by_name (camera, prop_name); + + return (pspec->flags & G_PARAM_WRITABLE) && + g_param_spec_get_qdata (pspec, UCA_WRITABLE_QUARK); +} |