## GcmSensor

GcmSensor — Sensor object

## Synopsis

    struct              GcmSensor;
    struct              GcmSensorClass;
    enum                GcmSensorError;
    enum                GcmSensorOutputType;
    enum                GcmSensorKind;
    enum                GcmSensorState;
    #define             GCM_SENSOR_ERROR
    GcmSensor *         gcm_sensor_new                      (void);
    void                gcm_sensor_button_pressed           (GcmSensor *sensor);
    void                gcm_sensor_set_state                (GcmSensor *sensor,
                                                             GcmSensorState state);
    GcmSensorState      gcm_sensor_get_state                (GcmSensor *sensor);
    gboolean            gcm_sensor_dump                     (GcmSensor *sensor,
                                                             GString *data,
                                                             GError **error);
    gboolean            gcm_sensor_set_leds                 (GcmSensor *sensor,
                                                             guint8 value,
                                                             GError **error);
    gboolean            gcm_sensor_set_from_device          (GcmSensor *sensor,
                                                             GUdevDevice *device,
                                                             GError **error);
    void                gcm_sensor_set_output_type          (GcmSensor *sensor,
                                                             GcmSensorOutputType output_type);
    GcmSensorOutputType  gcm_sensor_get_output_type         (GcmSensor *sensor);
    void                gcm_sensor_set_serial_number        (GcmSensor *sensor,
                                                             const gchar *serial_number);
    const gchar *       gcm_sensor_get_serial_number        (GcmSensor *sensor);
    const gchar *       gcm_sensor_get_model                (GcmSensor *sensor);
    const gchar *       gcm_sensor_get_vendor               (GcmSensor *sensor);
    GcmSensorKind       gcm_sensor_get_kind                 (GcmSensor *sensor);
    gboolean            gcm_sensor_supports_display         (GcmSensor *sensor);
    gboolean            gcm_sensor_supports_projector       (GcmSensor *sensor);
    gboolean            gcm_sensor_supports_printer         (GcmSensor *sensor);
    gboolean            gcm_sensor_supports_spot            (GcmSensor *sensor);
    gboolean            gcm_sensor_is_native                (GcmSensor *sensor);
    const gchar *       gcm_sensor_kind_to_string           (GcmSensorKind sensor_kind);
    GcmSensorKind       gcm_sensor_kind_from_string         (const gchar *sensor_kind);
    const gchar *       gcm_sensor_get_image_display        (GcmSensor *sensor);
    const gchar *       gcm_sensor_get_image_calibrate      (GcmSensor *sensor);
    const gchar *       gcm_sensor_get_image_spotread       (GcmSensor *sensor);
    void                gcm_sensor_get_ambient_async        (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            gcm_sensor_get_ambient_finish       (GcmSensor *sensor,
                                                             GAsyncResult *res,
                                                             gdouble *value,
                                                             GError **error);
    void                gcm_sensor_sample_async             (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    gboolean            gcm_sensor_sample_finish            (GcmSensor *sensor,
                                                             GAsyncResult *res,
                                                             GcmColorXYZ *value,
                                                             GError **error);
    gboolean            gcm_sensor_get_ambient              (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             gdouble *value,
                                                             GError **error);
    gboolean            gcm_sensor_sample                   (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             GcmColorXYZ *value,
                                                             GError **error);
                        GcmSensorPrivate;

## Object Hierarchy

      GObject
       +----GcmSensor
             +----GcmSensorColormunki
             +----GcmSensorDummy
             +----GcmSensorHuey

## Properties

      "device"                   gchar*                : Read
      "image-calibrate"          gchar*                : Read / Write / Construct
      "image-display"            gchar*                : Read / Write / Construct
      "image-spotread"           gchar*                : Read / Write / Construct
      "kind"                     guint                 : Read / Write / Construct
      "model"                    gchar*                : Read
      "native"                   gboolean              : Read / Write / Construct
      "serial-number"            gchar*                : Read / Write
      "state"                    guint                 : Read / Write / Construct
      "supports-display"         gboolean              : Read
      "supports-printer"         gboolean              : Read
      "supports-projector"       gboolean              : Read
      "supports-spot"            gboolean              : Read
      "vendor"                   gchar*                : Read

## Signals

      "button-pressed"                                 : Run Last

## Description

This object allows abstract handling of color sensors.

## Details

### struct GcmSensor

    struct GcmSensor;

### struct GcmSensorClass

    struct GcmSensorClass {
    	GObjectClass parent_class;
    	/* vtable */
    	void		 (*get_ambient_async)		(GcmSensor *sensor,
    							 GCancellable *cancellable,
    							 GAsyncResult *res);
    	gboolean	 (*get_ambient_finish)		(GcmSensor *sensor,
    							 GAsyncResult *res,
    							 gdouble *value,
    							 GError		**error);
    	void		 (*sample_async)		(GcmSensor *sensor,
    							 GCancellable *cancellable,
    							 GAsyncResult *res);
    	gboolean	 (*sample_finish)		(GcmSensor *sensor,
    							 GAsyncResult *res,
    							 GcmColorXYZ *value,
    							 GError		**error);
    	gboolean	 (*set_leds)			(GcmSensor *sensor,
    							 guint8		 value,
    							 GError		**error);
    	gboolean	 (*dump)			(GcmSensor *sensor,
    							 GString *data,
    							 GError		**error);
    	/* signals */
    	void		(* button_pressed)		(void);
    	/* padding for future expansion */
    	void (*_gcm_reserved1) (void);
    	void (*_gcm_reserved2) (void);
    	void (*_gcm_reserved3) (void);
    	void (*_gcm_reserved4) (void);
    	void (*_gcm_reserved5) (void);
    };

### enum GcmSensorError

    typedef enum {
    	GCM_SENSOR_ERROR_USER_ABORT,
    	GCM_SENSOR_ERROR_NO_SUPPORT,
    	GCM_SENSOR_ERROR_NO_DATA,
    	GCM_SENSOR_ERROR_INTERNAL
    } GcmSensorError;

The error code.

### enum GcmSensorOutputType

    typedef enum {
    	GCM_SENSOR_OUTPUT_TYPE_UNKNOWN,
    	GCM_SENSOR_OUTPUT_TYPE_LCD,
    	GCM_SENSOR_OUTPUT_TYPE_CRT,
    	GCM_SENSOR_OUTPUT_TYPE_PROJECTOR
    } GcmSensorOutputType;

The output type.

### enum GcmSensorKind

    typedef enum {
    	GCM_SENSOR_KIND_HUEY,
    	GCM_SENSOR_KIND_COLOR_MUNKI,
    	GCM_SENSOR_KIND_SPYDER,
    	GCM_SENSOR_KIND_DTP20,
    	GCM_SENSOR_KIND_DTP22,
    	GCM_SENSOR_KIND_DTP41,
    	GCM_SENSOR_KIND_DTP51,
    	GCM_SENSOR_KIND_DTP94,
    	GCM_SENSOR_KIND_SPECTRO_SCAN,
    	GCM_SENSOR_KIND_I1_PRO,
    	GCM_SENSOR_KIND_COLORIMTRE_HCFR,
    	GCM_SENSOR_KIND_UNKNOWN
    } GcmSensorKind;

The sensor type.

### enum GcmSensorState

    typedef enum {
    	GCM_SENSOR_STATE_STARTING,
    	GCM_SENSOR_STATE_IDLE,
    	GCM_SENSOR_STATE_MEASURING
    } GcmSensorState;

The state of the sensor.

### GCM_SENSOR_ERROR

    #define GCM_SENSOR_ERROR 1

### gcm_sensor_new ()

    GcmSensor *         gcm_sensor_new                      (void);

Returns : | a new GcmSensor object.

Since 2.91.1

### gcm_sensor_button_pressed ()

    void                gcm_sensor_button_pressed           (GcmSensor *sensor);

Causes the ::button-pressed signal to be fired.

Since 2.91.1

### gcm_sensor_set_state ()

    void                gcm_sensor_set_state                (GcmSensor *sensor,
                                                             GcmSensorState state);

Sets the device state.

`sensor` : | a valid GcmSensor instance
`state` : | the sensor state, e.g `GCM_SENSOR_STATE_IDLE`

Since 2.91.1

### gcm_sensor_get_state ()

    GcmSensorState      gcm_sensor_get_state                (GcmSensor *sensor);

Gets if the sensor is state taking a measurement.

`sensor` : | a valid GcmSensor instance
Returns : | `TRUE` for state.

Since 2.91.1

### gcm_sensor_dump ()

    gboolean            gcm_sensor_dump                     (GcmSensor *sensor,
                                                             GString *data,
                                                             GError **error);

Dumps the unstructured device data to a string.

`sensor` : | a valid GcmSensor instance
`data` : | A valid GString for the returned data
`error` : | a GError or `NULL`
Returns : | `TRUE` for success.

Since 2.91.1

### gcm_sensor_set_leds ()

    gboolean            gcm_sensor_set_leds                 (GcmSensor *sensor,
                                                             guint8 value,
                                                             GError **error);

Sets the LED output state for the device.

`sensor` : | a valid GcmSensor instance
`value` : | The LED bitmask
`error` : | a GError or `NULL`
Returns : | `TRUE` for success.

Since 2.91.1

### gcm_sensor_set_from_device ()

    gboolean            gcm_sensor_set_from_device          (GcmSensor *sensor,
                                                             GUdevDevice *device,
                                                             GError **error);

Set up some details about the sensor from the raw device. We aim to get as much as possible from UDEV.

`sensor` : | a valid GcmSensor instance
`device` : | a GUdevDevice
`error` : | a GError or `NULL`
Returns : | `TRUE` for success.

Since 2.91.1

### gcm_sensor_set_output_type ()

    void                gcm_sensor_set_output_type          (GcmSensor *sensor,
                                                             GcmSensorOutputType output_type);

Set the output type. Different sensors may do different things depending on the output type.

`sensor` : | a valid GcmSensor instance
`output_type` : | the output type, e.g. `GCM_SENSOR_OUTPUT_TYPE_LCD`

Since 2.91.1

### gcm_sensor_get_output_type ()

    GcmSensorOutputType  gcm_sensor_get_output_type         (GcmSensor *sensor);

Returns the set output type. Different sensors may do different things depending on the output type.

`sensor` : | a valid GcmSensor instance
Returns : | the output type, e.g. `GCM_SENSOR_OUTPUT_TYPE_LCD`

Since 2.91.1

### gcm_sensor_set_serial_number ()

    void                gcm_sensor_set_serial_number        (GcmSensor *sensor,
                                                             const gchar *serial_number);

Sets the sensor serial number which can be used to uniquely identify the device.

`sensor` : | a valid GcmSensor instance
`serial_number` : | the serial number

Since 2.91.1

### gcm_sensor_get_serial_number ()

    const gchar *       gcm_sensor_get_serial_number        (GcmSensor *sensor);

Gets the sensor serial number.

`sensor` : | a valid GcmSensor instance
Returns : | a string.

Since 2.91.1

### gcm_sensor_get_model ()

    const gchar *       gcm_sensor_get_model                (GcmSensor *sensor);

Gets the sensor model.

`sensor` : | a valid GcmSensor instance
Returns : | a string.

Since 2.91.1

### gcm_sensor_get_vendor ()

    const gchar *       gcm_sensor_get_vendor               (GcmSensor *sensor);

Gets the sensor vendor.

`sensor` : | a valid GcmSensor instance
Returns : | a string.

Since 2.91.1

### gcm_sensor_get_kind ()

    GcmSensorKind       gcm_sensor_get_kind                 (GcmSensor *sensor);

Returns the sensor kind.

`sensor` : | a valid GcmSensor instance
Returns : | the sensor kind, e.g. `GCM_SENSOR_KIND_HUEY`

Since 2.91.1

### gcm_sensor_supports_display ()

    gboolean            gcm_sensor_supports_display         (GcmSensor *sensor);

Returns if the sensor supports profiling a display.

`sensor` : | a valid GcmSensor instance
Returns : | `TRUE` or `FALSE`.

Since 2.91.1

### gcm_sensor_supports_projector ()

    gboolean            gcm_sensor_supports_projector       (GcmSensor *sensor);

Returns if the sensor supports profiling a projector.

`sensor` : | a valid GcmSensor instance
Returns : | `TRUE` or `FALSE`.

Since 2.91.1

### gcm_sensor_supports_printer ()

    gboolean            gcm_sensor_supports_printer         (GcmSensor *sensor);

Returns if the sensor supports profiling a printer.

`sensor` : | a valid GcmSensor instance
Returns : | `TRUE` or `FALSE`.

Since 2.91.1

### gcm_sensor_supports_spot ()

    gboolean            gcm_sensor_supports_spot            (GcmSensor *sensor);

Returns if the sensor supports getting a spot color.

`sensor` : | a valid GcmSensor instance
Returns : | `TRUE` or `FALSE`.

Since 2.91.1

### gcm_sensor_is_native ()

    gboolean            gcm_sensor_is_native                (GcmSensor *sensor);

Sensor support can be built in, for instance the HUEY, or rely on external frameworks such as argyllcms. Native sensor support is done internally without calling out to other frameworks.

`sensor` : | a valid GcmSensor instance
Returns : | `TRUE` for internal, native, support.

Since 2.91.1

### gcm_sensor_kind_to_string ()

    const gchar *       gcm_sensor_kind_to_string           (GcmSensorKind sensor_kind);

Gets the sensor kind as a string.

`sensor_kind` : | a GcmSensorKind
Returns : | the sensor kind, e.g. 'huey'.

Since 2.91.1

### gcm_sensor_kind_from_string ()

    GcmSensorKind       gcm_sensor_kind_from_string         (const gchar *sensor_kind);

Gets the sensor kind as a enumerated value.

`sensor_kind` : | the sensor kind, e.g. 'huey'.
Returns : | a GcmSensorKind

Since 2.91.1

### gcm_sensor_get_image_display ()

    const gchar *       gcm_sensor_get_image_display        (GcmSensor *sensor);

Since 2.91.1

### gcm_sensor_get_image_calibrate ()

    const gchar *       gcm_sensor_get_image_calibrate      (GcmSensor *sensor);

Since 2.91.1

### gcm_sensor_get_image_spotread ()

    const gchar *       gcm_sensor_get_image_spotread       (GcmSensor *sensor);

Since 2.91.1

### gcm_sensor_get_ambient_async ()

    void                gcm_sensor_get_ambient_async        (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Asks the hardware to get the ambient light value.

`sensor` : | a valid GcmSensor instance
`cancellable` : | a GCancellable or `NULL`
`callback` : | the function to run on completion
`user_data` : | the data to pass to `callback`

Since 2.91.1

### gcm_sensor_get_ambient_finish ()

    gboolean            gcm_sensor_get_ambient_finish       (GcmSensor *sensor,
                                                             GAsyncResult *res,
                                                             gdouble *value,
                                                             GError **error);

Gets the result from the asynchronous function.

`sensor` : | a valid GcmSensor instance
`res` : | the GAsyncResult
`value` : | the brightness in Lux, return value.
`error` : | A GError or `NULL`
Returns : | `FALSE` for an error

Since 2.91.1

### gcm_sensor_sample_async ()

    void                gcm_sensor_sample_async             (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

Sample the color and store as a XYZ value.

`sensor` : | a valid GcmSensor instance
`cancellable` : | a GCancellable or `NULL`
`callback` : | the function to run on completion
`user_data` : | the data to pass to `callback`

Since 2.91.1

### gcm_sensor_sample_finish ()

    gboolean            gcm_sensor_sample_finish            (GcmSensor *sensor,
                                                             GAsyncResult *res,
                                                             GcmColorXYZ *value,
                                                             GError **error);

Gets the result from the asynchronous function.

`sensor` : | a valid GcmSensor instance
`res` : | the GAsyncResult
`value` : | the brightness in Lux, return value.
`error` : | A GError or `NULL`
Returns : | `FALSE` for an error

Since 2.91.1

### gcm_sensor_get_ambient ()

    gboolean            gcm_sensor_get_ambient              (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             gdouble *value,
                                                             GError **error);

Gets the ambient light reading. Warning: this function is synchronous, and may block. Do not use it in GUI applications.

`sensor` : | a valid GcmSensor instance
`cancellable` : | a GCancellable or `NULL`
`value` : | the sensor brightness in Lux.
`error` : | A GError or `NULL`
Returns : | `TRUE` if the ambient value was obtained.

Since 2.91.1

### gcm_sensor_sample ()

    gboolean            gcm_sensor_sample                   (GcmSensor *sensor,
                                                             GCancellable *cancellable,
                                                             GcmColorXYZ *value,
                                                             GError **error);

Sample the color and store as a XYZ value. Warning: this function is synchronous, and may block. Do not use it in GUI applications.

`sensor` : | a valid GcmSensor instance
`cancellable` : | a GCancellable or `NULL`
`value` : | the sensor brightness in Lux.
`error` : | A GError or `NULL`
Returns : | `TRUE` if the ambient value was obtained.

Since 2.91.1

### GcmSensorPrivate

    typedef struct _GcmSensorPrivate GcmSensorPrivate;

Private GcmSensor data

## Property Details

### The `"device"` property

      "device"                   gchar*                : Read

Default value: NULL

### The `"image-calibrate"` property

      "image-calibrate"          gchar*                : Read / Write / Construct

Default value: NULL

### The `"image-display"` property

      "image-display"            gchar*                : Read / Write / Construct

Default value: NULL

### The `"image-spotread"` property

      "image-spotread"           gchar*                : Read / Write / Construct

Default value: NULL

### The `"kind"` property

      "kind"                     guint                 : Read / Write / Construct

Default value: 11

### The `"model"` property

      "model"                    gchar*                : Read

Default value: NULL

### The `"native"` property

      "native"                   gboolean              : Read / Write / Construct

Default value: FALSE

### The `"serial-number"` property

      "serial-number"            gchar*                : Read / Write

Default value: NULL

### The `"state"` property

      "state"                    guint                 : Read / Write / Construct

Default value: 0

### The `"supports-display"` property

      "supports-display"         gboolean              : Read

Default value: FALSE

### The `"supports-printer"` property

      "supports-printer"         gboolean              : Read

Default value: FALSE

### The `"supports-projector"` property

      "supports-projector"       gboolean              : Read

Default value: FALSE

### The `"supports-spot"` property

      "supports-spot"            gboolean              : Read

Default value: FALSE

### The `"vendor"` property

      "vendor"                   gchar*                : Read

Default value: NULL

## Signal Details

### The `"button-pressed"` signal

    void                user_function                      (GcmSensor *arg0,
                                                            gpointer   user_data)      : Run Last

`user_data` : | user data set when the signal handler was connected.

Since 2.91.1