Make return and release work again to commit a hex sequence. Additionally,

2006-03-14  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkimcontextsimple.c: Make return and release work again
	to commit a hex sequence. Additionally, make escape reset the
	im context when in a hex sequence.  (#334423, Behdad Esfahbod)
This commit is contained in:
Matthias Clasen 2006-03-14 16:42:59 +00:00 committed by Matthias Clasen
parent 25696b3575
commit 98569f6e65
3 changed files with 37 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2006-03-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkimcontextsimple.c: Make return and release work again
to commit a hex sequence. Additionally, make escape reset the
im context when in a hex sequence. (#334423, Behdad Esfahbod)
2006-03-13 Matthias Clasen <mclasen@redhat.com>
Make actions work with named icons. (#323484, Jorn Baayen)

View File

@ -1,3 +1,9 @@
2006-03-14 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkimcontextsimple.c: Make return and release work again
to commit a hex sequence. Additionally, make escape reset the
im context when in a hex sequence. (#334423, Behdad Esfahbod)
2006-03-13 Matthias Clasen <mclasen@redhat.com>
Make actions work with named icons. (#323484, Jorn Baayen)

View File

@ -1034,11 +1034,11 @@ gtk_im_context_simple_commit_char (GtkIMContext *context,
if (context_simple->tentative_match || context_simple->in_hex_sequence)
{
context_simple->in_hex_sequence = FALSE;
context_simple->tentative_match = 0;
context_simple->tentative_match_len = 0;
g_signal_emit_by_name (context_simple, "preedit_changed");
}
context_simple->in_hex_sequence = FALSE;
g_signal_emit_by_name (context, "commit", &buf);
}
@ -1320,8 +1320,9 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
int n_compose = 0;
gboolean have_hex_mods;
gboolean is_hex_start;
gboolean is_space;
gboolean is_hex_end;
gboolean is_backspace;
gboolean is_escape;
guint hex_keyval;
int i;
@ -1373,8 +1374,13 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
else
have_hex_mods = (event->state & (HEX_MOD_MASK)) == HEX_MOD_MASK;
is_hex_start = event->keyval == GDK_U;
is_space = event->keyval == GDK_space || event->keyval == GDK_KP_Space;
is_hex_end = (event->keyval == GDK_space ||
event->keyval == GDK_KP_Space ||
event->keyval == GDK_Return ||
event->keyval == GDK_ISO_Enter ||
event->keyval == GDK_KP_Enter);
is_backspace = event->keyval == GDK_BackSpace;
is_escape = event->keyval == GDK_Escape;
hex_keyval = canonical_hex_keyval (event);
/* If we are already in a non-hex sequence, or
@ -1385,15 +1391,17 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
(n_compose > 0 && !context_simple->in_hex_sequence) ||
(n_compose == 0 && !context_simple->in_hex_sequence && !is_hex_start) ||
(context_simple->in_hex_sequence && !hex_keyval &&
!is_hex_start && !is_space && !is_backspace))
!is_hex_start && !is_hex_end && !is_escape && !is_backspace))
{
if (event->state & (gtk_accelerator_get_default_mod_mask () & ~GDK_SHIFT_MASK) ||
(context_simple->in_hex_sequence && context_simple->modifiers_dropped &&
(event->keyval == GDK_Return ||
event->keyval == GDK_ISO_Enter ||
event->keyval == GDK_KP_Enter)))
{
return FALSE;
}
}
/* Handle backspace */
if (context_simple->in_hex_sequence && have_hex_mods && is_backspace)
@ -1414,6 +1422,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
return TRUE;
}
/* Check for hex sequence restart */
if (context_simple->in_hex_sequence && have_hex_mods && is_hex_start)
{
if (context_simple->tentative_match &&
@ -1452,7 +1461,13 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
{
if (hex_keyval)
context_simple->compose_buffer[n_compose++] = hex_keyval;
else if (!is_space)
else if (is_escape)
{
gtk_im_context_simple_reset (context);
return TRUE;
}
else if (!is_hex_end)
{
/* non-hex character in hex sequence */
gdk_display_beep (gdk_drawable_get_display (event->window));
@ -1470,8 +1485,8 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
/* If the modifiers are still held down, consider the sequence again */
if (have_hex_mods)
{
/* space ends the sequence, and we eat the space */
if (n_compose > 0 && is_space)
/* space or return ends the sequence, and we eat the key */
if (n_compose > 0 && is_hex_end)
{
if (context_simple->tentative_match &&
g_unichar_validate (context_simple->tentative_match))
@ -1524,11 +1539,11 @@ gtk_im_context_simple_reset (GtkIMContext *context)
if (context_simple->tentative_match || context_simple->in_hex_sequence)
{
context_simple->in_hex_sequence = FALSE;
context_simple->tentative_match = 0;
context_simple->tentative_match_len = 0;
g_signal_emit_by_name (context_simple, "preedit_changed");
}
context_simple->in_hex_sequence = FALSE;
}
static void