[libhandy] keypad: Allow pasting and erasing text in the entry
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] keypad: Allow pasting and erasing text in the entry
- Date: Thu, 7 Jan 2021 09:29:53 +0000 (UTC)
commit 4244b080a836d24f5ce1b670faed6b92312ca09f
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Dec 27 18:49:43 2020 +0500
keypad: Allow pasting and erasing text in the entry
Stop assuming that input is going to be 1 char only, instead allow it if
all characters are valid. Take care to handle unicode correctly.
Fixes https://gitlab.gnome.org/GNOME/libhandy/-/issues/394
src/hdy-keypad.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/hdy-keypad.c b/src/hdy-keypad.c
index 17a8e3f8..90f896ee 100644
--- a/src/hdy-keypad.c
+++ b/src/hdy-keypad.c
@@ -108,16 +108,25 @@ insert_text_cb (HdyKeypad *self,
GtkEditable *editable)
{
HdyKeypadPrivate *priv = hdy_keypad_get_instance_private (self);
+ gchar *p = text;
- g_assert (length == 1);
+ g_assert (g_utf8_validate (text, length, NULL));
- if (g_ascii_isdigit (*text))
- return;
+ while (p != text + length) {
+ gchar *q = p;
- if (priv->symbols_visible && strchr ("#*+", *text))
- return;
+ p = g_utf8_next_char (p);
- g_signal_stop_emission_by_name (editable, "insert-text");
+ if (g_ascii_isdigit (*q))
+ continue;
+
+ if (priv->symbols_visible && strchr ("#*+", *q))
+ continue;
+
+ g_signal_stop_emission_by_name (editable, "insert-text");
+
+ return;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]