gtk_im_context_set_cursor_location() in GtkTextView
- From: Yao Zhang <yzhang sharemedia com>
- To: gtk-i18n-list gnome org
- Subject: gtk_im_context_set_cursor_location() in GtkTextView
- Date: Wed, 03 Oct 2001 13:40:53 -0400
GtkTextView still lacks the call to
gtk_im_context_set_cursor_location(). I find
I really want it in order to input Chinese easily.
So I did it myself. I don't know if the way I do
it is what the designer of GtkTextView intended,
but it works very well for me. So I listed here
in case someone else may use it.
Index: gtk/gtktextview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktextview.c,v
retrieving revision 1.111
diff -u -r1.111 gtktextview.c
--- gtk/gtktextview.c 2001/09/18 20:06:47 1.111
+++ gtk/gtktextview.c 2001/09/24 16:55:03
@@ -3147,6 +3147,25 @@
return retval;
}
+static void
+update_im_cursor_location (GtkTextView *text_view)
+{
+ GdkRectangle strong_pos;
+ GtkTextIter insert;
+
+ gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &insert,
+ gtk_text_buffer_get_mark
(get_buffer (text_view),
+
"insert"));
+ gtk_text_layout_get_cursor_locations (text_view->layout, &insert,
&strong_pos, NULL);
+ gtk_text_view_buffer_to_window_coords (text_view,
+ GTK_TEXT_WINDOW_TEXT,
+ strong_pos.x, strong_pos.y,
+ &strong_pos.x, &strong_pos.y);
+ gtk_im_context_set_cursor_location (text_view->im_context,
&strong_pos);
+printf("cursor x=%d, y=%d, xs=%d, ys=%d\n",
+ strong_pos.x, strong_pos.y, strong_pos.width,
strong_pos.height);
+}
+
static gint
gtk_text_view_event (GtkWidget *widget, GdkEvent *event)
{
@@ -3405,6 +3424,8 @@
if (event->window != text_view->text_window->bin_window)
return FALSE;
+ update_im_cursor_location (text_view);
+
if (event->button == 1)
{
if (text_view->drag_start_x >= 0)
@@ -3835,6 +3856,7 @@
text_view->blink_timeout = gtk_timeout_add (get_cursor_time
(text_view) * CURSOR_PEND_MULTIPLIER,
blink_cb,
text_view);
+ update_im_cursor_location (text_view);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]