Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You'll need the following dependencies:
- gparted
- libgnomekbd-dev
- libgranite-7-dev >=7.4.0
- libgtk-4-dev
- libgtk-4-dev >=4.14
- libgee-0.8-dev
- libadwaita-1-dev >=1.4.0
- libjson-glib-dev
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ i18n = import('i18n')

glib_dep = dependency('glib-2.0', version: '>=2.74')
gobject_dep = dependency('gobject-2.0')
gtk_dep = dependency('gtk4')
gtk_dep = dependency('gtk4', version: '>=4.14') # Gtk.Accessible.announce
gtk_wayland_dep = dependency('gtk4-wayland')
gtk_x11_dep = dependency('gtk4-x11')
gee_dep = dependency('gee-0.8')
Expand Down
44 changes: 38 additions & 6 deletions src/Views/EncryptView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class EncryptView : AbstractInstallerView {

private const string SKIP_STRING = _("Don’t Encrypt");

private uint announce_timeout_id;

public EncryptView () {
Object (cancellable: true);
}
Expand Down Expand Up @@ -70,27 +72,31 @@ public class EncryptView : AbstractInstallerView {
"slate"
);

var pw_label = new Granite.HeaderLabel (_("Encryption Password")) {
secondary_text = _("A unique password for this device; not the password for your user account.")
};

pw_error_revealer = new ErrorRevealer (".");
pw_error_revealer.label_widget.add_css_class (Granite.STYLE_CLASS_WARNING);

pw_entry = new ValidatedEntry ();

var pw_label = new Granite.HeaderLabel (_("Encryption Password")) {
mnemonic_widget = pw_entry,
secondary_text = _("A unique password for this device, not the password for your user account.")
};

pw_levelbar = new Gtk.LevelBar.for_interval (0.0, 100.0);
pw_levelbar.set_mode (Gtk.LevelBarMode.CONTINUOUS);
pw_levelbar.add_offset_value ("low", 50.0);
pw_levelbar.add_offset_value ("high", 75.0);
pw_levelbar.add_offset_value ("middle", 75.0);

var confirm_label = new Granite.HeaderLabel (_("Confirm Password"));

confirm_entry = new Granite.ValidatedEntry () {
sensitive = false,
visibility = false
};
confirm_entry.update_property (Gtk.AccessibleProperty.REQUIRED, true, -1);

var confirm_label = new Granite.HeaderLabel (_("Confirm Password")) {
mnemonic_widget = confirm_entry
};

confirm_entry_revealer = new ErrorRevealer (".");
confirm_entry_revealer.label_widget.add_css_class (Granite.STYLE_CLASS_ERROR);
Expand Down Expand Up @@ -171,13 +177,23 @@ public class EncryptView : AbstractInstallerView {
pw_error_revealer.reveal_child = false;

pw_levelbar.value = quality;

if (quality <= 50) {
queue_announce (pw_entry, _("Acceptable password"));
} else if (quality <= 75) {
queue_announce (pw_entry, _("Good password"));
} else {
queue_announce (pw_entry, _("Great password"));
}
} else {
pw_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "dialog-warning-symbolic");

pw_error_revealer.reveal_child = true;
pw_error_revealer.label = ((PasswordQuality.Error) quality).to_string (error);

pw_levelbar.value = 0;

queue_announce (pw_entry, pw_error_revealer.label);
}
return true;
}
Expand All @@ -190,8 +206,11 @@ public class EncryptView : AbstractInstallerView {
if (pw_entry.text != confirm_entry.text) {
confirm_entry_revealer.label = _("Passwords do not match");
confirm_entry_revealer.reveal_child = true;

queue_announce (confirm_entry, confirm_entry_revealer.label);
} else {
confirm_entry_revealer.reveal_child = false;
queue_announce (confirm_entry, _("Passwords match"));
return true;
}
} else {
Expand All @@ -201,6 +220,19 @@ public class EncryptView : AbstractInstallerView {
return false;
}

private void queue_announce (Gtk.Entry entry, string announcement) {
if (announce_timeout_id != 0) {
Source.remove (announce_timeout_id);
announce_timeout_id = 0;
}

announce_timeout_id = Timeout.add (500, () => {
entry.announce (announcement, MEDIUM);
announce_timeout_id = 0;
return GLib.Source.REMOVE;
});
}

private void update_next_button () {
if (pw_entry.is_valid && confirm_entry.is_valid) {
encrypt_button.sensitive = true;
Expand Down