[gnome-system-tools] Update groups after creating or deleting users



commit d9032b007c26e0babee9b189a039286b3dbed956
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Fri Dec 17 16:31:27 2010 +0100

    Update groups after creating or deleting users
    
    Previous behavior was clearly broken, since groups were not realoaded,
    meaning that new user's main group wasn't known. When committing further
    changes to new users, an invalid GID was passed, and every command failed.
    We can also stop reloading groups when running the groups dialog, which was
    a mere workaround.
    
    This requires a change in liboobs to work correctly, so bump dependency to
    2.91.1.

 configure.in              |    2 +-
 src/users/callbacks.c     |    5 -----
 src/users/user-settings.c |    9 +++++++++
 src/users/users-tool.c    |   12 ++++++++++++
 src/users/users-tool.h    |    7 ++++---
 5 files changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/configure.in b/configure.in
index 8719007..2ea002e 100644
--- a/configure.in
+++ b/configure.in
@@ -31,7 +31,7 @@ AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
 GLIB_GSETTINGS
 
 STB_REQUIRED=2.10.1
-LIBOOBS_REQUIRED=2.31.91
+LIBOOBS_REQUIRED=2.91.1
 GTK_REQUIRED=2.91
 GLIB_REQUIRED=2.25.3
 DBUS_REQUIRED=0.32
diff --git a/src/users/callbacks.c b/src/users/callbacks.c
index f3f5cc3..08455f4 100644
--- a/src/users/callbacks.c
+++ b/src/users/callbacks.c
@@ -178,11 +178,6 @@ on_manage_groups_clicked (GtkWidget *widget, gpointer user_data)
 
 	dialog = gst_dialog_get_widget (tool->main_dialog, "groups_dialog");
 
-	/* Force reloading configuration. This is needed when an user was just
-	 * created/deleted, in which case groups may have changed. */
-	oobs_object_update (GST_USERS_TOOL (tool)->groups_config);
-	gst_users_tool_update_gui (tool);
-
 	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (tool->main_dialog));
 	while (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_HELP);
 	gtk_widget_hide (dialog);
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index 7347748..fe4526f 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -173,6 +173,10 @@ user_delete (GtkTreeModel *model, GtkTreePath *path)
 		config = OOBS_USERS_CONFIG (GST_USERS_TOOL (tool)->users_config);
 		result = oobs_users_config_delete_user (config, user);
 		if (result == OOBS_RESULT_OK) {
+			/* Take into account the possible deletion of user's main group.
+			 * If we update groups here, the 'changed' signal will be blocked, and
+			 * if it happens after 2 seconds, it will trigger a confirmation dialog. */
+			g_idle_add (gst_users_tool_update_groups_async, tool);
 			gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
 			retval = TRUE;
 		}
@@ -1129,6 +1133,11 @@ on_user_new (GtkButton *button, gpointer user_data)
 		users_table_select_path (user_path);
 		gtk_tree_path_free (user_path);
 
+		/* Take into account possibly new main group for user.
+		 * If we update groups here, the 'changed' signal will be blocked,
+		 * and if it happens after 2 seconds, it will trigger a confirmation dialog. */
+		g_idle_add (gst_users_tool_update_groups_async, tool);
+
 		/* Finally, run the password edit dialog.
 		 * User can hit cancel, leaving the account disabled */
 		on_edit_user_passwd (NULL, NULL);
diff --git a/src/users/users-tool.c b/src/users/users-tool.c
index e8a180a..62162fa 100644
--- a/src/users/users-tool.c
+++ b/src/users/users-tool.c
@@ -263,6 +263,18 @@ gst_users_tool_update_gui (GstTool *tool)
 	update_shells (GST_USERS_TOOL (tool));
 }
 
+/*
+ * Function called via g_idle_add() when we need to allow signals
+ * to be processed before updating.
+ */
+gboolean
+gst_users_tool_update_groups_async (gpointer data)
+{
+	update_groups (GST_USERS_TOOL (data));
+
+	return FALSE;
+}
+
 static void
 gst_users_tool_update_config (GstTool *tool)
 {
diff --git a/src/users/users-tool.h b/src/users/users-tool.h
index 207900b..e764a8d 100644
--- a/src/users/users-tool.h
+++ b/src/users/users-tool.h
@@ -61,12 +61,13 @@ struct _GstUsersToolClass {
 	GstToolClass parent_class;
 };
 
-GType    gst_users_tool_get_type           (void);
+GType    gst_users_tool_get_type            (void);
 
-GstTool *gst_users_tool_new                (void);
+GstTool *gst_users_tool_new                 (void);
 
-void     gst_users_tool_update_gui         (GstTool *tool);
+void     gst_users_tool_update_gui          (GstTool *tool);
 
+gboolean gst_users_tool_update_groups_async (gpointer data);
 
 G_END_DECLS
 



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