summaryrefslogtreecommitdiffstats
path: root/perl-install/interactive
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/interactive')
-rw-r--r--perl-install/interactive/gtk.pm21
1 files changed, 20 insertions, 1 deletions
diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm
index 4a93934e1..e6ad4aaff 100644
--- a/perl-install/interactive/gtk.pm
+++ b/perl-install/interactive/gtk.pm
@@ -545,7 +545,14 @@ sub create_widget {
};
} else {
$w = Gtk2::Entry->new;
- $w->signal_connect(changed => $onchange->(sub { $w->get_text }));
+ $w->signal_connect(changed => $onchange->(sub {
+ if ($e->{weakness_check}) {
+ require authentication;
+ my $password_weakness = authentication::compute_password_weakness($w->get_text);
+ $w->modify_base('GTK_STATE_NORMAL', get_weakness_color($password_weakness));
+ }
+ $w->get_text;
+ }));
$w->signal_connect(focus_in_event => sub { $w->select_region(0, -1) });
$w->signal_connect(focus_out_event => sub { $w->select_region(0, 0) });
$set = sub { $w->set_text($_[0]) if $_[0] ne $w->get_text };
@@ -958,4 +965,16 @@ sub kill {
@tempory::objects = ();
}
+sub get_weakness_color {
+ my ($password_weakness) = @_;
+ my %weakness_color = (
+ 1 => '#fd3434',
+ 2 => '#fd6c34',
+ 3 => '#f7871a',
+ 4 => '#2ae000',
+ 5 => '#30ff00');
+ my $weakness_color = $weakness_color{$password_weakness} || '#ffffff';
+ Gtk2::Gdk::Color->parse($weakness_color);
+}
+
1;