Comment 16 for bug 198172

Revision history for this message
James Westby (james-w) wrote :

Hi,

This bug is a lot simpler to fix than what my first attempts
were trying to do. The fix is attached.

By way of explanation, as it's not completely obvious I
include the main part here.

+--- gnome-system-tools-2.22.0~/src/users/user-settings.c 2008-03-31 16:32:35.000000000 +0100
++++ gnome-system-tools-2.22.0/src/users/user-settings.c 2008-03-31 16:32:36.000000000 +0100
+@@ -347,9 +347,6 @@
+ widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_shell");
+ set_entry_text (GTK_BIN (widget)->child, oobs_user_get_shell (user));
+
+- widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_home");
+- set_entry_text (widget, oobs_user_get_home_directory (user));
+-
+ widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_uid");
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), oobs_user_get_uid (user));
+ gtk_widget_set_sensitive (GTK_SPIN_BUTTON (widget), FALSE);

Here's where the code used to set the home dir for existing users.

+@@ -394,6 +391,11 @@
+ if (!login)
+ table_set_default_profile (GST_USERS_TOOL (tool));
+

However this eventually sets the default home dir prefix
for the user's profile, and then calls the callback to
update that based on the user's name. This then overwrote
the value we set above.

It is exactly the right thing to do if the user didn't exist
on the system yet, i.e. user == NULL.

++ if (user) {
++ widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_home");
++ set_entry_text (widget, oobs_user_get_home_directory (user));
++ }

So, we just add this right after, which is taking the code above and
moving it below this, with the same guard. This means that
we still set the user's home directory if they already exist, we just do
it later so that it is not overwritten.

I have tested this and found

  * It shows both mine and the root account's home
     dir correctly, where only mine was shown before.

  * It uses the default prefix from the user's profile
     when creating a user, and updates the homedir
     as you type in the username, which is the same
     behaviour as before.

Thanks,

James