[gnome-control-center/gnome-3-8] user-accounts: really selects the newly-created user



commit 781a8bdf4fee52bc7aa8ca8fa23011edb82af35f
Author: Jonh Wendell <jonh wendell intel com>
Date:   Mon Jul 29 14:42:48 2013 -0300

    user-accounts: really selects the newly-created user
    
    complement to 6dc71282858625af53283d0cd23364f2ed4aa7dd
    
    make sure to only return the newly created User object when
    it is fully loaded.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704426

 panels/user-accounts/um-account-dialog.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/panels/user-accounts/um-account-dialog.c b/panels/user-accounts/um-account-dialog.c
index 3da6ccb..57ff77b 100644
--- a/panels/user-accounts/um-account-dialog.c
+++ b/panels/user-accounts/um-account-dialog.c
@@ -166,6 +166,15 @@ complete_dialog (UmAccountDialog *self,
 }
 
 static void
+user_loaded_cb (ActUser         *user,
+                GParamSpec      *pspec,
+                UmAccountDialog *self)
+{
+  finish_action (self);
+  complete_dialog (self, user);
+}
+
+static void
 create_user_done (ActUserManager  *manager,
                   GAsyncResult    *res,
                   UmAccountDialog *self)
@@ -173,14 +182,13 @@ create_user_done (ActUserManager  *manager,
         ActUser *user;
         GError *error;
 
-        finish_action (self);
-
         /* Note that user is returned without an extra reference */
 
         error = NULL;
         user = act_user_manager_create_user_finish (manager, res, &error);
 
         if (user == NULL) {
+                finish_action (self);
                 g_debug ("Failed to create user: %s", error->message);
                 if (!g_error_matches (error, ACT_USER_MANAGER_ERROR, 
ACT_USER_MANAGER_ERROR_PERMISSION_DENIED))
                        show_error_dialog (self, _("Failed to add account"), error);
@@ -188,7 +196,11 @@ create_user_done (ActUserManager  *manager,
                 gtk_widget_grab_focus (self->local_name);
         } else {
                 g_debug ("Created user: %s", act_user_get_user_name (user));
-                complete_dialog (self, user);
+                /* Check if the returned object is fully loaded before returning it */
+                if (act_user_is_loaded (user))
+                        user_loaded_cb (user, NULL, self);
+                else
+                        g_signal_connect (user, "notify::is-loaded", G_CALLBACK (user_loaded_cb), self);
         }
 }
 


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