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
This commit is contained in:
Ray Strode 2013-01-03 11:30:13 -05:00
parent f9584966d8
commit db97299e74

View file

@ -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;