[gtk/peek-password] Add a default implementation of strength
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/peek-password] Add a default implementation of strength
- Date: Thu, 14 Mar 2019 21:47:38 +0000 (UTC)
commit 13edad81a798ae809cc192e8ff93487111a42972
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 a5e9343418..6c5c337005 100644
--- a/gtk/gtkpasswordentry.c
+++ b/gtk/gtkpasswordentry.c
@@ -537,10 +537,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]