user-panel: Only load the fingerprint state once

Don't load the fingerprint information all the times we update the view, but
load it during initialization only.

The fingerprint state in fact can only change because we requested it
through the dialog that we control already and that would update the
relevant widgets state anyways.

Also, given that the fingerprint settings are visible for the current user
anyway, we can track this only with a simple boolean, instead of using a set
of UIDs.
This commit is contained in:
Marco Trevisan (Treviño) 2020-04-03 17:36:39 +02:00 committed by Benjamin Berg
parent 3107279759
commit 014c7d77cc

View file

@ -103,6 +103,7 @@ struct _CcUserPanel {
CcAvatarChooser *avatar_chooser;
gboolean needs_fingerprint_update;
GCancellable *fingerprint_cancellable;
gint other_accounts;
@ -180,9 +181,6 @@ set_selected_user (CcUserPanel *self, CcCarouselItem *item)
g_set_object (&self->selected_user,
act_user_manager_get_user_by_id (self->um, uid));
g_cancellable_cancel (self->fingerprint_cancellable);
g_clear_object (&self->fingerprint_cancellable);
if (self->selected_user != NULL) {
show_user (self->selected_user, self);
}
@ -857,12 +855,22 @@ show_user (ActUser *user, CcUserPanel *self)
g_settings_get_boolean (self->login_screen_settings,
"enable-fingerprint-authentication")));
gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row), FALSE);
if (show) {
self->fingerprint_cancellable = g_cancellable_new ();
set_fingerprint_row (GTK_WIDGET (self->fingerprint_row),
self->fingerprint_state_label,
self->fingerprint_cancellable);
if (!self->needs_fingerprint_update) {
gtk_widget_set_visible (GTK_WIDGET (self->fingerprint_row), show);
} 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 */
@ -1093,6 +1101,11 @@ change_fingerprint (CcUserPanel *self)
g_assert (g_strcmp0 (g_get_user_name (), act_user_get_user_name (user)) == 0);
g_cancellable_cancel (self->fingerprint_cancellable);
g_clear_object (&self->fingerprint_cancellable);
self->fingerprint_cancellable = g_cancellable_new ();
fingerprint_button_clicked (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
GTK_WIDGET (self->fingerprint_row),
self->fingerprint_state_label,
@ -1447,6 +1460,7 @@ 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");