I want to make a Gtk.Entry field that can only accept numbers. Is that what GtkInputPurpose is for? The docs say:
Note that the purpose is not meant to impose a totally strict rule about allowed characters, and does not replace input validation.
I’m willing to still do the validation. I just want to give the user quicker feedback on what characters are allowed. This is similar to HTML’s <input type="number">.
I see that in this topic, someone is doing this manually by listening to the onInsertText signal. Is this the only way to do it or does GTK offer this as a built-in feature, via GtkInputPurpose or something else?
No, GTK does not provide validation out of the box. You’re supposed to perform validation every time the text changes—usually by connecting to the notify::text signal.