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