71 lines
2.3 KiB
Diff
71 lines
2.3 KiB
Diff
|
From cca6d3b04b74558e12df3aa43761faaa574c5ff9 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
||
|
Date: Fri, 22 Nov 2019 14:50:48 +0100
|
||
|
Subject: [PATCH 020/181] fp-image-device: Use a GObject signal to notify image
|
||
|
state changed
|
||
|
|
||
|
This is more GObject-friendly and we have the automatic call of the vfunc if
|
||
|
one is set.
|
||
|
---
|
||
|
libfprint/fp-image-device.c | 23 +++++++++++++++++------
|
||
|
1 file changed, 17 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/libfprint/fp-image-device.c b/libfprint/fp-image-device.c
|
||
|
index 3565b90..692727b 100644
|
||
|
--- a/libfprint/fp-image-device.c
|
||
|
+++ b/libfprint/fp-image-device.c
|
||
|
@@ -69,6 +69,14 @@ enum {
|
||
|
|
||
|
static GParamSpec *properties[N_PROPS];
|
||
|
|
||
|
+enum {
|
||
|
+ FPI_STATE_CHANGED,
|
||
|
+
|
||
|
+ LAST_SIGNAL
|
||
|
+};
|
||
|
+
|
||
|
+static guint signals[LAST_SIGNAL] = { 0 };
|
||
|
+
|
||
|
/*******************************************************/
|
||
|
|
||
|
/* TODO:
|
||
|
@@ -81,7 +89,6 @@ static void
|
||
|
fp_image_device_change_state (FpImageDevice *self, FpImageDeviceState state)
|
||
|
{
|
||
|
FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
|
||
|
- FpImageDeviceClass *cls = FP_IMAGE_DEVICE_GET_CLASS (self);
|
||
|
|
||
|
/* Cannot change to inactive using this function. */
|
||
|
g_assert (state != FP_IMAGE_DEVICE_STATE_INACTIVE);
|
||
|
@@ -94,11 +101,7 @@ fp_image_device_change_state (FpImageDevice *self, FpImageDeviceState state)
|
||
|
|
||
|
priv->state = state;
|
||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
|
||
|
-
|
||
|
- /* change_state is the only callback which is optional and does not
|
||
|
- * have a default implementation. */
|
||
|
- if (cls->change_state)
|
||
|
- cls->change_state (self, state);
|
||
|
+ g_signal_emit (self, signals[FPI_STATE_CHANGED], 0, priv->state);
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
@@ -356,6 +359,14 @@ fp_image_device_class_init (FpImageDeviceClass *klass)
|
||
|
FP_IMAGE_DEVICE_STATE_INACTIVE,
|
||
|
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
||
|
|
||
|
+ signals[FPI_STATE_CHANGED] =
|
||
|
+ g_signal_new ("fp-image-device-state-changed",
|
||
|
+ G_TYPE_FROM_CLASS (object_class),
|
||
|
+ G_SIGNAL_RUN_FIRST,
|
||
|
+ G_STRUCT_OFFSET (FpImageDeviceClass, change_state),
|
||
|
+ NULL, NULL, NULL,
|
||
|
+ G_TYPE_NONE, 1, FP_TYPE_IMAGE_DEVICE_STATE);
|
||
|
+
|
||
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||
|
}
|
||
|
|
||
|
--
|
||
|
2.24.1
|
||
|
|