[gnome-system-tools] When checking for main group's existence, take into account the combo box selection
- From: Milan Bouchet-Valat <milanbv src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-system-tools] When checking for main group's existence, take into account the combo box selection
- Date: Thu, 27 Aug 2009 15:54:08 +0000 (UTC)
commit 9d38d16af9ff19307a29f820a4c35a6591749256
Author: Milan Bouchet-Valat <nalimilan club fr>
Date: Thu Aug 27 13:31:24 2009 +0200
When checking for main group's existence, take into account the combo box selection
We now check that the main group to create does not already exist, to avoid overwriting it. This commit uses the group selected in the user_settings_group combo box instead of always using the login for that. This allows choosing another group, but has little practical interest until we actually allow using existing groups without replacing them.
src/users/user-settings.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index 0dbdbcf..eeaa9f6 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -551,11 +551,24 @@ check_login (gchar **primary_text, gchar **secondary_text, gpointer data)
{
OobsUser *user;
GtkWidget *widget;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
const gchar *login;
+ gchar *group;
+
+ user = g_object_get_data (G_OBJECT (data), "user");
widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_name");
login = gtk_entry_get_text (GTK_ENTRY (widget));
- user = g_object_get_data (G_OBJECT (data), "user");
+
+ widget = gst_dialog_get_widget (tool->main_dialog, "user_settings_group");
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) {
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+ gtk_tree_model_get (model, &iter, COL_GROUP_NAME, &group, -1);
+ g_object_unref (model);
+ }
+ else /* If no main group is selected, login will be used to create it, so check that it's possible */
+ group = g_strdup (login);
if (strlen (login) < 1) {
*primary_text = g_strdup (_("User name is empty"));
@@ -568,10 +581,12 @@ check_login (gchar **primary_text, gchar **secondary_text, gpointer data)
} else if (!user && login_exists (login)) {
*primary_text = g_strdup_printf (_("User name \"%s\" already exists"), login);
*secondary_text = g_strdup (_("Please choose a different user name."));
- } else if (!user && group_settings_group_exists (login)) {
- *primary_text = g_strdup_printf (_("Group \"%s\" already exists"), login);
+ } else if (!user && group_settings_group_exists (group)) {
+ *primary_text = g_strdup_printf (_("Group \"%s\" already exists"), group);
*secondary_text = g_strdup (_("Please choose a different user name."));
}
+
+ g_free (group);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]