summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-03-14 01:20:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-03-14 20:44:06 -0400
commitde9e31c028e8c2799b15d0db9aca02dbcc1c75d9 (patch)
treedaedb78c762c09fc55938e26099b2eb1e578fb89
parentd3d65e9148b10319e7c32b505e7039ae3d308b76 (diff)
downloadgtk+-peek-password.tar.gz
Add a default implementation of strengthpeek-password
This is too simple to be useful, but its a start.
-rw-r--r--gtk/gtkpasswordentry.c9
1 files changed, 8 insertions, 1 deletions
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);
}