void um_password_dialog_set_user (UmPasswordDialog *um, UmUser *user) { GdkPixbuf *pixbuf; GtkTreeModel *model; if (um->user) { g_object_unref (um->user); um->user = NULL; } if (user) { um->user = g_object_ref (user); um->using_ecryptfs = is_using_ecryptfs (um_user_get_user_name (user)); pixbuf = um_user_render_icon (user, FALSE, 48); gtk_image_set_from_pixbuf (GTK_IMAGE (um->user_icon), pixbuf); g_object_unref (pixbuf); gtk_label_set_label (GTK_LABEL (um->user_name), um_user_get_real_name (user)); gtk_entry_set_text (GTK_ENTRY (um->password_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->verify_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->normal_hint_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->old_password_entry), ""); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (um->show_password_button), FALSE); if (um_user_get_uid (um->user) == getuid()) { gtk_widget_show (um->old_password_label); gtk_widget_show (um->old_password_entry); if (um->passwd_handler != NULL) passwd_destroy (um->passwd_handler); um->passwd_handler = passwd_init (); um->old_password_ok = FALSE; } else { gtk_widget_hide (um->old_password_label); gtk_widget_hide (um->old_password_entry); um->old_password_ok = TRUE; } } model = gtk_combo_box_get_model (GTK_COMBO_BOX (um->action_combo)); if (!GTK_IS_TREE_MODEL_FILTER (model)) { model = gtk_tree_model_filter_new (model, NULL); gtk_combo_box_set_model (GTK_COMBO_BOX (um->action_combo), model); gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model), (GtkTreeModelFilterVisibleFunc) visible_func, um, NULL); } gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (model)); gtk_combo_box_set_active (GTK_COMBO_BOX (um->action_combo), 0); }
void um_password_dialog_free (UmPasswordDialog *um) { gtk_widget_destroy (um->dialog); if (um->user) g_object_unref (um->user); if (um->passwd_handler) passwd_destroy (um->passwd_handler); g_free (um); }
void um_password_dialog_set_user (UmPasswordDialog *um, ActUser *user) { gboolean visible; if (um->user) { g_object_unref (um->user); um->user = NULL; } if (user) { um->user = g_object_ref (user); gtk_entry_set_text (GTK_ENTRY (um->password_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->verify_entry), ""); gtk_entry_set_text (GTK_ENTRY (um->old_password_entry), ""); gtk_entry_set_visibility (GTK_ENTRY (um->password_entry), FALSE); gtk_entry_set_visibility (GTK_ENTRY (um->verify_entry), FALSE); if (act_user_get_uid (um->user) == getuid ()) { mode_change (um, ACT_USER_PASSWORD_MODE_REGULAR); gtk_widget_hide (um->action_radio_box); visible = (act_user_get_password_mode (user) != ACT_USER_PASSWORD_MODE_NONE); gtk_widget_set_visible (um->old_password_label, visible); gtk_widget_set_visible (um->old_password_entry, visible); um->old_password_ok = !visible; } else { mode_change (um, ACT_USER_PASSWORD_MODE_SET_AT_LOGIN); gtk_widget_show (um->action_radio_box); gtk_widget_hide (um->old_password_label); gtk_widget_hide (um->old_password_entry); um->old_password_ok = TRUE; } if (act_user_get_uid (um->user) == getuid()) { if (um->passwd_handler != NULL) passwd_destroy (um->passwd_handler); um->passwd_handler = passwd_init (); } } }
void um_password_dialog_free (UmPasswordDialog *um) { gtk_widget_destroy (um->dialog); g_clear_object (&um->user); if (um->passwd_handler) passwd_destroy (um->passwd_handler); if (um->old_password_entry_timeout_id != 0) { g_source_remove (um->old_password_entry_timeout_id); um->old_password_entry_timeout_id = 0; } if (um->password_entry_timeout_id != 0) { g_source_remove (um->password_entry_timeout_id); um->password_entry_timeout_id = 0; } g_free (um); }