static void accept_password_dialog (GtkButton *button, UmPasswordDialog *um) { const gchar *password; password = gtk_entry_get_text (GTK_ENTRY (um->password_entry)); switch (um->password_mode) { act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_REGULAR); case ACT_USER_PASSWORD_MODE_REGULAR: if (act_user_get_uid (um->user) == getuid ()) { GdkDisplay *display; GdkCursor *cursor; /* When setting a password for the current user, * use passwd directly, to preserve the audit trail * and to e.g. update the keyring password. */ passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um); gtk_widget_set_sensitive (um->dialog, FALSE); display = gtk_widget_get_display (um->dialog); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor); gdk_display_flush (display); g_object_unref (cursor); return; } act_user_set_password (um->user, password, ""); break; case ACT_USER_PASSWORD_MODE_SET_AT_LOGIN: act_user_set_password_mode (um->user, um->password_mode); act_user_set_automatic_login (um->user, FALSE); break; default: g_assert_not_reached (); } finish_password_change (um); }
static void accept_password_dialog (GtkButton *button, UmPasswordDialog *um) { GtkTreeModel *model; GtkTreeIter iter; gint mode; const gchar *hint; const gchar *password; model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo)); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->action_combo), &iter); gtk_tree_model_get (model, &iter, 1, &mode, -1); 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 ()) { GdkDisplay *display; GdkCursor *cursor; /* When setting a password for the current user, * use passwd directly, to preserve the audit trail * and to e.g. update the keyring password. */ passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um); gtk_widget_set_sensitive (um->dialog, FALSE); display = gtk_widget_get_display (um->dialog); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor); gdk_display_flush (display); g_object_unref (cursor); } else { um_user_set_password (um->user, mode, password, hint); finish_password_change (um); } }
static void accept_password_dialog (GtkButton *button, UmPasswordDialog *um) { GtkTreeModel *model; GtkTreeIter iter; gint mode; const gchar *hint; const gchar *password; model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo)); gtk_combo_box_get_active_iter (GTK_COMBO_BOX (um->action_combo), &iter); gtk_tree_model_get (model, &iter, 1, &mode, -1); password = gtk_entry_get_text (GTK_ENTRY (um->password_entry)); hint = NULL; switch (mode) { case UM_PASSWORD_DIALOG_MODE_NORMAL: if (act_user_get_uid (um->user) == getuid ()) { GdkDisplay *display; GdkCursor *cursor; /* When setting a password for the current user, * use passwd directly, to preserve the audit trail * and to e.g. update the keyring password. */ passwd_change_password (um->passwd_handler, password, (PasswdCallback) password_changed_cb, um); gtk_widget_set_sensitive (um->dialog, FALSE); display = gtk_widget_get_display (um->dialog); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); gdk_window_set_cursor (gtk_widget_get_window (um->dialog), cursor); gdk_display_flush (display); g_object_unref (cursor); return; } act_user_set_password (um->user, password, hint); break; case UM_PASSWORD_DIALOG_MODE_SET_AT_LOGIN: act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_SET_AT_LOGIN); break; case UM_PASSWORD_DIALOG_MODE_NO_PASSWORD: act_user_set_password_mode (um->user, ACT_USER_PASSWORD_MODE_NONE); break; case UM_PASSWORD_DIALOG_MODE_LOCK_ACCOUNT: act_user_set_locked (um->user, TRUE); break; case UM_PASSWORD_DIALOG_MODE_UNLOCK_ACCOUNT: act_user_set_locked (um->user, FALSE); break; default: g_assert_not_reached (); } finish_password_change (um); }