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 417446 - Include multi-press-im-context in gtk+
Include multi-press-im-context in gtk+
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Input Methods
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Hidetoshi Tajima
gtk-bugs
Depends on:
Blocks: 447359
 
 
Reported: 2007-03-12 12:25 UTC by Johannes Schmid
Modified: 2007-03-18 05:37 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Tarball of the latest version (374.75 KB, application/x-compressed-tar)
2007-03-12 12:28 UTC, Johannes Schmid
  Details
Add MultiPress IM Context to gtk+ (32.95 KB, patch)
2007-03-14 14:30 UTC, Johannes Schmid
reviewed Details | Review
README (1.42 KB, text/plain)
2007-03-15 18:00 UTC, Murray Cumming
  Details
Improved version of the patch mentioned above (31.28 KB, patch)
2007-03-15 20:01 UTC, Johannes Schmid
none Details | Review
Another improved version (31.27 KB, patch)
2007-03-15 20:05 UTC, Johannes Schmid
accepted-commit_now Details | Review

Description Johannes Schmid 2007-03-12 12:25:40 UTC
This is a follow-up of the gnome support ticket #2565

The multi-press-im-context is particularly useful for devices like mobile phones where it is the usual way to enter text (in short message service for example).

Attached is the latest tarball from the private openismus SVN.
Comment 1 Johannes Schmid 2007-03-12 12:28:16 UTC
Created attachment 84425 [details]
Tarball of the latest version
Comment 2 Murray Cumming 2007-03-12 12:32:42 UTC
I don't think it would be wise to add the multipress method to GTK+ itself, because it is useless (and confusing) on most systems, with normal keyboards.

