Blame SOURCES/0020-fp-image-device-Use-a-GObject-signal-to-notify-image.patch

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