[gnome-control-center/wip/identity: 3/11] user-accounts: hide admin tasks from non-administrators
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/identity: 3/11] user-accounts: hide admin tasks from non-administrators
- Date: Fri, 22 Jun 2012 02:50:03 +0000 (UTC)
commit 83f7135a03b3ae14ec72481aea709ebbc0c9db7e
Author: Ray Strode <rstrode redhat com>
Date: Tue Feb 28 22:47:30 2012 -0500
user-accounts: hide admin tasks from non-administrators
If the user isn't an administrator (either by account type,
or through polkit escalation), then don't show administrative
tasks in the panel like editing other users, setting up autologin,
etc.
https://bugzilla.gnome.org/show_bug.cgi?id=671156
panels/user-accounts/um-user-panel.c | 66 ++++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 0dd709a..52e1af9 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -690,6 +690,7 @@ account_type_changed (UmEditableCombo *combo,
if (account_type != um_user_get_account_type (user)) {
um_user_set_account_type (user, account_type);
+ on_permission_changed (d->permission, NULL, d);
}
g_object_unref (user);
@@ -945,6 +946,60 @@ remove_unlock_tooltip (GtkWidget *button)
}
static void
+hide_administrative_tasks (UmUserPanelPrivate *d)
+{
+ GtkWidget *widget;
+
+ widget = get_widget (d, "userlist-vbox");
+ gtk_widget_hide (widget);
+
+ widget = get_widget (d, "account-type-label");
+ gtk_widget_hide (widget);
+
+ widget = get_widget (d, "account-type-combo");
+ gtk_widget_hide (widget);
+
+ widget = get_widget (d, "language-label");
+ gtk_widget_hide (widget);
+
+ widget = get_widget (d, "account-language-combo");
+ gtk_widget_hide (widget);
+
+ widget = get_widget (d, "autologin-label");
+ gtk_widget_hide (widget);
+
+ widget = get_widget (d, "autologin-switch");
+ gtk_widget_hide (widget);
+}
+
+static void
+show_administrative_tasks (UmUserPanelPrivate *d)
+{
+ GtkWidget *widget;
+
+ widget = get_widget (d, "userlist-vbox");
+ gtk_widget_show (widget);
+
+ widget = get_widget (d, "account-type-label");
+ gtk_widget_show (widget);
+
+ widget = get_widget (d, "account-type-combo");
+ gtk_widget_show (widget);
+
+ widget = get_widget (d, "language-label");
+ gtk_widget_show (widget);
+
+ widget = get_widget (d, "account-language-combo");
+ gtk_widget_show (widget);
+
+ widget = get_widget (d, "autologin-label");
+ gtk_widget_show (widget);
+
+ widget = get_widget (d, "autologin-switch");
+ gtk_widget_show (widget);
+}
+
+static void
on_permission_changed (GPermission *permission,
GParamSpec *pspec,
gpointer data)
@@ -953,6 +1008,8 @@ on_permission_changed (GPermission *permission,
gboolean is_authorized;
gboolean self_selected;
UmUser *user;
+ UmUser *self_user;
+ UmAccountType self_account_type;
GtkWidget *widget;
user = get_selected_user (d);
@@ -963,6 +1020,9 @@ on_permission_changed (GPermission *permission,
is_authorized = g_permission_get_allowed (G_PERMISSION (d->permission));
self_selected = um_user_get_uid (user) == geteuid ();
+ self_user = um_user_manager_get_user_by_id (d->um, geteuid ());
+ self_account_type = um_user_get_account_type (self_user);
+
widget = get_widget (d, "add-user-toolbutton");
gtk_widget_set_sensitive (widget, is_authorized);
if (is_authorized) {
@@ -1048,6 +1108,12 @@ on_permission_changed (GPermission *permission,
gtk_notebook_set_current_page (GTK_NOTEBOOK (get_widget (d, "account-fingerprint-notebook")), 0);
}
+ if (is_authorized || self_account_type == UM_ACCOUNT_TYPE_ADMINISTRATOR) {
+ show_administrative_tasks (d);
+ } else {
+ hide_administrative_tasks (d);
+ }
+
um_password_dialog_set_privileged (d->password_dialog, is_authorized);
g_object_unref (user);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]