[gnome-system-tools] Fix current user detection and modification
- From: Milan Bouchet-Valat <milanbv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-system-tools] Fix current user detection and modification
- Date: Wed, 19 Aug 2009 13:59:49 +0000 (UTC)
commit 96be08b1de87f4e00cc90eb4d9f4eba9becaad45
Author: Milan Bouchet-Valat <nalimilan club fr>
Date: Tue Aug 18 20:24:38 2009 +0200
Fix current user detection and modification
Don't allow to modify not show settings for currently logged in users, only the current one. Change the way we check for authentication for org.freedesktop.systemtoolsbackends.self.set. Showing settings for other users will possibly be enabled later, since the backend can provide it without authorization; but it needs more work.
src/users/callbacks.c | 27 ++++++++++++++-------------
src/users/users-table.c | 6 +++++-
2 files changed, 19 insertions(+), 14 deletions(-)
---
diff --git a/src/users/callbacks.c b/src/users/callbacks.c
index 05e29e6..fe5d47d 100644
--- a/src/users/callbacks.c
+++ b/src/users/callbacks.c
@@ -68,6 +68,9 @@ on_unlocked (GstDialog *dialog)
static void
actions_set_sensitive (gint table, gint count, OobsUser *user)
{
+ OobsObject *object = GST_USERS_TOOL (tool)->self_config;
+ gboolean sensitive;
+
switch (table) {
case TABLE_USERS:
gst_dialog_try_set_sensitive (tool->main_dialog,
@@ -77,9 +80,10 @@ actions_set_sensitive (gint table, gint count, OobsUser *user)
gst_dialog_get_widget (tool->main_dialog, "user_delete"),
(count > 0));
-
+ sensitive = count == 1 && gst_dialog_is_authenticated (tool->main_dialog)
+ || (user == oobs_self_config_get_user (OOBS_SELF_CONFIG (object)));
gtk_widget_set_sensitive (gst_dialog_get_widget (tool->main_dialog, "user_settings"),
- (count == 1 && (gst_dialog_is_authenticated (tool->main_dialog) || oobs_user_get_active (user))));
+ sensitive);
break;
case TABLE_GROUPS:
gst_dialog_try_set_sensitive (tool->main_dialog,
@@ -195,6 +199,7 @@ on_table_button_press (GtkTreeView *treeview, GdkEventButton *event, gpointer da
GtkTreePath *path;
GtkTreeIter iter;
OobsUser *user;
+ OobsObject *object;
selected = gtk_tree_selection_get_selected_rows (selection, &model);
path = (GtkTreePath *) selected->data;
@@ -202,7 +207,8 @@ on_table_button_press (GtkTreeView *treeview, GdkEventButton *event, gpointer da
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, COL_USER_OBJECT, &user, -1);
- if (!oobs_user_get_active (user))
+ object = GST_USERS_TOOL (tool)->self_config;
+ if (user != oobs_self_config_get_user (OOBS_SELF_CONFIG (object)))
return FALSE;
}
@@ -325,22 +331,17 @@ on_user_settings_clicked (GtkButton *button, gpointer user_data)
/* change users/groups configuration */
oobs_object_commit (GST_USERS_TOOL (tool)->users_config);
oobs_object_commit (GST_USERS_TOOL (tool)->groups_config);
+#ifdef HAVE_POLKIT
+ /* With PolicyKit1, we don't have to check for authorizations: just try to commit,
+ * the backend will trigger authentication if possible, or fail */
} else {
OobsObject *object = GST_USERS_TOOL (tool)->self_config;
/* change self, only if it is the modified user */
if (user == oobs_self_config_get_user (OOBS_SELF_CONFIG (object))) {
-#ifdef HAVE_POLKIT
- GstPolKitAction *action;
- action = gst_polkit_action_new (oobs_object_get_authentication_action (object),
- GTK_WIDGET (tool->main_dialog));
-
- if (gst_polkit_action_authenticate (action))
- oobs_object_commit (GST_USERS_TOOL (tool)->self_config);
-
- g_object_unref (action);
-#endif
+ oobs_object_commit (GST_USERS_TOOL (tool)->self_config);
}
+#endif
}
}
diff --git a/src/users/users-table.c b/src/users/users-table.c
index 49513c0..f2673bd 100644
--- a/src/users/users-table.c
+++ b/src/users/users-table.c
@@ -177,9 +177,13 @@ users_table_set_user (OobsUser *user, OobsListIter *list_iter, GtkTreeIter *iter
GtkWidget *users_table = gst_dialog_get_widget (GST_TOOL (tool)->main_dialog, "users_table");
GtkTreeModel *filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (users_table));
GtkTreeModel *model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
+ OobsObject *object = GST_USERS_TOOL (tool)->self_config;
GdkPixbuf *face;
+ gboolean sensitive;
face = get_user_face (oobs_user_get_home_directory (user));
+ sensitive = gst_dialog_is_authenticated (tool->main_dialog) ||
+ (user == oobs_self_config_get_user (OOBS_SELF_CONFIG (object)));
gtk_list_store_set (GTK_LIST_STORE (model), iter,
COL_USER_FACE, face,
@@ -189,7 +193,7 @@ users_table_set_user (OobsUser *user, OobsListIter *list_iter, GtkTreeIter *iter
COL_USER_ID, oobs_user_get_uid (user),
COL_USER_OBJECT, user,
COL_USER_ITER, list_iter,
- COL_USER_SENSITIVE, gst_dialog_is_authenticated (tool->main_dialog) || oobs_user_get_active (user),
+ COL_USER_SENSITIVE, sensitive,
-1);
if (face)
g_object_unref (face);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]