summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-08-08 09:39:22 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-08-13 14:27:08 +0200
commit58e855f24b49fb211d8da50240b0278bfdf71413 (patch)
tree8b99f57dfa84bb2c69e434995c08e0ac749ab7ab /src
parent972bc48715450e61ae79c705b95ddabcc2b1bbc9 (diff)
downloadlibuca-58e855f24b49fb211d8da50240b0278bfdf71413.tar.gz
libuca-58e855f24b49fb211d8da50240b0278bfdf71413.tar.bz2
libuca-58e855f24b49fb211d8da50240b0278bfdf71413.tar.xz
libuca-58e855f24b49fb211d8da50240b0278bfdf71413.zip
Refactor out get_param_spec_by_name
Diffstat (limited to 'src')
-rw-r--r--src/uca-camera.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/uca-camera.c b/src/uca-camera.c
index 27af765..46e7cb7 100644
--- a/src/uca-camera.c
+++ b/src/uca-camera.c
@@ -980,6 +980,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 +1015,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);
-
- if (pspec == NULL) {
- g_warning ("Camera does not have property `%s'", prop_name);
- return;
- }
+ pspec = get_param_spec_by_name (camera, prop_name);
- uca_camera_set_property_unit (pspec, unit);
+ if (pspec != NULL)
+ uca_camera_set_property_unit (pspec, unit);
}
/**
@@ -1026,19 +1038,13 @@ 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);