[gnome-control-center] user-panel: Use fingerprint manager to track the enrollment state
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-panel: Use fingerprint manager to track the enrollment state
- Date: Fri, 26 Jun 2020 01:59:13 +0000 (UTC)
commit 25079fc505e9faafc271d5dc27624971fcef89cf
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Mon Apr 6 22:48:02 2020 +0200
user-panel: Use fingerprint manager to track the enrollment state
panels/user-accounts/cc-user-panel.c | 44 ++++++++++++++++++----------
panels/user-accounts/um-fingerprint-dialog.c | 6 ++++
panels/user-accounts/um-fingerprint-dialog.h | 2 ++
3 files changed, 36 insertions(+), 16 deletions(-)
---
diff --git a/panels/user-accounts/cc-user-panel.c b/panels/user-accounts/cc-user-panel.c
index 0ab7062b9..a5c876693 100644
--- a/panels/user-accounts/cc-user-panel.c
+++ b/panels/user-accounts/cc-user-panel.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "cc-user-panel.h"
+#include "cc-fingerprint-manager.h"
#include <stdlib.h>
#include <string.h>
@@ -112,8 +113,8 @@ struct _CcUserPanel {
CcAvatarChooser *avatar_chooser;
- gboolean needs_fingerprint_update;
GCancellable *fingerprint_cancellable;
+ CcFingerprintManager *fingerprint_manager;
gint other_accounts;
};
@@ -846,6 +847,22 @@ is_parental_controls_enabled_for_user (ActUser *user)
}
#endif
+static void
+update_fingerprint_row_state (CcUserPanel *self, GParamSpec *spec, CcFingerprintManager *fingerprint_manager)
+{
+ CcFingerprintState state = cc_fingerprint_manager_get_state (fingerprint_manager);
+
+ gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row),
+ state != CC_FINGERPRINT_STATE_NONE);
+
+ if (state == CC_FINGERPRINT_STATE_ENABLED)
+ gtk_label_set_text (self->fingerprint_state_label, _("Enabled"));
+ else if (state == CC_FINGERPRINT_STATE_DISABLED)
+ gtk_label_set_text (self->fingerprint_state_label, _("Disabled"));
+
+ fingerprint_set_enabled (state == CC_FINGERPRINT_STATE_ENABLED);
+}
+
static void
show_user (ActUser *user, CcUserPanel *self)
{
@@ -905,22 +922,18 @@ show_user (ActUser *user, CcUserPanel *self)
g_settings_get_boolean (self->login_screen_settings,
"enable-fingerprint-authentication")));
- if (!self->needs_fingerprint_update) {
- gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row), show);
+ if (show) {
+ if (!self->fingerprint_manager) {
+ self->fingerprint_manager = cc_fingerprint_manager_new (user);
+ g_signal_connect_object (self->fingerprint_manager,
+ "notify::state",
+ G_CALLBACK (update_fingerprint_row_state),
+ self, G_CONNECT_SWAPPED);
+ }
+
+ update_fingerprint_row_state (self, NULL, self->fingerprint_manager);
} else {
gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row), FALSE);
-
- if (show) {
- g_cancellable_cancel (self->fingerprint_cancellable);
- g_clear_object (&self->fingerprint_cancellable);
-
- self->fingerprint_cancellable = g_cancellable_new ();
- self->needs_fingerprint_update = FALSE;
-
- set_fingerprint_row (GTK_WIDGET (self->fingerprint_row),
- self->fingerprint_state_label,
- self->fingerprint_cancellable);
- }
}
/* Autologin: show when local account */
@@ -1558,7 +1571,6 @@ cc_user_panel_init (CcUserPanel *self)
gtk_widget_init_template (GTK_WIDGET (self));
self->um = act_user_manager_get_default ();
- self->needs_fingerprint_update = TRUE;
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider,
"/org/gnome/control-center/user-accounts/user-accounts-dialog.css");
diff --git a/panels/user-accounts/um-fingerprint-dialog.c b/panels/user-accounts/um-fingerprint-dialog.c
index bc90c8310..200c0d4a8 100644
--- a/panels/user-accounts/um-fingerprint-dialog.c
+++ b/panels/user-accounts/um-fingerprint-dialog.c
@@ -850,4 +850,10 @@ fingerprint_button_clicked (GtkWindow *parent,
}
}
+void
+fingerprint_set_enabled (gboolean enabled)
+{
+ is_disable = enabled;
+}
+
#pragma GCC diagnostic pop
diff --git a/panels/user-accounts/um-fingerprint-dialog.h b/panels/user-accounts/um-fingerprint-dialog.h
index 09dbf5133..dea120f7c 100644
--- a/panels/user-accounts/um-fingerprint-dialog.h
+++ b/panels/user-accounts/um-fingerprint-dialog.h
@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include <act/act.h>
+void fingerprint_set_enabled (gboolean enabled);
+
void set_fingerprint_row (GtkWidget *fingerprint_row,
GtkLabel *state_label,
GCancellable *cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]