After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 446056 - allow filtering GtkEntry input with regular expressions
allow filtering GtkEntry input with regular expressions
Status: RESOLVED DUPLICATE of bug 50276
Product: gtk+
Classification: Platform
Component: Widget: GtkEntry
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on: 445065
Blocks:
 
 
Reported: 2007-06-10 15:44 UTC by Carlos Garnacho
Modified: 2011-02-23 01:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to add regexp-based filtering (10.80 KB, patch)
2007-06-10 15:46 UTC, Carlos Garnacho
none Details | Review
test application (812 bytes, text/x-csrc)
2007-06-10 15:50 UTC, Carlos Garnacho
  Details

Description Carlos Garnacho 2007-06-10 15:44:28 UTC
Hi!,

I'm attaching a patch to make GtkEntry able to filter text input based on a GRegex
Comment 1 Carlos Garnacho 2007-06-10 15:46:43 UTC
Created attachment 89697 [details] [review]
patch to add regexp-based filtering
Comment 2 Carlos Garnacho 2007-06-10 15:50:34 UTC
Created attachment 89699 [details]
test application

It only allows to enter IPv4 addresses in the entry
Comment 3 Behdad Esfahbod 2007-06-11 02:37:13 UTC
Like the feature.  Thanks for implementing it.  Though can you explain a bit how it works?  What happens if, say, you try to edit the text content in the middle as opposed to the end?
Comment 4 Carlos Garnacho 2007-06-11 11:54:10 UTC
I've used g_match_info_is_partial_match() to implement the feature, so any edition to the entry that leaves a partial match is allowed, but when there is no possibility of matching the regex pattern, no edition happens and gtk_widget_error_bell() is called.

So, for example, given you have the pattern "^(\d){1,3}[a-z](\d){1,3}$" and the "123a4" text (which matches the regex):

- deleting "a4" gives you a partial match
- deleting "23" still gives you a match
- deleting "a" won't be allowed, as "1234" doesn't match the pattern
- deleting "3a" gives you a partial match
Comment 5 Johan (not receiving bugmail) Dahlin 2011-02-23 01:30:13 UTC

*** This bug has been marked as a duplicate of bug 50276 ***