[gnome-control-center/gnome-3-36] user-panel: Only load the fingerprint state once



commit 563232e40d40733b72fa31c4f82dd6421b2aea1d
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Fri Apr 3 17:36:39 2020 +0200

    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.

 panels/user-accounts/cc-user-panel.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/panels/user-accounts/cc-user-panel.c b/panels/user-accounts/cc-user-panel.c
index 09ab8c47a..3afe2b0fd 100644
--- a/panels/user-accounts/cc-user-panel.c
+++ b/panels/user-accounts/cc-user-panel.c
@@ -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);
         }
@@ -858,12 +856,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 */
@@ -1094,6 +1102,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,
@@ -1470,6 +1483,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");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]