From 70895bfdfda0460fbb1c78e6c060db9ea1ce0d04 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Fri, 2 Apr 2004 07:17:36 +0000 Subject: [ fixes bug #51897 ] 2004-04-01 Chris Toshok [ fixes bug #51897 ] * gal/e-text/e-text.c (insert_preedit_text): only reset the layout attrs if there is some preedit text to insert. also, try getting text->layout's attributes before creating a new list. this will keep us from overwriting existing attributes and wiping out the underlining for objects. svn path=/trunk/; revision=25294 --- widgets/text/e-text.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index 93fd9d0120..b9aeadf6bf 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -293,6 +293,7 @@ insert_preedit_text (EText *text) gchar *preedit_string = NULL; GString *tmp_string = g_string_new (NULL); gint length = 0, cpos = 0, preedit_length = 0; + gboolean new_attrs = FALSE; if (text->layout == NULL || !GTK_IS_IM_CONTEXT (text->im_context)) return; @@ -302,11 +303,9 @@ insert_preedit_text (EText *text) g_string_prepend_len (tmp_string, text->text,length); - attrs = pango_attr_list_new (); - gtk_im_context_get_preedit_string (text->im_context, - &preedit_string, &preedit_attrs, - NULL); + &preedit_string, &preedit_attrs, + NULL); if (preedit_string && g_utf8_validate (preedit_string, -1, NULL)) text->preedit_len = preedit_length = strlen (preedit_string); @@ -315,15 +314,26 @@ insert_preedit_text (EText *text) cpos = g_utf8_offset_to_pointer (text->text, text->selection_start) - text->text; - if (preedit_length) + if (preedit_length) { g_string_insert (tmp_string, cpos, preedit_string); - reset_layout_attrs (text); + reset_layout_attrs (text); + + attrs = pango_layout_get_attributes (text->layout); + if (!attrs) { + attrs = pango_attr_list_new (); + new_attrs = TRUE; + } + + pango_layout_set_text (text->layout, tmp_string->str, tmp_string->len); - pango_layout_set_text (text->layout, tmp_string->str, tmp_string->len); - if (preedit_length) pango_attr_list_splice (attrs, preedit_attrs, cpos, preedit_length); - pango_layout_set_attributes (text->layout, attrs); + + if (new_attrs) { + pango_layout_set_attributes (text->layout, attrs); + pango_attr_list_unref (attrs); + } + } if (preedit_string) g_free (preedit_string); @@ -331,8 +341,6 @@ insert_preedit_text (EText *text) pango_attr_list_unref (preedit_attrs); if (tmp_string) g_string_free (tmp_string, TRUE); - if (attrs) - pango_attr_list_unref (attrs); } static void -- cgit v1.2.3