Also, I anticipate that mobile vendors might want to customize it, and that is easier if it's independent of their GTK+ packages.
Comment 3 Johannes Schmid 2007-03-12 12:47:57 UTC
The GTK+ developers wanted this bug report so I created it. They haven't said much about their reasons in the support ticket.
Comment 4 Murray Cumming 2007-03-12 13:42:21 UTC
Tim Janik seems to like the idea of having this in GTK+ itself anyway, to get more testing, maybe disabled via a configure option. I don't mind too much either way.
Comment 5 Johannes Schmid 2007-03-12 14:28:16 UTC
From Matthias Clasen:
> (...=But since the IM we are talking about here is not language-specific, 
> and we have been accepting a lot of features to make gtk work in
> embedded situations, I have no objections to adding the multipress
> IM to gtk itself.

OK, I will prepare a patch against Gtk+ svn then attach it here.
Comment 6 Murray Cumming 2007-03-12 14:41:54 UTC
Thanks, Johannes.
Comment 7 Johannes Schmid 2007-03-12 14:54:02 UTC
> OK, I will prepare a patch against Gtk+ svn then attach it here.
> 

Some questions about the Gtk+ integration:
- What namespace would you prefer?
Currently the methods are name GtkMultiPressImContext but I assume that it would be better to have GtkImContextMultiPress as all other modules are named GtkImContext*
- What about the config file that is used to know which buttons to map (on a normal mobile phone "1" = abc1 for example). It is in GKeyFile format but where should I put it in Gtk+?

Thanks!
Comment 8 Matthias Clasen 2007-03-12 15:18:39 UTC
I guess I would prefer GtkIMContextMultipress and
gtk_im_context_multipress (or maybe MultiPress and multi_press if you really
want to maximize the number of underscores...)

If the input method needs a config file, the most natural place for it in svn
would be in modules/input next to the source, I'd say. 
Where do you look for it at runtime ? /etc/gtk-2.0 ? $HOME/.config ?
Comment 9 Tim Janik 2007-03-12 15:41:53 UTC
a couple thoughts on integration/enabling of multi-press from IRC:

if a multi-press input method goes into stock gtk, it should be testable by   developers of course. but if on a stock desktop it proves to be rather useless and shouldn't be part of the IM menu, a display setting for showing the menu entry defaulting to FALSE could be a solution. a configure.in option could be another one. and/or a configure default to auto-build it only in development branches (like we already do with debugging info).

this isn't meant to imply decisions on integration or visibility on menu items just yet.
Comment 10 Matthias Clasen 2007-03-12 15:55:11 UTC
Realistically, a lot of the IMs we ship with gtk are not testable by developers either, because there is no documentation at all for how they map keypresses to 
characters, and what you should expect on screen...
Comment 11 Johannes Schmid 2007-03-12 16:01:38 UTC
> If the input method needs a config file, the most natural place for it in svn
> would be in modules/input next to the source, I'd say. 
> Where do you look for it at runtime ? /etc/gtk-2.0 ? $HOME/.config ?

It is currently installed in $(sysconfdir) but /etc/gtk-2.0 looks like a good place to put this in the future. I don't think anyone will ever want to change the behaviour on a per-user base because it depends on the available hardware keys.
Comment 12 Johannes Schmid 2007-03-14 14:30:16 UTC
Created attachment 84576 [details] [review]
Add MultiPress IM Context to gtk+

This patch will add the required files to gtk+ and adjust the Makefile.am. 

The config file will be installed in $(sysconfdir)/gtk-2.0. I hope I got everything correctly with the namespaces and conventions. I did NOT add anything to build this conditionally as I think the maintainers will know better how they want to do this.
Comment 13 Matthias Clasen 2007-03-15 02:37:02 UTC
Looks good in general, some comments: 

- it would be nice if we could start to improve the state of user-level documentation of input methods by including a README.multipress or similar
describing "how it works".

- stylistic nitpick: we always leave a space before a (, 
  both in for( and in g_free(foo)

- return types go on a line by themselves

- All uses of bsearch seem to be commented out, still
+#include <stdlib.h> /* For bsearch() */
I guess you should either sort the sequence table and use bsearch
or remove the commented out parts together with the include


+  /* GDK_THREADS_ENTER and GDK_THREADS_LEAVE might not be necessary.
+   * I added them while investigating a crash (fixed elsewhere now, in accept_character(), I believe),
+   * because I saw them in Movial's sequence-input-module implementation.
+   */

Yes, they are necessary, since timeouts are executed outside the gdk lock.
Just remove the comment.


+        /* TODO: The delete key does not seem to be handled when we do this.
+         * danielk: Yes, that's normal and it's not the only one.  I'll get to that later. */

Is this planned ? 


+      else if(event->keyval == GDK_Return || event->keyval == GDK_Tab)

There are some more keys you may want to check for here:
GDK_KP_Enter
GDK_ISO_Enter
GDK_KP_Tab
GDK_ISO_Left_Tab


+  parent = (GtkIMContextClass *)gtk_im_context_multipress_parent_class;
+  if(parent && parent->filter_keypress)

No need to check parent here. It can't be NULL
Comment 14 Murray Cumming 2007-03-15 08:53:36 UTC
> +  /* GDK_THREADS_ENTER and GDK_THREADS_LEAVE might not be necessary.
> +   * I added them while investigating a crash (fixed elsewhere now, in
> accept_character(), I believe),
> +   * because I saw them in Movial's sequence-input-module implementation.
> +   */
> 
> Yes, they are necessary, since timeouts are executed outside the gdk lock.
> Just remove the comment.

Thanks. I'd rather have a comment saying why they are necessary (now possible). I am intolerant of the lack of comments in most GTK+ code.

> +        /* TODO: The delete key does not seem to be handled when we do this.
> +         * danielk: Yes, that's normal and it's not the only one.  I'll get to
> that later. */
>
> Is this planned ?

No Idea. CCing Daniel.
Comment 15 Murray Cumming 2007-03-15 09:21:53 UTC
> it would be nice if we could start to improve the state of user-level
> documentation of input methods by including a README.multipress or similar
> describing "how it works".

I plan to patch the GtkIMContext gtk-doc documentation sometime, based on this:
http://www.murrayc.com/blog/permalink/2006/12/22/creating-gtk-input-methods/
Comment 16 Matthias Clasen 2007-03-15 17:38:11 UTC
> I am intolerant of the lack of comments in most GTK+ code.

That may be so, however, the code you are presenting here is heavily over-commented. Not that I think this should block it from going in.
But comments expressing uncertainty about how other parts of the very 
module you want to get this in are working are guaranteed to raise
questions during review...

> I plan to patch the GtkIMContext gtk-doc documentation sometime, based on this:
> http://www.murrayc.com/blog/permalink/2006/12/22/creating-gtk-input-methods/

Thats nice, but it doesn't address my request for _user_ documentation,
ie a file describing what key sequences have to create to produce a certain
character.
Comment 17 Murray Cumming 2007-03-15 17:59:35 UTC
> But comments expressing uncertainty about how other parts of the very 
> module you want to get this in are working are guaranteed to raise
> questions during review...

Of course, and thanks. That's what they are there for.

> _user_ documentation,

There was a README in the original tarball. I'll upload it separately so it's more obvious.
Comment 18 Murray Cumming 2007-03-15 18:00:18 UTC
Created attachment 84665 [details]
README

README for the multipress input method.
Comment 19 Matthias Clasen 2007-03-15 18:19:38 UTC
Thanks, having that README next to the code would be a good.
Comment 20 Johannes Schmid 2007-03-15 20:01:50 UTC
Created attachment 84672 [details] [review]
Improved version of the patch mentioned above

- fixed coding style
- added GDK_KP_Enter, etc.
- Removed unused code (bsearch)
- Added REAME.multipress (see Murray's comment)

I am not sure about the TODO you mention. I haven't written the code and I don't really know what is needed there. Maybe Daniel could tell us.
Comment 21 Johannes Schmid 2007-03-15 20:05:35 UTC
Created attachment 84673 [details] [review]
Another improved version

Same as above but also fixes the parent checking issue. Sorry for missing that one before.
Comment 22 Matthias Clasen 2007-03-15 20:17:44 UTC
Looking much better now, thanks. 

Murray, do you want to leave your email address in the README ?
Comment 23 Murray Cumming 2007-03-15 20:30:17 UTC
> do you want to leave your email address in the README ?

If that's OK. (Not for copyright, but just as advertising)
Comment 24 Matthias Clasen 2007-03-15 20:47:36 UTC
Sure its ok. 
Just asking, because normally people want their email addresses 
_not_ exposed...
Comment 25 Matthias Clasen 2007-03-16 18:36:28 UTC
Johannes, can you commit this yourself, or should I do it ?
Comment 26 Murray Cumming 2007-03-17 16:53:42 UTC
By the way, we should still replace the object-data hack with a function call to set the current input method programatically. But I guess we can do that later.
Comment 27 Matthias Clasen 2007-03-18 05:37:54 UTC
2007-03-18  Matthias Clasen <mclasen@redhat.com> 

        * modules/input/gtkimcontextmultipress.[hc]:
        * modules/input/im-multipress.conf:
        * modules/input/immultipress.c:
        * modules/input/README.multipress: Add the multipress input
        method.  (#417446, Johannes Schmid, Murray Cumming)

        * modules/input/Makefile.am: Glue