evolution/evolution-2.7.4-deleting-preedit-buffer.patch
Matthew Barnes d93c79add4 - Update to 2.21.3
- Remove patch for RH bug #215467 (fixed upstream).
- Remove patch for GNOME bug #499920 (fixed upstream).
2007-12-04 01:22:06 +00:00

111 lines
3.8 KiB
Diff

--- evolution-2.7.90/widgets/text/e-text.c.deleting-preedit-buffer 2006-07-26 10:16:02.000000000 -0400
+++ evolution-2.7.90/widgets/text/e-text.c 2006-07-26 10:25:29.000000000 -0400
@@ -284,7 +284,7 @@
PangoAttrList *preedit_attrs = NULL;
gchar *preedit_string = NULL;
GString *tmp_string = g_string_new (NULL);
- gint length = 0, cpos = 0, preedit_length = 0;
+ gint length = 0, cpos = 0;
gboolean new_attrs = FALSE;
if (text->layout == NULL || !GTK_IS_IM_CONTEXT (text->im_context))
@@ -295,19 +295,15 @@
g_string_prepend_len (tmp_string, text->text,length);
- if (text->preedit_len)
- gtk_im_context_get_preedit_string (text->im_context,
- &preedit_string, &preedit_attrs,
- NULL);
+ /* we came into this function only when text->preedit_len was not 0
+ so we can saftely fetch the preedit string */
+ gtk_im_context_get_preedit_string (text->im_context, &preedit_string, &preedit_attrs, NULL);
if (preedit_string && g_utf8_validate (preedit_string, -1, NULL))
- text->preedit_len = preedit_length = strlen (preedit_string);
- else
- text->preedit_len = preedit_length = 0;
-
- cpos = g_utf8_offset_to_pointer (text->text, text->selection_start) - text->text;
+ {
+ text->preedit_len = strlen (preedit_string);
+ cpos = g_utf8_offset_to_pointer (text->text, text->selection_start) - text->text;
- if (preedit_length) {
g_string_insert (tmp_string, cpos, preedit_string);
reset_layout_attrs (text);
@@ -320,15 +316,17 @@
pango_layout_set_text (text->layout, tmp_string->str, tmp_string->len);
- pango_attr_list_splice (attrs, preedit_attrs, cpos, preedit_length);
+ pango_attr_list_splice (attrs, preedit_attrs, cpos, text->preedit_len);
if (new_attrs) {
pango_layout_set_attributes (text->layout, attrs);
pango_attr_list_unref (attrs);
- }
+ }
update_im_cursor_position (text);
}
+ else
+ text->preedit_len = 0;
if (preedit_string)
g_free (preedit_string);
@@ -385,9 +383,12 @@
pango_attr_list_insert_before (attrs, attr);
}
}
+
pango_layout_set_attributes (text->layout, attrs);
+
if (attrs)
pango_attr_list_unref (attrs);
+
calc_height (text);
}
@@ -1510,9 +1511,14 @@
}
}
-
- if (text->im_context_signals_registered)
- insert_preedit_text (text);
+ /* Insert preedit text only when im_context signals are connected & text->preedit_len is not zero */
+ if (text->im_context_signals_registered && text->preedit_len)
+ insert_preedit_text (text);
+
+ /* Need to reset the layout to cleanly clear the preedit buffer
+ * when typing in CJK & using backspace on the preedit */
+ if(!text->preedit_len)
+ reset_layout (text);
if (!pango_layout_get_text (text->layout))
return;
@@ -2220,11 +2226,12 @@
*/
if (save_text && save_text->im_context) {
+ gtk_im_context_focus_out(save_text->im_context);
g_signal_handlers_disconnect_matched (save_text->im_context,
G_SIGNAL_MATCH_DATA,
0, 0, NULL,
NULL, save_text);
- save_text->im_context_signals_registered = FALSE;
+ save_text->im_context_signals_registered = FALSE;
reset_layout (save_text);
}
@@ -2240,6 +2247,7 @@
G_CALLBACK (e_text_delete_surrounding_cb), text);
text->im_context_signals_registered = TRUE;
}
+ gtk_im_context_focus_in(text->im_context);
}
start_editing (text);
text->show_cursor = FALSE; /* so we'll redraw and the cursor will be shown */