[gnome-system-tools/gnome-2-28] Don't show changed user/group in the list if commit failed



commit 7b91b0d9b1b184fb32752624d2a16fbe6df9c45b
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Thu Sep 3 20:02:49 2009 +0200

    Don't show changed user/group in the list if commit failed
    
    This prevents the tool from showing data that does not reflect the state of the system configuration.

 src/users/callbacks.c     |   26 ++++++++++++++------------
 src/users/user-settings.c |    6 +++---
 2 files changed, 17 insertions(+), 15 deletions(-)
---
diff --git a/src/users/callbacks.c b/src/users/callbacks.c
index e30ce14..0e1d63c 100644
--- a/src/users/callbacks.c
+++ b/src/users/callbacks.c
@@ -302,11 +302,11 @@ on_user_new_clicked (GtkButton *button, gpointer user_data)
 		oobs_list_append (users_list, &list_iter);
 		oobs_list_set (users_list, &list_iter, user);
 
-		users_table_add_user (user, &list_iter);
-
-		/* Avoid committing group changes if the user has not been created */
-		if (gst_tool_commit (tool, GST_USERS_TOOL (tool)->users_config) == OOBS_RESULT_OK)
+		/* Avoid showing the new user or trying to commit group changes if the user has not been created */
+		if (gst_tool_commit (tool, GST_USERS_TOOL (tool)->users_config) == OOBS_RESULT_OK) {
 			gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config);
+			users_table_add_user (user, &list_iter);
+		}
 	}
 }
 
@@ -348,12 +348,12 @@ on_user_settings_clicked (GtkButton *button, gpointer user_data)
 		if (!user) /* Means an error has already occurred and been displayed, stop here */
 			return;
 
-		users_table_set_user (user, list_iter, &filter_iter);
-
 		if (gst_dialog_is_authenticated (tool->main_dialog)) {
 			/* change users/groups configuration */
-			gst_tool_commit (tool, GST_USERS_TOOL (tool)->users_config);
-			gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config);
+			if (gst_tool_commit (tool, GST_USERS_TOOL (tool)->users_config) == OOBS_RESULT_OK) {
+				gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config);
+				users_table_set_user (user, list_iter, &filter_iter);
+			}
 #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 */
@@ -361,8 +361,10 @@ on_user_settings_clicked (GtkButton *button, gpointer user_data)
 			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))) {
-				gst_tool_commit (tool, GST_USERS_TOOL (tool)->self_config);
+			if (user == oobs_self_config_get_user (OOBS_SELF_CONFIG (object)) &&
+			    gst_tool_commit (tool, GST_USERS_TOOL (tool)->self_config) == OOBS_RESULT_OK) {
+				gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config);
+				users_table_set_user (user, list_iter, &filter_iter);
 			}
 #endif
 		}
@@ -434,8 +436,8 @@ on_group_new_clicked (GtkButton *button, gpointer user_data)
 		oobs_list_append (groups_list, &list_iter);
 		oobs_list_set (groups_list, &list_iter, group);
 
-		groups_table_add_group (group, &list_iter);
-		gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config);
+		if (gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config) == OOBS_RESULT_OK)
+			groups_table_add_group (group, &list_iter);
 	}
 }
 
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index 03cd8ed..10c92a6 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -226,9 +226,9 @@ set_main_group (OobsUser *user)
 			oobs_list_append (groups_list, &list_iter);
 			oobs_list_set (groups_list, &list_iter, group);
 
-			groups_table_add_group (group, &list_iter);
-
-			if (gst_tool_commit (tool, OOBS_OBJECT (config)) != OOBS_RESULT_OK)
+			if (gst_tool_commit (tool, OOBS_OBJECT (config)) == OOBS_RESULT_OK)
+				groups_table_add_group (group, &list_iter);
+			else
 				group = NULL; /* See below */
 		}
 		/* Else group exists, use it */



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