From cd7376dd5e4be396a592d24832da3b129b429ee6 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Sun, 25 May 2008 22:58:55 +0000 Subject: Bug 534463 - non-editable GtkTextView should not call 2008-05-25 Cody Russell Bug 534463 - non-editable GtkTextView should not call gtk_im_context_focus_in in focus event * gtk/gtktextview.c: Add checks to see if the textview is editable. Patch by Wang Diancheng. svn path=/trunk/; revision=20162 --- gtk/gtktextview.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'gtk/gtktextview.c') diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index b00ebb05a..681959023 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -2234,8 +2234,18 @@ gtk_text_view_set_editable (GtkTextView *text_view, if (text_view->editable != setting) { + if (!setting) + { + gtk_text_view_reset_im_context(text_view); + if (GTK_WIDGET_HAS_FOCUS (text_view)) + gtk_im_context_focus_out (text_view->im_context); + } + text_view->editable = setting; + if (setting && GTK_WIDGET_HAS_FOCUS (text_view)) + gtk_im_context_focus_in (text_view->im_context); + if (text_view->layout) { gtk_text_layout_set_overwrite_mode (text_view->layout, @@ -4333,9 +4343,12 @@ gtk_text_view_focus_in_event (GtkWidget *widget, GdkEventFocus *event) "direction_changed", G_CALLBACK (keymap_direction_changed), text_view); gtk_text_view_check_keymap_direction (text_view); - - text_view->need_im_reset = TRUE; - gtk_im_context_focus_in (GTK_TEXT_VIEW (widget)->im_context); + + if (text_view->editable) + { + text_view->need_im_reset = TRUE; + gtk_im_context_focus_in (GTK_TEXT_VIEW (widget)->im_context); + } return FALSE; } @@ -4361,8 +4374,11 @@ gtk_text_view_focus_out_event (GtkWidget *widget, GdkEventFocus *event) keymap_direction_changed, text_view); - text_view->need_im_reset = TRUE; - gtk_im_context_focus_out (GTK_TEXT_VIEW (widget)->im_context); + if (text_view->editable) + { + text_view->need_im_reset = TRUE; + gtk_im_context_focus_out (GTK_TEXT_VIEW (widget)->im_context); + } return FALSE; } -- cgit v1.2.1