Exposing the IM context of the WebView will allow embedders to recreate the IM context menu items and make possible more extensive unit tests against IM context behavior.
Created attachment 46062 [details] Patch for this feature
Attachment 46062 [details] did not pass style-queue: Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1 WebKit/gtk/webkit/webkitwebview.cpp:4090: Use 0 instead of NULL. [readability/null] [5] WebKit/gtk/webkit/webkitwebview.h:379: Extra space before ( in function call [whitespace/parens] [4] Total errors found: 2
I'd mirror the behavior of GtkEntry and GtkTextView here. I was about to say "and they don't expose it" but they grew an "im-module" property (no accessors) in 2.16. Would that work for your use cases?
From IRC: We determined that this wouldn't work for the use cases that I listed, because im-module only let's you set the type of im-module that the widget uses. We need a handle on the actual IM context instance that the view creates on initialization.
FWIW, I think we should go ahead with the proposed API - perhaps turned into a read-only property that exposes the actual object. What does Xan think, I wonder? =)
Whether a property or function, it should return a GtkIMContext*, which is what gtk_im_multicontext_new also returns.
Comment on attachment 46062 [details] Patch for this feature Comments above seem to suggest this has the wrong return value. r- Please re-flag if you disagree.
Created attachment 47504 [details] Updated patch (fixes style issues and passes tests) Based on all the comments I received, I'm attaching a new patch for this issue which exposes the context as a property of the WebKitWebView of type GtkIMContext.
Comment on attachment 47504 [details] Updated patch (fixes style issues and passes tests) > + Expose the GtkIMMultiContext as a property of WebKitWebView. This will > + allow embedders to generate the input method context menu entires and s/entires/entries/ > + * This is the input method context used for all text entry widgets inside > + * the #WebKitWebView. It can be used to generate context menu items for > + * controlling the active input method. g_object_unref does not need to be > + * called after retrieving this property. I don't think this is true. g_object_get will increase the ref count of the object it is getting, so you need to unref it, right? You could say that the WebView is the owner of the object, though.
Created attachment 47532 [details] Updated patch (fix documentation mistakes) Whoops. Working late again. Thanks for the review. I've attached a patch fixing those issues.
Comment on attachment 47532 [details] Updated patch (fix documentation mistakes) Looks good, thanks!
Comment on attachment 47532 [details] Updated patch (fix documentation mistakes) Clearing flags on attachment: 47532 Committed r53967: <http://trac.webkit.org/changeset/53967>
All reviewed patches have been landed. Closing bug.
*** Bug 33103 has been marked as a duplicate of this bug. ***
Some quotes from IRC, where exposing IM contexts came up today: <Company> webkit-gtk is exposing the im context, too <Company> because it wants to give developers control over the right-click menu <Company> and you cannot do that sanely without the im context <Company> (i think there was another reason, but don't remember it) <pbor> Company: uh? what does the menu have to do with it? <Company> pbor: you need to add the im context menu options <pbor> Company: e.g. textview has a popupmenu signal that you can use to extend the menu <Company> pbor: yeah, but you cannot use it to create your own menu in a sane way <mclasen> Company: I can't stop people from doing such things....but in gtk3 the im context is not going to be available... <mclasen> I don't really see how you need the context at all for that <mclasen> we do have the id of the current im as a property on the widget now <Company> mclasen, pbor: https://bugs.webkit.org/show_bug.cgi?id=33327 * mclasen not impressed <mclasen> with webkit exposing gtk interna <Company> mclasen: how would you solve the problem (of having an API for right-click menus)? <mclasen> Company: I would start by describing my needs in a gtk bug... <mclasen> Company: that bug should also explain how the populate-popup signals are insufficient...