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 651244 - Add a "purpose" tag for GtkEntries
Add a "purpose" tag for GtkEntries
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
3.0.x
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 612662
 
 
Reported: 2011-05-27 13:18 UTC by Bastien Nocera
Modified: 2012-12-03 10:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Tentative patch for input mode. (10.59 KB, patch)
2011-11-18 16:01 UTC, Krzesimir Nowak
reviewed Details | Review
Tentative patch for input mode, v2. (11.38 KB, patch)
2011-11-21 10:35 UTC, Krzesimir Nowak
none Details | Review
Tentative patch for input mode, v3. (11.46 KB, patch)
2011-12-03 12:31 UTC, Krzesimir Nowak
reviewed Details | Review
Tentative patch for input mode, v4. (2.70 KB, patch)
2012-05-29 15:15 UTC, Krzesimir Nowak
none Details | Review
enums: Add purpose enum and hints flags. (4.10 KB, patch)
2012-08-16 18:36 UTC, Matthias Clasen
committed Details | Review
GtkIMContext: Add purpose and hints (5.09 KB, patch)
2012-08-16 18:37 UTC, Matthias Clasen
committed Details | Review
GtkEntry: Add input purpose and hints (6.57 KB, patch)
2012-08-16 18:37 UTC, Matthias Clasen
committed Details | Review
GtkTextView: Add input purpose and hints (7.61 KB, patch)
2012-08-16 18:37 UTC, Matthias Clasen
committed Details | Review
Add documentation (8.48 KB, patch)
2012-08-16 18:37 UTC, Matthias Clasen
committed Details | Review
patch, add GTK_INPUT_HINT_INHIBIT (1.33 KB, patch)
2012-08-24 18:53 UTC, Carlos Garnacho
needs-work Details | Review

Description Bastien Nocera 2011-05-27 13:18:57 UTC
So that the on-screen keyboard can display things appropriately, GtkEntry should have a hint as to what the purpose of the entry is, possibly adding a new mode. For example:
- numeric-only entry
- URL entry
- free-form text entry

iOS has a larger list [1]:
typedef enum {
   UIKeyboardTypeDefault,
   UIKeyboardTypeASCIICapable,
   UIKeyboardTypeNumbersAndPunctuation,
   UIKeyboardTypeURL,
   UIKeyboardTypeNumberPad,
   UIKeyboardTypePhonePad,
   UIKeyboardTypeNamePhonePad,
   UIKeyboardTypeEmailAddress,
   UIKeyboardTypeDecimalPad,
   UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
} UIKeyboardType;

[1]: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITextInputTraits_Protocol/Reference/UITextInputTraits.html#//apple_ref/doc/uid/TP40006896-CH3-SW22
Comment 1 Christian Dywan 2011-05-27 13:26:02 UTC
See also HildonGtkInputMode:

 http://maemo.gitorious.org/hildon/gtk/blobs/master/gtk/gtkenums.h#line559
