[gnome-control-center] user-accounts: Move non-shared function



commit 288ef61515c0c727a358df712513d68ffc83551c
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Nov 9 09:32:00 2018 +1300

    user-accounts: Move non-shared function
    
    The would_demote_only_admin function is only used in CcUserPanel

 panels/user-accounts/cc-user-panel.c | 38 ++++++++++++++++++++++++++++++++++++
 panels/user-accounts/um-utils.c      | 38 ------------------------------------
 panels/user-accounts/um-utils.h      |  2 --
 3 files changed, 38 insertions(+), 40 deletions(-)
---
diff --git a/panels/user-accounts/cc-user-panel.c b/panels/user-accounts/cc-user-panel.c
index a31ad256e..5002ba4fe 100644
--- a/panels/user-accounts/cc-user-panel.c
+++ b/panels/user-accounts/cc-user-panel.c
@@ -1136,6 +1136,44 @@ remove_unlock_tooltip (GtkWidget *widget)
                                               G_CALLBACK (show_tooltip_now), NULL);
 }
 
+static guint
+get_num_active_admin (ActUserManager *um)
+{
+        GSList *list;
+        GSList *l;
+        guint num_admin = 0;
+
+        list = act_user_manager_list_users (um);
+        for (l = list; l != NULL; l = l->next) {
+                ActUser *u = l->data;
+                if (act_user_get_account_type (u) == ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR && 
!act_user_get_locked (u)) {
+                        num_admin++;
+                }
+        }
+        g_slist_free (list);
+
+        return num_admin;
+}
+
+static gboolean
+would_demote_only_admin (ActUser *user)
+{
+        ActUserManager *um = act_user_manager_get_default ();
+
+        /* Prevent the user from demoting the only admin account.
+         * Returns TRUE when user is an administrator and there is only
+         * one enabled administrator. */
+
+        if (act_user_get_account_type (user) == ACT_USER_ACCOUNT_TYPE_STANDARD ||
+            act_user_get_locked (user))
+                return FALSE;
+
+        if (get_num_active_admin (um) > 1)
+                return FALSE;
+
+        return TRUE;
+}
+
 static void
 on_permission_changed (CcUserPanel *self)
 {
diff --git a/panels/user-accounts/um-utils.c b/panels/user-accounts/um-utils.c
index f8def3ef5..831d1e2df 100644
--- a/panels/user-accounts/um-utils.c
+++ b/panels/user-accounts/um-utils.c
@@ -794,41 +794,3 @@ set_user_icon_data (ActUser   *user,
         g_free (path);
 }
 
-static guint
-get_num_active_admin (ActUserManager *um)
-{
-        GSList *list;
-        GSList *l;
-        guint num_admin = 0;
-
-        list = act_user_manager_list_users (um);
-        for (l = list; l != NULL; l = l->next) {
-                ActUser *u = l->data;
-                if (act_user_get_account_type (u) == ACT_USER_ACCOUNT_TYPE_ADMINISTRATOR && 
!act_user_get_locked (u)) {
-                        num_admin++;
-                }
-        }
-        g_slist_free (list);
-
-        return num_admin;
-}
-
-gboolean
-would_demote_only_admin (ActUser *user)
-{
-
-        ActUserManager *um = act_user_manager_get_default ();
-
-        /* Prevent the user from demoting the only admin account.
-         * Returns TRUE when user is an administrator and there is only
-         * one enabled administrator. */
-
-        if (act_user_get_account_type (user) == ACT_USER_ACCOUNT_TYPE_STANDARD
-            ||  act_user_get_locked (user))
-                return FALSE;
-
-        if (get_num_active_admin (um) > 1)
-                return FALSE;
-
-        return TRUE;
-}
diff --git a/panels/user-accounts/um-utils.h b/panels/user-accounts/um-utils.h
index 4970b22b3..e140d6d10 100644
--- a/panels/user-accounts/um-utils.h
+++ b/panels/user-accounts/um-utils.h
@@ -52,6 +52,4 @@ cairo_surface_t *render_user_icon         (ActUser         *user,
 void     set_user_icon_data               (ActUser         *user,
                                            GdkPixbuf       *pixbuf);
 
-gboolean would_demote_only_admin          (ActUser *user);
-
 G_END_DECLS


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