diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2012-03-02 17:51:45 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2012-03-02 17:51:45 +0100 |
commit | 3761b79dc771022e2f39fb22708d7436f5f02e12 (patch) | |
tree | 8cff21b8b1b1fa0af237596e7612c0631fb3516e | |
parent | 5ce0955086c2360d5f5346270759fb7d96cc4a70 (diff) | |
download | libuca-3761b79dc771022e2f39fb22708d7436f5f02e12.tar.gz libuca-3761b79dc771022e2f39fb22708d7436f5f02e12.tar.bz2 libuca-3761b79dc771022e2f39fb22708d7436f5f02e12.tar.xz libuca-3761b79dc771022e2f39fb22708d7436f5f02e12.zip |
Test property signals
-rw-r--r-- | src/cameras/uca-mock-camera.c | 2 | ||||
-rw-r--r-- | src/uca-camera.c | 39 | ||||
-rw-r--r-- | src/uca-camera.h | 2 |
3 files changed, 32 insertions, 11 deletions
diff --git a/src/cameras/uca-mock-camera.c b/src/cameras/uca-mock-camera.c index 0803ec0..8a40bcd 100644 --- a/src/cameras/uca-mock-camera.c +++ b/src/cameras/uca-mock-camera.c @@ -87,7 +87,9 @@ static void uca_mock_camera_grab(UcaCamera *camera, gchar *data, GError **error) static void uca_mock_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { + g_return_if_fail(UCA_IS_MOCK_CAMERA(object)); UcaMockCameraPrivate *priv = UCA_MOCK_CAMERA_GET_PRIVATE(object); + g_signal_emit_by_name(object, "property-changed", pspec->name, NULL); switch (property_id) { case PROP_FRAMERATE: diff --git a/src/uca-camera.c b/src/uca-camera.c index 85c4140..9fda4a1 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -33,6 +33,11 @@ GQuark uca_camera_error_quark() } enum { + PROPERTY_CHANGED, + LAST_SIGNAL +}; + +enum { PROP_0 = 0, PROP_SENSOR_WIDTH, PROP_SENSOR_HEIGHT, @@ -50,10 +55,13 @@ struct _UcaCameraPrivate { gboolean recording; }; -static GParamSpec *uca_camera_properties[N_PROPERTIES] = { NULL, }; +static GParamSpec *camera_properties[N_PROPERTIES] = { NULL, }; + +static guint camera_signals[LAST_SIGNAL] = { 0 }; static void uca_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } @@ -72,35 +80,35 @@ static void uca_camera_class_init(UcaCameraClass *klass) klass->stop_recording = NULL; klass->grab = NULL; - uca_camera_properties[PROP_SENSOR_WIDTH] = + camera_properties[PROP_SENSOR_WIDTH] = g_param_spec_uint("sensor-width", "Width of sensor", "Width of the sensor in pixels", 1, G_MAXUINT, 1, G_PARAM_READABLE); - uca_camera_properties[PROP_SENSOR_HEIGHT] = + camera_properties[PROP_SENSOR_HEIGHT] = g_param_spec_uint("sensor-height", "Height of sensor", "Height of the sensor in pixels", 1, G_MAXUINT, 1, G_PARAM_READABLE); - uca_camera_properties[PROP_SENSOR_BITDEPTH] = + camera_properties[PROP_SENSOR_BITDEPTH] = g_param_spec_uint("sensor-bitdepth", "Number of bits per pixel", "Number of bits per pixel", 1, 32, 1, G_PARAM_READABLE); - uca_camera_properties[PROP_SENSOR_HORIZONTAL_BINNING] = + camera_properties[PROP_SENSOR_HORIZONTAL_BINNING] = g_param_spec_uint("sensor-horizontal-binning", "Horizontal binning", "Number of sensor ADCs that are combined to one pixel in horizontal direction", 1, G_MAXUINT, 1, G_PARAM_READWRITE); - uca_camera_properties[PROP_SENSOR_HORIZONTAL_BINNINGS] = + camera_properties[PROP_SENSOR_HORIZONTAL_BINNINGS] = g_param_spec_value_array("sensor-horizontal-binnings", "Array of possible binnings", "Array of possible binnings in horizontal direction", @@ -111,14 +119,14 @@ static void uca_camera_class_init(UcaCameraClass *klass) 1, G_MAXUINT, 1, G_PARAM_READABLE), G_PARAM_READABLE); - uca_camera_properties[PROP_SENSOR_VERTICAL_BINNING] = + camera_properties[PROP_SENSOR_VERTICAL_BINNING] = g_param_spec_uint("sensor-vertical-binning", "Vertical binning", "Number of sensor ADCs that are combined to one pixel in vertical direction", 1, G_MAXUINT, 1, G_PARAM_READWRITE); - uca_camera_properties[PROP_SENSOR_VERTICAL_BINNINGS] = + camera_properties[PROP_SENSOR_VERTICAL_BINNINGS] = g_param_spec_value_array("sensor-vertical-binnings", "Array of possible binnings", "Array of possible binnings in vertical direction", @@ -129,20 +137,29 @@ static void uca_camera_class_init(UcaCameraClass *klass) 1, G_MAXUINT, 1, G_PARAM_READABLE), G_PARAM_READABLE); - uca_camera_properties[PROP_HAS_STREAMING] = + camera_properties[PROP_HAS_STREAMING] = g_param_spec_boolean("has-streaming", "Streaming capability", "Is the camera able to stream the data", TRUE, G_PARAM_READABLE); - uca_camera_properties[PROP_HAS_CAMRAM_RECORDING] = + camera_properties[PROP_HAS_CAMRAM_RECORDING] = g_param_spec_boolean("has-camram-recording", "Cam-RAM capability", "Is the camera able to record the data in-camera", FALSE, G_PARAM_READABLE); for (guint id = PROP_0 + 1; id < N_PROPERTIES; id++) - g_object_class_install_property(gobject_class, id, uca_camera_properties[id]); + g_object_class_install_property(gobject_class, id, camera_properties[id]); + + camera_signals[PROPERTY_CHANGED] = + g_signal_new("property-changed", + G_OBJECT_CLASS_TYPE(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(UcaCameraClass, property_changed), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 0); g_type_class_add_private(klass, sizeof(UcaCameraPrivate)); } diff --git a/src/uca-camera.h b/src/uca-camera.h index 4e30c0a..1117bd1 100644 --- a/src/uca-camera.h +++ b/src/uca-camera.h @@ -56,6 +56,8 @@ struct _UcaCameraClass { void (*start_recording) (UcaCamera *camera, GError **error); void (*stop_recording) (UcaCamera *camera, GError **error); void (*grab) (UcaCamera *camera, gchar *data, GError **error); + + void (*property_changed) (UcaCamera *camera, const gchar *name, gpointer user_data); }; void uca_camera_start_recording(UcaCamera *camera, GError **error); |