"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gtk/gtkimcontextsimple.c" between
gtk+-3.24.26.tar.xz and gtk+-3.24.27.tar.xz

About: GTK+ 3 (the GIMP Toolkit; version 3) is a library for creating graphical user interfaces for the X Window System.

gtkimcontextsimple.c  (gtk+-3.24.26.tar.xz):gtkimcontextsimple.c  (gtk+-3.24.27.tar.xz)
skipping to change at line 68 skipping to change at line 68
*/ */
struct _GtkIMContextSimplePrivate struct _GtkIMContextSimplePrivate
{ {
guint16 *compose_buffer; guint16 *compose_buffer;
int compose_buffer_len; int compose_buffer_len;
GString *tentative_match; GString *tentative_match;
int tentative_match_len; int tentative_match_len;
guint in_hex_sequence : 1; guint in_hex_sequence : 1;
guint in_compose_sequence : 1;
guint modifiers_dropped : 1; guint modifiers_dropped : 1;
}; };
/* From the values below, the value 30 means the number of different first keysy ms /* From the values below, the value 30 means the number of different first keysy ms
* that exist in the Compose file (from Xorg). When running compose-parse.py wit hout * that exist in the Compose file (from Xorg). When running compose-parse.py wit hout
* parameters, you get the count that you can put here. Needed when updating the * parameters, you get the count that you can put here. Needed when updating the
* gtkimcontextsimpleseqs.h header file (contains the compose sequences). * gtkimcontextsimpleseqs.h header file (contains the compose sequences).
*/ */
const GtkComposeTableCompact gtk_compose_table_compact = { const GtkComposeTableCompact gtk_compose_table_compact = {
gtk_compose_seqs_compact, gtk_compose_seqs_compact,
skipping to change at line 304 skipping to change at line 305
gtk_im_context_simple_new (void) gtk_im_context_simple_new (void)
{ {
return g_object_new (GTK_TYPE_IM_CONTEXT_SIMPLE, NULL); return g_object_new (GTK_TYPE_IM_CONTEXT_SIMPLE, NULL);
} }
static void static void
gtk_im_context_simple_commit_string (GtkIMContextSimple *context_simple, gtk_im_context_simple_commit_string (GtkIMContextSimple *context_simple,
const char *str) const char *str)
{ {
GtkIMContextSimplePrivate *priv = context_simple->priv; GtkIMContextSimplePrivate *priv = context_simple->priv;
priv->in_hex_sequence = FALSE;
g_string_set_size (priv->tentative_match, 0);
priv->tentative_match_len = 0;
priv->compose_buffer[0] = 0;
g_signal_emit_by_name (context_simple, "preedit-changed"); if (priv->in_hex_sequence ||
g_signal_emit_by_name (context_simple, "preedit-end"); priv->tentative_match_len > 0 ||
priv->compose_buffer[0] != 0)
{
g_string_set_size (priv->tentative_match, 0);
priv->tentative_match_len = 0;
priv->in_compose_sequence = FALSE;
priv->in_hex_sequence = FALSE;
priv->compose_buffer[0] = 0;
g_signal_emit_by_name (context_simple, "preedit-changed");
g_signal_emit_by_name (context_simple, "preedit-end");
}
g_signal_emit_by_name (context_simple, "commit", str); g_signal_emit_by_name (context_simple, "commit", str);
} }
static void static void
gtk_im_context_simple_commit_char (GtkIMContextSimple *context_simple, gtk_im_context_simple_commit_char (GtkIMContextSimple *context_simple,
gunichar ch) gunichar ch)
{ {
char buf[8] = { 0, }; char buf[8] = { 0, };
g_unichar_to_utf8 (ch, buf); g_unichar_to_utf8 (ch, buf);
skipping to change at line 426 skipping to change at line 435
no_sequence_matches (GtkIMContextSimple *context_simple, no_sequence_matches (GtkIMContextSimple *context_simple,
int n_compose, int n_compose,
GdkEventKey *event) GdkEventKey *event)
{ {
GtkIMContextSimplePrivate *priv = context_simple->priv; GtkIMContextSimplePrivate *priv = context_simple->priv;
GtkIMContext *context; GtkIMContext *context;
gunichar ch; gunichar ch;
context = GTK_IM_CONTEXT (context_simple); context = GTK_IM_CONTEXT (context_simple);
priv->in_compose_sequence = FALSE;
/* No compose sequences found, check first if we have a partial /* No compose sequences found, check first if we have a partial
* match pending. * match pending.
*/ */
if (priv->tentative_match_len > 0) if (priv->tentative_match_len > 0)
{ {
int len = priv->tentative_match_len; int len = priv->tentative_match_len;
int i; int i;
guint16 *compose_buffer; guint16 *compose_buffer;
char *str; char *str;
skipping to change at line 715 skipping to change at line 726
priv->in_hex_sequence = TRUE; priv->in_hex_sequence = TRUE;
priv->modifiers_dropped = FALSE; priv->modifiers_dropped = FALSE;
g_string_set_size (priv->tentative_match, 0); g_string_set_size (priv->tentative_match, 0);
g_signal_emit_by_name (context_simple, "preedit-start"); g_signal_emit_by_name (context_simple, "preedit-start");
g_signal_emit_by_name (context_simple, "preedit-changed"); g_signal_emit_by_name (context_simple, "preedit-changed");
return TRUE; return TRUE;
} }
/* Then, check for compose sequences */
if (priv->in_hex_sequence) if (priv->in_hex_sequence)
{ {
if (hex_keyval && n_compose < 6) if (hex_keyval && n_compose < 6)
priv->compose_buffer[n_compose++] = hex_keyval; priv->compose_buffer[n_compose++] = hex_keyval;
else if (is_escape) else if (is_escape)
{ {
gtk_im_context_simple_reset (context); gtk_im_context_simple_reset (context);
return TRUE; return TRUE;
} }
else if (!is_hex_end) else if (!is_hex_end)
skipping to change at line 758 skipping to change at line 768
if (have_hex_mods) if (have_hex_mods)
{ {
/* space or return ends the sequence, and we eat the key */ /* space or return ends the sequence, and we eat the key */
if (n_compose > 0 && is_hex_end) if (n_compose > 0 && is_hex_end)
{ {
if (priv->tentative_match->len > 0) if (priv->tentative_match->len > 0)
{ {
char *str = g_strdup (priv->tentative_match->str); char *str = g_strdup (priv->tentative_match->str);
gtk_im_context_simple_commit_string (context_simple, str); gtk_im_context_simple_commit_string (context_simple, str);
g_free (str); g_free (str);
return TRUE;
} }
else else
{ {
/* invalid hex sequence */ /* invalid hex sequence */
beep_window (event->window); beep_window (event->window);
g_string_set_size (priv->tentative_match, 0); g_string_set_size (priv->tentative_match, 0);
priv->in_hex_sequence = FALSE; priv->in_hex_sequence = FALSE;
priv->compose_buffer[0] = 0; priv->compose_buffer[0] = 0;
} }
skipping to change at line 780 skipping to change at line 792
beep_window (event->window); beep_window (event->window);
g_signal_emit_by_name (context_simple, "preedit-changed"); g_signal_emit_by_name (context_simple, "preedit-changed");
if (!priv->in_hex_sequence) if (!priv->in_hex_sequence)
g_signal_emit_by_name (context_simple, "preedit-end"); g_signal_emit_by_name (context_simple, "preedit-end");
return TRUE; return TRUE;
} }
} }
else else /* Then, check for compose sequences */
{ {
gboolean success = FALSE; gboolean success = FALSE;
GString *output; GString *output;
output = g_string_new (""); output = g_string_new ("");
G_LOCK (global_tables); G_LOCK (global_tables);
tmp_list = global_tables; tmp_list = global_tables;
while (tmp_list) while (tmp_list)
{ {
if (gtk_compose_table_check ((GtkComposeTable *)tmp_list->data, if (gtk_compose_table_check ((GtkComposeTable *)tmp_list->data,
priv->compose_buffer, n_compose, priv->compose_buffer, n_compose,
&compose_finish, &compose_match, &compose_finish, &compose_match,
output)) output))
{ {
if (!priv->in_compose_sequence)
{
priv->in_compose_sequence = TRUE;
g_signal_emit_by_name (context_simple, "preedit-start");
}
if (compose_finish) if (compose_finish)
{ {
if (compose_match) if (compose_match)
gtk_im_context_simple_commit_string (context_simple, output- >str); gtk_im_context_simple_commit_string (context_simple, output- >str);
} }
else else
{ {
if (compose_match) if (compose_match)
{ {
g_string_assign (priv->tentative_match, output->str); g_string_assign (priv->tentative_match, output->str);
skipping to change at line 831 skipping to change at line 849
g_string_free (output, TRUE); g_string_free (output, TRUE);
if (success) if (success)
return TRUE; return TRUE;
if (gtk_compose_table_compact_check (&gtk_compose_table_compact, if (gtk_compose_table_compact_check (&gtk_compose_table_compact,
priv->compose_buffer, n_compose, priv->compose_buffer, n_compose,
&compose_finish, &compose_match, &compose_finish, &compose_match,
&output_char)) &output_char))
{ {
if (!priv->in_compose_sequence)
{
priv->in_compose_sequence = TRUE;
g_signal_emit_by_name (context_simple, "preedit-start");
}
if (compose_finish) if (compose_finish)
{ {
if (compose_match) if (compose_match)
gtk_im_context_simple_commit_char (context_simple, output_char); gtk_im_context_simple_commit_char (context_simple, output_char);
} }
else else
{ {
if (compose_match) if (compose_match)
{ {
g_string_set_size (priv->tentative_match, 0); g_string_set_size (priv->tentative_match, 0);
skipping to change at line 852 skipping to change at line 876
priv->tentative_match_len = n_compose; priv->tentative_match_len = n_compose;
} }
g_signal_emit_by_name (context_simple, "preedit-changed"); g_signal_emit_by_name (context_simple, "preedit-changed");
} }
return TRUE; return TRUE;
} }
if (gtk_check_algorithmically (priv->compose_buffer, n_compose, &output_ch ar)) if (gtk_check_algorithmically (priv->compose_buffer, n_compose, &output_ch ar))
{ {
if (!priv->in_compose_sequence)
{
priv->in_compose_sequence = TRUE;
g_signal_emit_by_name (context_simple, "preedit-start");
}
if (output_char) if (output_char)
gtk_im_context_simple_commit_char (context_simple, output_char); gtk_im_context_simple_commit_char (context_simple, output_char);
return TRUE; return TRUE;
} }
} }
/* The current compose_buffer doesn't match anything */ /* The current compose_buffer doesn't match anything */
return no_sequence_matches (context_simple, n_compose, event); return no_sequence_matches (context_simple, n_compose, event);
} }
skipping to change at line 900 skipping to change at line 930
s = g_string_new (""); s = g_string_new ("");
if (priv->in_hex_sequence) if (priv->in_hex_sequence)
{ {
g_string_append_c (s, 'u'); g_string_append_c (s, 'u');
for (i = 0; priv->compose_buffer[i]; i++) for (i = 0; priv->compose_buffer[i]; i++)
g_string_append_unichar (s, gdk_keyval_to_unicode (priv->compose_buffer[ i])); g_string_append_unichar (s, gdk_keyval_to_unicode (priv->compose_buffer[ i]));
} }
else if (priv->tentative_match->len > 0 && priv->compose_buffer[0] != 0) else if (priv->in_compose_sequence)
{
g_string_append (s, priv->tentative_match->str);
}
else
{ {
for (i = 0; priv->compose_buffer[i]; i++) if (priv->tentative_match_len > 0 && priv->compose_buffer[0] != 0)
{ {
if (priv->compose_buffer[i] == GDK_KEY_Multi_key) g_string_append (s, priv->tentative_match->str);
{ }
/* We only show the Compose key visibly when it is the else
* only glyph in the preedit, or when it occurs in the {
* middle of the sequence. Sadly, the official character, for (i = 0; priv->compose_buffer[i]; i++)
* U+2384, COMPOSITION SYMBOL, is bit too distracting, so
* we use U+00B7, MIDDLE DOT.
*/
if (priv->compose_buffer[1] == 0 || i > 0)
g_string_append (s, "·");
}
else
{ {
gunichar ch; if (priv->compose_buffer[i] == GDK_KEY_Multi_key)
gboolean need_space;
if (GDK_KEY_dead_grave <= priv->compose_buffer[i] && priv->compose
_buffer[i] <= GDK_KEY_dead_greek)
{ {
/* Sadly, not all the dead keysyms have spacing mark equivalen /* We only show the Compose key visibly when it is the
ts * only glyph in the preedit, or when it occurs in the
* in Unicode. For those that don't, we use space + the non-sp * middle of the sequence. Sadly, the official character,
acing * U+2384, COMPOSITION SYMBOL, is bit too distracting, so
* mark as an approximation * we use U+00B7, MIDDLE DOT.
*/ */
switch (priv->compose_buffer[i]) if (priv->compose_buffer[1] == 0 || i > 0)
{ g_string_append (s, "·");
#define CASE(keysym, unicode, sp) \ }
case GDK_KEY_dead_##keysym: ch = unicode; need_space = sp; b else
reak {
gunichar ch;
gboolean need_space;
CASE (grave, 0x60, 0); if (GDK_KEY_dead_grave <= priv->compose_buffer[i] && priv->com
CASE (acute, 0xb4, 0); pose_buffer[i] <= GDK_KEY_dead_greek)
CASE (circumflex, 0x5e, 0); {
CASE (tilde, 0x7e, 0); /* Sadly, not all the dead keysyms have spacing mark equiv
CASE (macron, 0xaf, 0); alents
CASE (breve, 0x2d8, 0); * in Unicode. For those that don't, we use space + the no
CASE (abovedot, 0x307, 1); n-spacing
CASE (diaeresis, 0xa8, 0); * mark as an approximation
CASE (abovering, 0x2da, 0); */
CASE (hook, 0x2c0, 0); switch (priv->compose_buffer[i])
CASE (doubleacute, 0x2dd, 0); {
CASE (caron, 0x2c7, 0); #define CASE(keysym, unicode, sp) \
CASE (cedilla, 0xb8, 0); case GDK_KEY_dead_##keysym: ch = unicode; need_space = s
CASE (ogonek, 0x2db, 0); p; break
CASE (iota, 0x37a, 0);
CASE (voiced_sound, 0x3099, 1); CASE (grave, 0x60, 0);
CASE (semivoiced_sound, 0x309a, 1); CASE (acute, 0xb4, 0);
CASE (belowdot, 0x323, 1); CASE (circumflex, 0x5e, 0);
CASE (horn, 0x31b, 1); CASE (tilde, 0x7e, 0);
CASE (stroke, 0x335, 1); CASE (macron, 0xaf, 0);
CASE (abovecomma, 0x2bc, 0); CASE (breve, 0x2d8, 0);
CASE (abovereversedcomma, 0x2bd, 1); CASE (abovedot, 0x307, 1);
CASE (doublegrave, 0x30f, 1); CASE (diaeresis, 0xa8, 0);
CASE (belowring, 0x2f3, 0); CASE (abovering, 0x2da, 0);
CASE (belowmacron, 0x2cd, 0); CASE (hook, 0x2c0, 0);
CASE (belowcircumflex, 0x32d, 1); CASE (doubleacute, 0x2dd, 0);
CASE (belowtilde, 0x330, 1); CASE (caron, 0x2c7, 0);
CASE (belowbreve, 0x32e, 1); CASE (cedilla, 0xb8, 0);
CASE (belowdiaeresis, 0x324, 1); CASE (ogonek, 0x2db, 0);
CASE (invertedbreve, 0x32f, 1); CASE (iota, 0x37a, 0);
CASE (belowcomma, 0x326, 1); CASE (voiced_sound, 0x3099, 1);
CASE (lowline, 0x5f, 0); CASE (semivoiced_sound, 0x309a, 1);
CASE (aboveverticalline, 0x2c8, 0); CASE (belowdot, 0x323, 1);
CASE (belowverticalline, 0x2cc, 0); CASE (horn, 0x31b, 1);
CASE (longsolidusoverlay, 0x338, 1); CASE (stroke, 0x335, 1);
CASE (a, 0x363, 1); CASE (abovecomma, 0x2bc, 0);
CASE (A, 0x363, 1); CASE (abovereversedcomma, 0x2bd, 1);
CASE (e, 0x364, 1); CASE (doublegrave, 0x30f, 1);
CASE (E, 0x364, 1); CASE (belowring, 0x2f3, 0);
CASE (i, 0x365, 1); CASE (belowmacron, 0x2cd, 0);
CASE (I, 0x365, 1); CASE (belowcircumflex, 0x32d, 1);
CASE (o, 0x366, 1); CASE (belowtilde, 0x330, 1);
CASE (O, 0x366, 1); CASE (belowbreve, 0x32e, 1);
CASE (u, 0x367, 1); CASE (belowdiaeresis, 0x324, 1);
CASE (U, 0x367, 1); CASE (invertedbreve, 0x32f, 1);
CASE (small_schwa, 0x1dea, 1); CASE (belowcomma, 0x326, 1);
CASE (capital_schwa, 0x1dea, 1); CASE (lowline, 0x5f, 0);
#undef CASE CASE (aboveverticalline, 0x2c8, 0);
default: CASE (belowverticalline, 0x2cc, 0);
need_space = FALSE; CASE (longsolidusoverlay, 0x338, 1);
ch = gdk_keyval_to_unicode (priv->compose_buffer[i]); CASE (a, 0x363, 1);
break; CASE (A, 0x363, 1);
CASE (e, 0x364, 1);
CASE (E, 0x364, 1);
CASE (i, 0x365, 1);
CASE (I, 0x365, 1);
CASE (o, 0x366, 1);
CASE (O, 0x366, 1);
CASE (u, 0x367, 1);
CASE (U, 0x367, 1);
CASE (small_schwa, 0x1dea, 1);
CASE (capital_schwa, 0x1dea, 1);
#undef CASE
default:
need_space = FALSE;
ch = gdk_keyval_to_unicode (priv->compose_buffer[i]);
break;
}
if (ch)
{
if (need_space)
g_string_append_c (s, ' ');
g_string_append_unichar (s, ch);
}
} }
if (ch) else
{ {
if (need_space) ch = gdk_keyval_to_unicode (priv->compose_buffer[i]);
g_string_append_c (s, ' '); if (ch)
g_string_append_unichar (s, ch); g_string_append_unichar (s, ch);
} }
} }
else
{
ch = gdk_keyval_to_unicode (priv->compose_buffer[i]);
if (ch)
g_string_append_unichar (s, ch);
}
} }
} }
} }
if (cursor_pos) if (cursor_pos)
*cursor_pos = s->len; *cursor_pos = s->len;
if (attrs) if (attrs)
{ {
*attrs = pango_attr_list_new (); *attrs = pango_attr_list_new ();
 End of changes. 20 change blocks. 
103 lines changed or deleted 136 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)