[gtk/peek-password: 14/14] Add a default implementation of strength
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/peek-password: 14/14] Add a default implementation of strength
- Date: Fri, 15 Mar 2019 00:44:52 +0000 (UTC)
commit de9e31c028e8c2799b15d0db9aca02dbcc1c75d9
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Mar 14 01:20:43 2019 -0400
Add a default implementation of strength
This is too simple to be useful, but its a start.
gtk/gtkpasswordentry.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkpasswordentry.c b/gtk/gtkpasswordentry.c
index 433eeb4c9f..bfb025fc33 100644
--- a/gtk/gtkpasswordentry.c
+++ b/gtk/gtkpasswordentry.c
@@ -558,10 +558,17 @@ update_strength (GObject *object,
{
GtkPasswordEntryPrivate *priv = gtk_password_entry_get_instance_private (entry);
- int strength = 0;
+ int strength = -1;
g_signal_emit (entry, signals[GET_STRENGTH], 0, &strength);
+ if (strength == -1)
+ {
+ const char *text = gtk_editable_get_text (GTK_EDITABLE (priv->entry));
+
+ strength = CLAMP (0, 100, 10 * g_utf8_strlen (text, -1));
+ }
+
gtk_level_bar_set_value (GTK_LEVEL_BAR (priv->strength_widget), strength);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]