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 @@ -14,7 +14,7 @@ You'll need the following dependencies:
* libgranite-7-dev >= 7.4.0
* libaccountsservice-dev
* libgnomekbd-dev
* libgtk-4-dev
* libgtk-4-dev >=4.14
* libadwaita-1-dev >= 1.4
* libjson-glib-dev
* libpantheon-wayland-1-dev
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gee_dep = dependency('gee-0.8')
glib_dep = dependency('glib-2.0', version: '>=2.74')
gobject_dep = dependency('gobject-2.0')
granite_dep = dependency('granite-7', version: '>=7.4.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')
adw_dep = dependency('libadwaita-1', version: '>=1.4.0')
Expand Down
30 changes: 30 additions & 0 deletions src/Views/AccountView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class Installer.AccountView : AbstractInstallerView {
private Gtk.LevelBar pw_levelbar;
private Granite.ValidatedEntry hostname_entry;

private uint announce_timeout_id;

construct {
var avatar = new Adw.Avatar (104, null, true) {
margin_top = 12,
Expand Down Expand Up @@ -102,6 +104,7 @@ public class Installer.AccountView : AbstractInstallerView {
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
Expand Down Expand Up @@ -227,13 +230,23 @@ public class Installer.AccountView : 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 @@ -246,8 +259,11 @@ public class Installer.AccountView : 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 @@ -257,6 +273,19 @@ public class Installer.AccountView : 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 bool check_username () {
string username_entry_text = username_entry.text;
bool username_is_valid = is_valid_username (username_entry_text);
Expand All @@ -275,6 +304,7 @@ public class Installer.AccountView : AbstractInstallerView {
}

username_error_revealer.reveal_child = true;
queue_announce (username_entry, username_error_revealer.label);
}

return false;
Expand Down