[gnome-control-center] user-panel: add UmPasswordDialogMode enum instead of using numeric literals



commit db97299e74e2e4c29f700de45e711cdd3fa01744
Author: Ray Strode <rstrode redhat com>
Date:   Thu Jan 3 11:30:13 2013 -0500

    user-panel: add UmPasswordDialogMode enum instead of using numeric literals
    
    The um-password-dialog combobox has a column in its model associated
    with what password action to apply. Possible actions are:
    
    - Normal password
    - Set password at next login
    - No password needed
    - Lock account
    - Unlock account
    
    These actions are currently represented in the code with harded coded
    numeric values (0-4).
    
    This commit cleans up the hard coding to use a symbolic enumeration
    instead.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671858

 panels/user-accounts/um-password-dialog.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/panels/user-accounts/um-password-dialog.c b/panels/user-accounts/um-password-dialog.c
index d2984b8..78ba352 100644
--- a/panels/user-accounts/um-password-dialog.c
+++ b/panels/user-accounts/um-password-dialog.c
@@ -60,6 +60,14 @@ struct _UmPasswordDialog {
         PasswdHandler *passwd_handler;
 };
 
+typedef enum {
+        UM_PASSWORD_DIALOG_MODE_NORMAL = 0,
+        UM_PASSWORD_DIALOG_MODE_SET_AT_LOGIN,
+        UM_PASSWORD_DIALOG_MODE_NO_PASSWORD,
+        UM_PASSWORD_DIALOG_MODE_LOCK_ACCOUNT,
+        UM_PASSWORD_DIALOG_MODE_UNLOCK_ACCOUNT
+} UmPasswordDialogMode;
+
 static void
 generate_one_password (GtkWidget        *widget,
                        UmPasswordDialog *um)
@@ -197,7 +205,7 @@ accept_password_dialog (GtkButton        *button,
         password = gtk_entry_get_text (GTK_ENTRY (um->password_entry));
         hint = gtk_entry_get_text (GTK_ENTRY (um->normal_hint_entry));
 
-        if (mode == 0 && um_user_get_uid (um->user) == getuid ()) {
+        if (mode == UM_PASSWORD_DIALOG_MODE_NORMAL && um_user_get_uid (um->user) == getuid ()) {
                 GdkDisplay *display;
                 GdkCursor *cursor;
 
@@ -621,10 +629,10 @@ visible_func (GtkTreeModel     *model,
 
                 gtk_tree_model_get (model, iter, 1, &mode, -1);
 
-                if (mode == 3 && locked)
+                if (mode == UM_PASSWORD_DIALOG_MODE_LOCK_ACCOUNT && locked)
                         return FALSE;
 
-                if (mode == 4 && !locked)
+                if (mode == UM_PASSWORD_DIALOG_MODE_UNLOCK_ACCOUNT && !locked)
                         return FALSE;
 
                 return TRUE;



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