Comment 2 Dan Winship 2011-05-27 13:43:58 UTC
Having the "don't spellcheck" flag (UITextAutocorrectionTypeNo) is also important, eg, for entering usernames. (No, I didn't mean "dawn".)

(There's no plan to implement inline spelling checking for 3.2, but if we're going to get people tagging their entries, we should define all the tags/flags now.)
Comment 3 Bastien Nocera 2011-05-27 13:50:36 UTC
As you can see in the linked API docs, there are more types (auto-correction type, auto-capitalisation, the name of the return key, etc.).
Comment 4 Bastien Nocera 2011-05-27 13:55:41 UTC
Android's equivalent:
http://developer.android.com/reference/android/text/InputType.html
Comment 5 Bastien Nocera 2011-05-27 14:09:15 UTC
InputScope for Windows Phone:
http://msdn.microsoft.com/en-us/library/ms538181(VS.85).aspx
Comment 6 Matthias Clasen 2011-05-28 23:20:34 UTC
Needs a concrete api proposal. It should answer a few questions, such as
- How will the entry 'mode' be made known to the OSK ?
- Will the mode affect any behaviours of GtkEntry itself ?
Comment 7 Dan Winship 2011-05-31 20:55:25 UTC
(In reply to comment #6)
> Needs a concrete api proposal.

Yes. I was figuring that we'd play around with the corresponding API in StEntry first, and then propose gtk API once we had more idea what we wanted.

> - How will the entry 'mode' be made known to the OSK ?

Current vague theory: we should expose the entry mode to the input method (since it would be useful to some IMs too), and we should expose the input method information to the OSK (since in addition to wanting to know the entry mode, the OSK may want to know where on the screen the cursor is too).

Not sure what the best way to do that is. Should the OSK hook itself in as a Gtk IM somehow? Or should gtk broadcast the information in a way that the OSK can find? (Eg, additional properties on the _NET_WM_USER_TIME_WINDOW.)
Comment 8 Benjamin Otte (Company) 2011-10-08 08:48:28 UTC
There's a bunch of things we could do with this information inside GtkEntry:
- provide correctness information next to the entry (think a warning icon if the email/url is wrong)
- provide validation (to make forms code easier to write)
- provide hilighting (think URLs in Chrome)
- provide additional clues to accessibility ("please enter a valid email address")
- and from a11y there to the OSK?

That of course leads to the question if part of that information is also useful in cell renderers or labels (in particular hilighting) and if it's useful to hook other machinery into it (email entries could automatically be hooked up into an entry completion feeding from my address book) and if it should be possible to extend it (in particular to provide hilighting or an abstraction for autocomplete in complex libraries/applications.

That said, we can probably start with an enum and go from there. :)

PS: Should "password" be a part of this enum or should the boolean toggle for "display as password" keep being a separate thing?
Comment 9 Benjamin Otte (Company) 2011-10-08 08:55:26 UTC
Oh, and there's of course HTML 5:

http://dev.w3.org/html5/spec/Overview.html#attr-input-type

which is way more exhaustive than all the options here. It also contains a bunch of things that GTK only ships buttons for.
Comment 10 Dan Winship 2011-10-08 15:55:51 UTC
(In reply to comment #8)
> - and from a11y there to the OSK?

The OSK currently works via a gtkmodule that snoops focus and works with gtkwidgets directly. So it can just read the property directly off the GtkEntry.
Comment 11 Murray Cumming 2011-11-09 11:49:30 UTC
Dan, are you actually working on this?
Comment 12 Dan Winship 2011-11-09 13:18:39 UTC
no, afaik no one is actively working on this
Comment 13 Jon Nordby 2011-11-11 10:03:18 UTC
(In reply to comment #10)
> (In reply to comment #8)
> > - and from a11y there to the OSK?
> 
> The OSK currently works via a gtkmodule that snoops focus and works with
> gtkwidgets directly. So it can just read the property directly off the
> GtkEntry.

What do you mean, does it not use GtkIMContext? Do you have a link to the code?
Comment 14 Murray Cumming 2011-11-11 11:43:13 UTC
> What do you mean, does it not use GtkIMContext? Do you have a link to the code?

Here is the code, though I'm not sure how it works:
http://git.gnome.org/browse/caribou/tree/modules/gtk3/caribou-gtk-module.vala
(Thanks to Jan Arne Petersen for finding that.)

Surely a sane on-screen keyboard (or other input method) would use the GTK+ input method system, so I guess we'll also need some way for GtkIMContext modules to get the widget, or at least get this information about the widget.
Comment 15 Murray Cumming 2011-11-11 12:03:44 UTC
(In reply to comment #14)
> I guess we'll also need some way for GtkIMContext
> modules to get the widget, or at least get this information about the widget.

Maemo Fremantle had a GTK+ patch to add this:
  http://maemo.org/api_refs/5.0/beta/gtk/GtkIMContext.html#GtkIMContext--hildon-input-default
and that should be somewhere here:
  https://maemo.gitorious.org/hildon/gtk/
Comment 16 Dan Winship 2011-11-11 15:22:22 UTC
(In reply to comment #14)
> Here is the code, though I'm not sure how it works:
> http://git.gnome.org/browse/caribou/tree/modules/gtk3/caribou-gtk-module.vala

Caribou installs a file that tells gnome-settings-daemon to load this gtk module when the on-screen-keyboard gsettings key is enabled. The module installs a gdk event filter to snoop on events and figure out what the currently-focused widget is.

(The original plan was for the module to use Atk interfaces to snoop on the focus, rather than using a gdk event filter, but this doesn't currently work in gtk3 because of bug 655828.)

> Surely a sane on-screen keyboard (or other input method) would use the GTK+
> input method system

Yes, it was originally an input method. We switched because:

  a) g-s-d already had the infrastructure to load arbitrary gtkmodules based
     on gsettings; it was more complicated to get it to override the choice
     of IM module

  b) it would in theory be possible to use both the shell OSK and an input
     method, so that, eg, you could type latin characters with the OSK and
     have an IM turn them into kanji. (Obviously this would be unnecessary
     if it was possible to type kanji directly from the OSK.)
Comment 17 Murray Cumming 2011-11-15 21:51:55 UTC
(In reply to comment #16)
> Yes, it was originally an input method. We switched because:
> 
>   a) g-s-d already had the infrastructure to load arbitrary gtkmodules based
>      on gsettings; it was more complicated to get it to override the choice
>      of IM module

Is there any discussion of that somewhere? It sounds like a problem that should be solved instead of worked around so bluntly. Though I don't understand why gnome-system-daemon needs to change the IM Module any more in gnome-shell than it did before.

>   b) it would in theory be possible to use both the shell OSK and an input
>      method, so that, eg, you could type latin characters with the OSK and
>      have an IM turn them into kanji. (Obviously this would be unnecessary
>      if it was possible to type kanji directly from the OSK.)

Typing CJK characters phonetically via latin characters is very common - Pinyin and Canjii, for instance. Maliit does that  and also uses non-latin (Zhuyin/Bopomofo) phonetic input (though these need closed-source engines currently), though I don't know if it reuses the regular Meego Keyboard. But breaking out of the standard GtkIMContext system does not seem like the best way to reuse keyboard code.
Comment 18 Benjamin Otte (Company) 2011-11-15 22:12:55 UTC
(In reply to comment #17)
> (In reply to comment #16)
> > Yes, it was originally an input method. We switched because:
> > 
> >   a) g-s-d already had the infrastructure to load arbitrary gtkmodules based
> >      on gsettings; it was more complicated to get it to override the choice
> >      of IM module
> 
> Is there any discussion of that somewhere? It sounds like a problem that should
> be solved instead of worked around so bluntly. Though I don't understand why
> gnome-system-daemon needs to change the IM Module any more in gnome-shell than
> it did before.
> 
GTK modules are - like any support for arbitrary modules in any software system (see Firefox add-ons or nautilus, gedit, epiphany and soon shell extensions) - a desaster waiting to happen. If it were my decision, we'd stop supporting this craziness.
That said, I think that the Caribou approach is currently the best solution that we have.

I have no idea how XKB, a11y, IM, OSK, magic keys and regular keyboards should interact on a desktop and I doubt anyone has a clear design in mind on how to handle keyboard input properly. All solutions range somewhere from "do it in the kernel" to "do it in the toolkit". And usually you can find any combination of problem and solution out there in the wild.
Comment 19 Murray Cumming 2011-11-15 22:19:04 UTC
> I doubt anyone has a clear design in mind 

Well, the Maliit team have a great deal of experience in this field and have spent a great deal of time coming up with a framework that works. Nobody else in the open-source world seems to come close. So it would be good if some way could be found to let Maliit work in gnome-shell so that work can continue towards the perfection you maybe think still needs to be achieved.

(Yes, this bug report is getting way off track. I'll blog about this general issue tomorrow and that will be a slightly better place to discuss it.)
Comment 20 Matthias Clasen 2011-11-16 16:42:32 UTC
Patches to add use hints to GtkEntry will be welcome here, as will be thoughts on how best to expose that information to the outside world.

Please keep your push for maalit out of gtk bugzilla.
Comment 21 Murray Cumming 2011-11-16 20:25:41 UTC
(In reply to comment #20)
> Please keep your push for maalit out of gtk bugzilla.

Sorry. We just took the opportunity to learn more about how gnome-shell's keyboard works since it was brought up here. We should have a patch for the hints soon.
Comment 22 Matthias Clasen 2011-11-16 23:14:28 UTC
(In reply to comment #21)

> We should have a patch for the hints soon.

Cool, looking forward to that.
Comment 23 Krzesimir Nowak 2011-11-18 16:01:24 UTC
Created attachment 201671 [details] [review]
Tentative patch for input mode.

Attached tentative patch for input mode to check if direction is right. It is based on Hildon.
Comment 24 Matthias Clasen 2011-11-19 17:47:17 UTC
Review of attachment 201671 [details] [review]:

Documentation for what the various flags are supposed to mean would be essential, here. I have no idea what 'tele' or 'autocap' might mean, for instance.

I would have expected things like 'url', 'email address', 'phone #' to be available as hints.

I think the property should maybe be called 'input-mode-hint', since it is not actually enforcing anything, just hinting im and a11y technologies about the type of input that his expected.
Comment 25 Benjamin Otte (Company) 2011-11-19 19:45:37 UTC
(In reply to comment #24)
> I think the property should maybe be called 'input-mode-hint', since it is not
> actually enforcing anything,
>
Should it enforce things? Because naming it "hint" and then later doing validation based on it is bad. And adding a different property for validation later is bad, too...
Comment 26 Matthias Clasen 2011-11-20 20:53:57 UTC
I don't want to see code for validation of phone number formats in gtk, thats clearly application territory...
Comment 27 Krzesimir Nowak 2011-11-21 10:35:30 UTC
Created attachment 201795 [details] [review]
Tentative patch for input mode, v2.

I documented the enumeration and got rid of its two members. Also, `[-_]hints' is appended in some places.

As to have `url', `phone #' or `email address' in hints it is worth to think whether it is sensible to enumerate all possible uses of entry. I think that hints about allowed characters would be enough and application themselves should implement the purpose of entry with its validation.
Comment 28 Murray Cumming 2011-11-29 11:08:12 UTC
+ * @GTK_INPUT_MODE_ALPHA: Allow alphabetic characters
+ * @GTK_INPUT_MODE_NUMERIC: Allow numeric characters
+ * @GTK_INPUT_MODE_SPECIAL: Allow non-numeric, non-alphabetic characters.
+ * @GTK_INPUT_MODE_FULL: Allow any character
+ * @GTK_INPUT_MODE_NO_SCREEN_PLUGINS: No input mode plugins should be displayed
+ * @GTK_INPUT_MODE_MULTILINE: Edited field can hold several lines
+ * @GTK_INPUT_MODE_INVISIBLE: Edited field is hidden
+ * @GTK_INPUT_MODE_AUTOCAP: Capitalize words at the beginning of sentence
+ * @GTK_INPUT_MODE_DICTIONARY: Check for word in dictionary (spellchecking)

This is the main thing that needs to be discussed. I guess that we should start with an even smaller set that we know will be useful. So I guess we can remove:
  GTK_INPUT_MODE_NO_SCREEN_PLUGINS
because its description is vague and it is probably special-purpose.

I doubt that these need to be here, because they duplicate GTK+ API elsewhere:
  GTK_INPUT_MODE_MULTILINE: Edited field can hold several lines
  GTK_INPUT_MODE_INVISIBLE: Edited field is hidden

I also wonder why this needs to be here:
  GTK_INPUT_MODE_DICTIONARY: Check for word in dictionary (spellchecking)
Comment 29 Benjamin Otte (Company) 2011-11-29 11:27:15 UTC
So, for an email address input, we want to have dots and an @ sign in the OSK, but we don't need slashes. Would we use GTK_INPUT_MODE_SPECIAL there? What about GTK_INPUT_MODE_NUMERIC? My email has no numbers, but I know of people who do.

What about URL entries? / and . is definitely necessary to enter them, so do we want GTK_INPUT_MODE_SPECIAL? What about GTK_INPUT_MODE_NUMERIC?

Phone numbers need GTK_INPUT_MODE_NUMERIC and + and -, maybe # and *.

So I guess what I'm wondering is: Do these flags make sense for the cases we care about? Afaik the iphone and android keyboards use a regular or numeric keyboard and add a few extra keys depending on usecase. For those extra keys GTK_INPUT_MODE_SPECIAL is not fine-grained enough.
Comment 30 Jon Nordby 2011-11-29 12:56:50 UTC
(In reply to comment #28)
> I also wonder why this needs to be here:
>   GTK_INPUT_MODE_DICTIONARY: Check for word in dictionary (spellchecking)
How else will input method know if it should try to provide spell-checking or word-prediction?

An important password usecase should perhaps be explicitly supported: IM must not collect the characters typed in password fields. And why not let IM-provided spell-checking be opt-out instead of opt-in?

In general, I think content types like phone number or email should have their own flags. IM cannot know the intent of a field that has _MODE_NUMERIC + _MODE_SPECIAL, it could be phone number or it could be product numbers.

Usecases: Showing a dialing-pad for phone-number fields (a dialing-pad is typically different from something only for numbers).
Comment 31 Dan Winship 2011-11-29 16:08:05 UTC
(In reply to comment #27)
> Created an attachment (id=201795) [details] [review]
> Tentative patch for input mode, v2.

>+   * GtkEntry:input-mode:

Does GtkTextView need to implement this as well? Or is it safe to assume that all textviews are full-keyboard-and-spellcheck-please?

(In reply to comment #25)
> (In reply to comment #24)
> > I think the property should maybe be called 'input-mode-hint', since it is not
> > actually enforcing anything,
> >
> Should it enforce things?

I'd say no, because if they were enforcing, then adding a new flag later would be an ABI break against old keyboard implementations.

(In reply to comment #29)
> GTK_INPUT_MODE_SPECIAL is not fine-grained enough.

agreed

(In reply to comment #30)
> An important password usecase should perhaps be explicitly supported: IM must
> not collect the characters typed in password fields.

passwordness is already indicated by a different GtkEntry property, although yes, we should make sure that that property gets exposed to the IM as well.

> And why not let
> IM-provided spell-checking be opt-out instead of opt-in?

Assuming that the default value of the hints is going to be "0", then it depends on whether we want spellcheck/autocomplete to be on by default or not... It's basically on-by-default in iOS, but I'm not sure that that necessarily means it's the better option in existing gtk apps too.
Comment 32 Matthias Clasen 2011-11-30 04:49:43 UTC
I think more semantic hints like 'phone nr', 'email address', 'url' are going to be much more useful, and we should have them (maybe in addition to those more basic 'allow-such-and-such-chars' modes). E.g for email addresses, one could offer smart completion based on contacts.
Comment 33 Krzesimir Nowak 2011-12-03 12:31:17 UTC
Created attachment 202700 [details] [review]
Tentative patch for input mode, v3.

Added flags for phone, url and email. Removed the multiline flag for now, as this bug is about GtkEntries, not GtkTextViews - it can be added back later. Also, I was thinking about adding flags for time and date, but probably different widgets should be used for them (GtkComboBox or GtkSpinButton).
Comment 34 Matthias Clasen 2011-12-07 01:26:15 UTC
Review of attachment 202700 [details] [review]:

::: gtk/gtkenums.h
@@ +951,3 @@
+  GTK_INPUT_MODE_AUTOCAP           = 1 << 30,
+  GTK_INPUT_MODE_DICTIONARY        = 1 << 31
+} GtkInputMode;

Comparing this to some of the prior art cited in the bug, I think we could do a bit better here.

Proposals:

- Make it explicit in the docs that additions to this enumeration are possible, and state that consumers should ignore values that they don't know.

- Make it explicit which of these values are 'variations' or 'modifiers' and which are complete modes. Something like 'email|numeric' probably doesn't make sense, and the documentation should make that clear. My guess is that the following grouping makes sense:

character set restrictions: alpha/numeric/special. these can be freely combined
complete 'semantic' modes: full/phone/url/email. doesn't make sense to combine
  with character set restrictions or each other
additional behaviour hints: invisible/autocap/dictionary: these can be added to
  any of the others

- Other apis discriminate between sentence/word/character autocapitalization, so we should probably rename AUTOCAP to CAP_SENTENCE to leave room for adding more

- What is the intended semantics of DICTIONARY ? Other apis have AUTO_CORRECT - is that the intention ? Dan pointed out the importance of having a NO_AUTO_CORRECT counterpart to make entering names non-annoying. An alternative would be to add a NAME mode

- Back to the charset restrictions: does alpha include space ? does numeric include hex or decimal ? should punctuation be a separate class ?
Comment 35 Matthias Clasen 2011-12-07 01:26:21 UTC
Review of attachment 202700 [details] [review]:

::: gtk/gtkenums.h
@@ +951,3 @@
+  GTK_INPUT_MODE_AUTOCAP           = 1 << 30,
+  GTK_INPUT_MODE_DICTIONARY        = 1 << 31
+} GtkInputMode;

Comparing this to some of the prior art cited in the bug, I think we could do a bit better here.

Proposals:

- Make it explicit in the docs that additions to this enumeration are possible, and state that consumers should ignore values that they don't know.

- Make it explicit which of these values are 'variations' or 'modifiers' and which are complete modes. Something like 'email|numeric' probably doesn't make sense, and the documentation should make that clear. My guess is that the following grouping makes sense:

character set restrictions: alpha/numeric/special. these can be freely combined
complete 'semantic' modes: full/phone/url/email. doesn't make sense to combine
  with character set restrictions or each other
additional behaviour hints: invisible/autocap/dictionary: these can be added to
  any of the others

- Other apis discriminate between sentence/word/character autocapitalization, so we should probably rename AUTOCAP to CAP_SENTENCE to leave room for adding more

- What is the intended semantics of DICTIONARY ? Other apis have AUTO_CORRECT - is that the intention ? Dan pointed out the importance of having a NO_AUTO_CORRECT counterpart to make entering names non-annoying. An alternative would be to add a NAME mode

- Back to the charset restrictions: does alpha include space ? does numeric include hex or decimal ? should punctuation be a separate class ?
Comment 36 Benjamin Otte (Company) 2011-12-07 06:35:18 UTC
Should this maybe be different kinds of properties?

I mean, email addresses or phone numbers do have a limitation on allowed character set. They also have a generally agreed upon capitalization behavior.

Same for auto-correction - I would imagine auto-correction to find typos in names, emails and phone numbers based on my address book and in URLs based on my browser history if it was turned on.
Comment 37 Weng Xuetian 2012-05-15 18:57:23 UTC
Hi,
Usually, such kinds of hint are separate into two different group.
One is "Preferred" (no real effect, but a hint) and the other is "Restricted" (subset of character is limited).

If we don't want to separate to two types then we may explicitly write better document.

# 36
What we discussion here is the hint for input method, not for the application itself.

So auto-correction actually usually means input method(or on-screen keyboard if you don't quite understand) provides some hint, for example, if you type, "app" and there is hint about "apple".

This kinds of completion usually could not apply to email field (for example: how can "prw325@gmail.com" be a real word?). But email look up is still up to application itself.
Comment 38 Weng Xuetian 2012-05-16 05:57:27 UTC
Review of attachment 202700 [details] [review]:

So from my point of view
@GTK_INPUT_MODE_ALPHA: Allow alphabetic characters
@GTK_INPUT_MODE_NUMERIC: Allow numeric characters
@GTK_INPUT_MODE_SPECIAL: Allow non-numeric, non-alphabetic characters
@GTK_INPUT_MODE_FULL: Allow any character
@GTK_INPUT_MODE_PHONE: Edited field expects phone number
@GTK_INPUT_MODE_URL: Edited field expects URL
@GTK_INPUT_MODE_EMAIL: Edited field expects email address
These should be "Restricted", no matter input method exist or not or what they do, it will always affects typing.

@GTK_INPUT_MODE_INVISIBLE: Input characters are hidden (password)
@GTK_INPUT_MODE_AUTOCAP: Capitalize words at the beginning of sentence
@GTK_INPUT_MODE_DICTIONARY: Check for word in dictionary (spellchecking)
These should be categorized to "hints".
GTK_INPUT_MODE_DICTIONARY is named "Qt::ImhNoPredictiveText" under Qt, maybe it's more accurate and covers more case.

And Qt have something more:

Qt::ImhPreferNumbers  Numbers are preferred (but not required).
Qt::ImhPreferUppercase Upper case letters are preferred (but not required).
Qt::ImhPreferLowercase Lower case letters are preferred (but not required).

Which also seems to be viable, add those should be no harm.
Comment 39 Krzesimir Nowak 2012-05-29 15:15:11 UTC
Created attachment 215183 [details] [review]
Tentative patch for input mode, v4.

New patch. For now it only introduces new enum and flags, but they are not used anywhere.

Notes and questions:
GtkInputPurpose is an enum describing purpose and may be supplemented with GtkInputHints. Still some common sense is needed when using them.

GtkInputPurpose should be considered as "should" by applications and input methods while GtkInputHints as "may".

GtkInputPurpose is not a closed list - it will be extended for sure with some new purposes I haven't thought of.

I don't know whether setting GtkInputPurpose on GtkEntry should somehow change behaviour of GtkEntry - we probably do not want url validation in toolkit, but on the other hand setting GTK_INPUT_PURPOSE_{PASSWORD,PIN} could modify character visibility setting. I am rather striving toward information role of both purpose and hints.

 * @GTK_INPUT_PURPOSE_ALPHA: Allow only alphabetic characters.
 * @GTK_INPUT_PURPOSE_DIGITS: Allow only digits.
 * @GTK_INPUT_PURPOSE_NUMBER: Edited field expects numbers.

Should those be purposes, a hints, or removed? I am quite uncomfortable with them as there are too many questions involving them (like what about spaces? does GTK_INPUT_PURPOSE_NUMBER allow for several number or only for one? what may be their usecase?). They are probably too general, too "lowlevel".
Comment 40 Matthias Clasen 2012-08-04 19:59:17 UTC
I like the idea of splitting this into 2 properties.

A few comments:

- It should be explicitly said that these enumerations may be extended in the future and that unknown purpose values should be interpreted as 'free form', while unknown hint values should be ignored.

- The documentation for the purpose enum should say that it is meant to hint on-screen keyboards about the appropriate keys to show

- I wonder what the value of separating password/pin from freeform/digits is ? Input methods can already check the 'visibility' property of entries to know whether this field is password-like

- As mentioned above, there should be a 'no spellcheck' hint (and perhaps the name hint should be defined as 'no spellcheck'+'capitalize words')
Comment 41 Matthias Clasen 2012-08-16 18:36:52 UTC
Created attachment 221443 [details] [review]
enums: Add purpose enum and hints flags.

This commit adds two enumerations that will be used
to pass additional information to input methods, in
the subsequent commits.
Comment 42 Matthias Clasen 2012-08-16 18:37:39 UTC
Created attachment 221444 [details] [review]
GtkIMContext: Add purpose and hints

Add input-purpose and input-hints properties to GtkIMContext.
Comment 43 Matthias Clasen 2012-08-16 18:37:42 UTC
Created attachment 221445 [details] [review]
GtkEntry: Add input purpose and hints

Add input-purpose and input-hints properties to GtkEntry,
and pass these on to GtkIMContext.
Comment 44 Matthias Clasen 2012-08-16 18:37:46 UTC
Created attachment 221446 [details] [review]
GtkTextView: Add input purpose and hints

Add input-purpose and input-hints properties and pass these through
to the GtkIMContext.
Comment 45 Matthias Clasen 2012-08-16 18:37:50 UTC
Created attachment 221447 [details] [review]
Add documentation

Document the new API and properties, and their interaction with
existing properties.
Comment 46 Matthias Clasen 2012-08-16 18:42:11 UTC
Here is what I intend to commit soon. Comments appreciated.

The initial patch is based on Krzesimirs. I've reshuffled the enums a bit, and expanded the documentation with what I think makes sense.

The subsequent patches add GtkIMContext, GtkEntry, GtkTextView api to use these new enums.

After looking at the hildon code, I have not copied their approach of syncing 'invisible' with input purpose - it seems wrong to me that the purpose should change just because I check a 'show password text' checkbox below the entry...

I have also not copied the filtering according to purpose inside gtkentry that hildon has. If anything, that belongs into GtkIMContextSimple - we can do that later.
Comment 47 Gonzalo Odiard 2012-08-21 17:06:32 UTC
Is possible add a case where the developer want avoid the display of the on screen keyboard?

Our use case is simple, we have a Calculator (in the Sugar environment), and the activity already provide his own keyboard.

Calculate screenshots: http://activities.sugarlabs.org/en-US/sugar/addon/4076
Comment 48 Carlos Garnacho 2012-08-24 18:53:16 UTC
Created attachment 222360 [details] [review]
patch, add GTK_INPUT_HINT_INHIBIT

This extra flag would allow implementing what's been suggested in comment 47
Comment 49 Carlos Garnacho 2012-08-24 19:00:33 UTC
BTW, the changes in master look pretty good, and the flags fairly complete, just a couple of observations:

* GtkIMMultiContext might also need forwarding those settings to child IM contexts

* There's a minor indenting glitch that was unfortunately pasted several times:
 http://git.gnome.org/browse/gtk+/tree/gtk/gtkentry.c#n10388
 http://git.gnome.org/browse/gtk+/tree/gtk/gtkentry.c#n10437
 http://git.gnome.org/browse/gtk+/tree/gtk/gtktextview.c#n9715
 http://git.gnome.org/browse/gtk+/tree/gtk/gtktextview.c#n9766
Comment 50 Matthias Clasen 2012-08-24 21:36:47 UTC
Review of attachment 222360 [details] [review]:

::: gtk/gtkenums.h
@@ +1011,3 @@
  * @GTK_INPUT_HINT_UPPERCASE_SENTENCES: Suggest to capitalize the
  *     first word of each sentence
+ * @GTK_INPUT_HINT_INHIBIT: Suggest to inhibit the input method

I think this should be more precise, and talk explicitly about onscreen keyboards, like

@GTK_INPUT_HINT_INHIBIT_OSK: Suggest to not show an onscreen keyboard 
    (e.g for a calculator that already has all the keys).
Comment 51 Matthias Clasen 2012-08-24 21:38:13 UTC
(In reply to comment #49)

> 
> * GtkIMMultiContext might also need forwarding those settings to child IM
> contexts

Good point, you are probably right. Does hildon have code that we can steal ?

> * There's a minor indenting glitch that was unfortunately pasted several times:

oops. If you want to fix that, please go ahead.
Comment 52 Matthias Clasen 2012-08-25 19:47:33 UTC
All fixed now