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



commit 9745e8a5bfa5652c4596b63b79f9242d6262b4ac
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 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 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);
 	}
 }
 



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