[gnome-system-tools] Update password status field



commit 55635baf28e7380e4c39ada613a4283886e0ab78
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Wed Jan 27 16:27:50 2010 +0100

    Update password status field
    
    Fill the "Passwd:" field depending on whether the password is empty and asked on login, which is not yet filled by the backends. Call user_settings_show() after committing, since password may have changed. Reduce padding and modify table so that the label can take more horizontal space without changing the size of the users list.

 interfaces/users.ui       |   48 ++++++++++++++++++++++----------------------
 src/users/user-password.c |    8 ++++--
 src/users/user-settings.c |   16 +++++++++++++++
 src/users/user-settings.h |    1 +
 4 files changed, 46 insertions(+), 27 deletions(-)
---
diff --git a/interfaces/users.ui b/interfaces/users.ui
index 9f5b95d..5a142f4 100644
--- a/interfaces/users.ui
+++ b/interfaces/users.ui
@@ -152,8 +152,8 @@
           <object class="GtkTable" id="table1">
             <property name="visible">True</property>
             <property name="n_rows">5</property>
-            <property name="n_columns">3</property>
-            <property name="column_spacing">24</property>
+            <property name="n_columns">4</property>
+            <property name="column_spacing">12</property>
             <property name="row_spacing">12</property>
             <child>
               <object class="GtkImage" id="user_settings_face">
@@ -196,8 +196,8 @@
                 <signal name="clicked" handler="on_edit_user_name"/>
               </object>
               <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
                 <property name="x_options"></property>
                 <property name="y_options"></property>
               </packing>
@@ -214,7 +214,7 @@
               </object>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
+                <property name="right_attach">3</property>
                 <property name="y_options">GTK_FILL</property>
               </packing>
             </child>
@@ -243,7 +243,7 @@
               </object>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
+                <property name="right_attach">3</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
                 <property name="y_options">GTK_FILL</property>
@@ -260,8 +260,8 @@
                 <signal name="clicked" handler="on_edit_user_passwd"/>
               </object>
               <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
                 <property name="x_options"></property>
@@ -279,7 +279,7 @@
               </object>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
+                <property name="right_attach">3</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
                 <property name="y_options">GTK_FILL</property>
@@ -296,8 +296,8 @@
                 <signal name="clicked" handler="on_edit_user_profile"/>
               </object>
               <packing>
-                <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
+                <property name="left_attach">3</property>
+                <property name="right_attach">4</property>
                 <property name="top_attach">1</property>
                 <property name="bottom_attach">2</property>
                 <property name="x_options"></property>
@@ -305,6 +305,16 @@
               </packing>
             </child>
             <child>
+              <object class="GtkLabel" id="label5">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="right_attach">4</property>
+                <property name="top_attach">3</property>
+                <property name="bottom_attach">4</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkButton" id="edit_user_advanced_button">
                 <property name="label" translatable="yes">_Advanced Settings</property>
                 <property name="visible">True</property>
@@ -315,7 +325,7 @@
               </object>
               <packing>
                 <property name="left_attach">2</property>
-                <property name="right_attach">3</property>
+                <property name="right_attach">4</property>
                 <property name="top_attach">4</property>
                 <property name="bottom_attach">5</property>
                 <property name="x_options"></property>
@@ -323,16 +333,6 @@
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label5">
-                <property name="visible">True</property>
-              </object>
-              <packing>
-                <property name="right_attach">3</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkButton" id="manage_groups">
                 <property name="label" translatable="yes">_Manage Groups</property>
                 <property name="visible">True</property>
@@ -3203,9 +3203,9 @@
   <object class="GtkSizeGroup" id="user_new_notice_sizegroup">
     <property name="mode">both</property>
     <widgets>
-      <widget name="user_new_login_notice"/>
-      <widget name="user_new_login_used_notice"/>
       <widget name="user_new_login_letter_notice"/>
+      <widget name="user_new_login_used_notice"/>
+      <widget name="user_new_login_notice"/>
     </widgets>
   </object>
 </interface>
diff --git a/src/users/user-password.c b/src/users/user-password.c
index 87804c8..0b698f0 100644
--- a/src/users/user-password.c
+++ b/src/users/user-password.c
@@ -34,8 +34,6 @@
 #include "passwd.h"
 
 
-#define NO_PASSWD_LOGIN_GROUP "nopasswdlogin"
-
 extern GstTool *tool;
 
 
@@ -362,8 +360,12 @@ finish_password_change ()
 	if (no_passwd_login_changed || !is_self) {
 		/* commit both user and groups config
 		 * because of the no_passwd_login_group membership */
-		if (gst_tool_commit (tool, OOBS_OBJECT (user)) == OOBS_RESULT_OK)
+		if (gst_tool_commit (tool, OOBS_OBJECT (user)) == OOBS_RESULT_OK) {
 			gst_tool_commit (tool, GST_USERS_TOOL (tool)->groups_config);
+
+			/* Update settings shown in the main dialog */
+			user_settings_show (user);
+		}
 	}
 
 	gst_dialog_remove_edit_dialog (tool->main_dialog, GTK_WIDGET (user_passwd_dialog));
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index bce264b..c527e6c 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -289,8 +289,11 @@ user_settings_show (OobsUser *user)
 	GtkWidget *face_image;
 	GtkWidget *profile_label;
 	GtkWidget *profile_button;
+	GtkWidget *passwd_label;
 	GdkPixbuf *face;
 	GstUserProfile *profile;
+	OobsGroupsConfig *groups_config;
+	OobsGroup *group;
 
 	name_label = gst_dialog_get_widget (tool->main_dialog, "user_settings_real_name");
 	gtk_label_set_text (GTK_LABEL (name_label), oobs_user_get_full_name (user));
@@ -313,6 +316,19 @@ user_settings_show (OobsUser *user)
 		gtk_label_set_text (GTK_LABEL (profile_label),
 		                    profile ? profile->name : _("Custom"));
 	}
+
+	passwd_label = gst_dialog_get_widget (tool->main_dialog, "user_settings_passwd");
+	groups_config = OOBS_GROUPS_CONFIG (GST_USERS_TOOL (tool)->groups_config);
+	group = oobs_groups_config_get_from_name (groups_config, NO_PASSWD_LOGIN_GROUP);
+
+	if (oobs_user_get_password_empty (user))
+		/* TRANSLATORS: This applies to a password. */
+		gtk_label_set_text (GTK_LABEL (passwd_label), _("None"));
+	else if (oobs_user_is_in_group (user, group))
+		/* TRANSLATORS:  This applies to a password. Keep the string short. */
+		gtk_label_set_text (GTK_LABEL (passwd_label), _("Not asked on login"));
+	else
+		gtk_label_set_text (GTK_LABEL (passwd_label), _("Asked on login"));
 }
 
 static void
diff --git a/src/users/user-settings.h b/src/users/user-settings.h
index 4d22b59..a252734 100644
--- a/src/users/user-settings.h
+++ b/src/users/user-settings.h
@@ -30,6 +30,7 @@
 #include "user-profiles.h"
 
 #define ADMIN_GROUP "admin"
+#define NO_PASSWD_LOGIN_GROUP "nopasswdlogin"
 
 gboolean        user_delete                      (GtkTreeModel *model,
 						  GtkTreePath *path);



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