[Uim] Focus and cursor position shift handlings (bug #7729)
Etsushi Kato
ek.kato at gmail.com
Fri Nov 17 12:13:28 EET 2006
On 11/17/06, YAMAMOTO Kengo / YamaKen <yamaken at bp.iij4u.or.jp> wrote:
> At Fri, 17 Nov 2006 16:31:51 +0900,
> ek.kato at gmail.com wrote:
> > As GtkTextview doesn't inherit GtkEditable we can't use this. Since
> > only GtkEntry and GtkTextView have GtkIMContext in GTK+, following
> > code should work (but seem hack).
>
> Oops, sorry. You're right. But I think that the responsibility
> violation of your code should be avoided even if it's a
> workaround hack. I prefer keeping im_context private to text
> widgets, as described in gtk_entry_init(). And I also want to
> keep full-implementability of user text widgets that use
> im_context possible.
>
> # Although I recently suggested a code fragment which touches
> # im_context directly to explain my concepts. Sorry, it was only
> # a concept and inappropriate for actual implementation.
>
> static void
> gtk_entry_init (GtkEntry *entry)
> {
> ...
> /* This object is completely private. No external entity can gain a reference
> * to it; so we create it here and destroy it in finalize().
> */
> entry->im_context = gtk_im_multicontext_new ();
> ...
> }
Agreed.
> How about using move_cursor signal with zero move to notify text
> widgets the event?
That's fine. And it is needed to revise semantics of
gtk_text_view_reset_im_context() and _gtk_entry_reset_im_context().
It may requires additional interface with GtkIMContext. Or just call
gtk_im_context_focus_out() and gtk_im_context_focus_in() sequentially
within it?
void
gtk_widget_fix_input_context (GtkWidget *widget)
{
GtkWidget *toplevel, *focus_widget;;
g_return_if_fail (GTK_IS_WIDGET (widget));
toplevel = gtk_widget_get_toplevel (widget);
if (GTK_WIDGET_TOPLEVEL (toplevel)) {
focus_widget = GTK_WINDOW (toplevel)->focus_widget;
if (focus_widget &&
(GTK_IS_TEXT_VIEW (focus_widget) || GTK_IS_ENTRY (focus_widget)))
g_signal_emit_by_name (focus_widget, "move_cursor",
GTK_MOVEMENT_LOGICAL_POSITIONS, 0, FALSE);
}
}
--
Etsushi Kato
ek.kato at gmail.com
More information about the uim
mailing list