1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 2000 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include <gdk/gdkkeysyms.h>
25 #include "gtkaccelgroup.h"
26 #include "gtkimcontextsimple.h"
27 #include "gtksettings.h"
28 #include "gtkwidget.h"
32 typedef struct _GtkComposeTable GtkComposeTable;
33 typedef struct _GtkComposeTableCompact GtkComposeTableCompact;
35 struct _GtkComposeTable
42 struct _GtkComposeTableCompact
50 /* This file contains the table of the compose sequences,
51 * static const guint16 gtk_compose_seqs_compact[] = {}
52 * IT is generated from the compose-parse.py script.
54 #include "gtkimcontextsimpleseqs.h"
56 /* From the values below, the value 22 means the number of different first keysyms
57 * that exist in the Compose file (from Xorg). When running compose-parse.py without
58 * parameters, you get the count that you can put here. Needed when updating the
59 * gtkimcontextsimpleseqs.h header file (contains the compose sequences).
61 static const GtkComposeTableCompact gtk_compose_table_compact = {
62 gtk_compose_seqs_compact,
68 static const guint16 gtk_compose_ignore[] = {
87 static void gtk_im_context_simple_finalize (GObject *obj);
88 static gboolean gtk_im_context_simple_filter_keypress (GtkIMContext *context,
90 static void gtk_im_context_simple_reset (GtkIMContext *context);
91 static void gtk_im_context_simple_get_preedit_string (GtkIMContext *context,
93 PangoAttrList **attrs,
96 G_DEFINE_TYPE (GtkIMContextSimple, gtk_im_context_simple, GTK_TYPE_IM_CONTEXT)
99 gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class)
101 GtkIMContextClass *im_context_class = GTK_IM_CONTEXT_CLASS (class);
102 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
104 im_context_class->filter_keypress = gtk_im_context_simple_filter_keypress;
105 im_context_class->reset = gtk_im_context_simple_reset;
106 im_context_class->get_preedit_string = gtk_im_context_simple_get_preedit_string;
107 gobject_class->finalize = gtk_im_context_simple_finalize;
111 gtk_im_context_simple_init (GtkIMContextSimple *im_context_simple)
116 gtk_im_context_simple_finalize (GObject *obj)
118 GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (obj);
120 if (context_simple->tables)
122 g_slist_foreach (context_simple->tables, (GFunc)g_free, NULL);
123 g_slist_free (context_simple->tables);
125 context_simple->tables = NULL;
128 G_OBJECT_CLASS (gtk_im_context_simple_parent_class)->finalize (obj);
132 * gtk_im_context_simple_new:
134 * Creates a new #GtkIMContextSimple.
136 * Returns: a new #GtkIMContextSimple.
139 gtk_im_context_simple_new (void)
141 return g_object_new (GTK_TYPE_IM_CONTEXT_SIMPLE, NULL);
145 gtk_im_context_simple_commit_char (GtkIMContext *context,
151 GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
153 g_return_if_fail (g_unichar_validate (ch));
155 len = g_unichar_to_utf8 (ch, buf);
158 if (context_simple->tentative_match || context_simple->in_hex_sequence)
160 context_simple->in_hex_sequence = FALSE;
161 context_simple->tentative_match = 0;
162 context_simple->tentative_match_len = 0;
163 g_signal_emit_by_name (context_simple, "preedit-changed");
164 g_signal_emit_by_name (context_simple, "preedit-end");
167 g_signal_emit_by_name (context, "commit", &buf);
171 compare_seq_index (const void *key, const void *value)
173 const guint *keysyms = key;
174 const guint16 *seq = value;
176 if (keysyms[0] < seq[0])
178 else if (keysyms[0] > seq[0])
185 compare_seq (const void *key, const void *value)
188 const guint *keysyms = key;
189 const guint16 *seq = value;
193 if (keysyms[i] < seq[i])
195 else if (keysyms[i] > seq[i])
205 check_table (GtkIMContextSimple *context_simple,
206 const GtkComposeTable *table,
209 gint row_stride = table->max_seq_len + 2;
212 /* Will never match, if the sequence in the compose buffer is longer
213 * than the sequences in the table. Further, compare_seq (key, val)
214 * will overrun val if key is longer than val. */
215 if (n_compose > table->max_seq_len)
218 seq = bsearch (context_simple->compose_buffer,
219 table->data, table->n_seqs,
220 sizeof (guint16) * row_stride,
227 /* Back up to the first sequence that matches to make sure
228 * we find the exact match if their is one.
230 while (seq > table->data)
232 prev_seq = seq - row_stride;
233 if (compare_seq (context_simple->compose_buffer, prev_seq) != 0)
238 if (n_compose == table->max_seq_len ||
239 seq[n_compose] == 0) /* complete sequence */
243 0x10000 * seq[table->max_seq_len] + seq[table->max_seq_len + 1];
246 /* We found a tentative match. See if there are any longer
247 * sequences containing this subsequence
249 next_seq = seq + row_stride;
250 if (next_seq < table->data + row_stride * table->n_seqs)
252 if (compare_seq (context_simple->compose_buffer, next_seq) == 0)
254 context_simple->tentative_match = value;
255 context_simple->tentative_match_len = n_compose;
257 g_signal_emit_by_name (context_simple, "preedit-changed");
263 gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
264 context_simple->compose_buffer[0] = 0;
274 check_compact_table (GtkIMContextSimple *context_simple,
275 const GtkComposeTableCompact *table,
283 /* Will never match, if the sequence in the compose buffer is longer
284 * than the sequences in the table. Further, compare_seq (key, val)
285 * will overrun val if key is longer than val. */
286 if (n_compose > table->max_seq_len)
289 seq_index = bsearch (context_simple->compose_buffer,
290 table->data, table->n_index_size,
291 sizeof (guint16) * table->n_index_stride,
297 if (seq_index && n_compose == 1)
302 for (i = n_compose-1; i < table->max_seq_len; i++)
306 if (seq_index[i+1] - seq_index[i] > 0)
308 seq = bsearch (context_simple->compose_buffer + 1,
309 table->data + seq_index[i], (seq_index[i+1] - seq_index[i]) / row_stride,
310 sizeof (guint16) * row_stride,
315 if (i == n_compose - 1)
319 g_signal_emit_by_name (context_simple, "preedit-changed");
332 value = seq[row_stride - 1];
334 gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
335 context_simple->compose_buffer[0] = 0;
343 /* This function receives a sequence of Unicode characters and tries to
344 * normalize it (NFC). We check for the case the the resulting string
345 * has length 1 (single character).
346 * NFC normalisation normally rearranges diacritic marks, unless these
347 * belong to the same Canonical Combining Class.
348 * If they belong to the same canonical combining class, we produce all
349 * permutations of the diacritic marks, then attempt to normalize.
352 check_normalize_nfc (gunichar* combination_buffer, gint n_compose)
354 gunichar combination_buffer_temp[GTK_MAX_COMPOSE_LEN];
355 gchar *combination_utf8_temp = NULL;
356 gchar *nfc_temp = NULL;
363 for (i = 1; i < n_compose; i++ )
366 /* Xorg reuses dead_tilde for the perispomeni diacritic mark.
367 * We check if base character belongs to Greek Unicode block,
368 * and if so, we replace tilde with perispomeni. */
369 if (combination_buffer[0] >= 0x390 && combination_buffer[0] <= 0x3FF)
371 for (i = 1; i < n_compose; i++ )
372 if (combination_buffer[i] == 0x303)
373 combination_buffer[i] = 0x342;
376 memcpy (combination_buffer_temp, combination_buffer, GTK_MAX_COMPOSE_LEN * sizeof (gunichar) );
378 for (i = 0; i < n_combinations; i++ )
380 g_unicode_canonical_ordering (combination_buffer_temp, n_compose);
381 combination_utf8_temp = g_ucs4_to_utf8 (combination_buffer_temp, -1, NULL, NULL, NULL);
382 nfc_temp = g_utf8_normalize (combination_utf8_temp, -1, G_NORMALIZE_NFC);
384 if (g_utf8_strlen (nfc_temp, -1) == 1)
386 memcpy (combination_buffer, combination_buffer_temp, GTK_MAX_COMPOSE_LEN * sizeof (gunichar) );
388 g_free (combination_utf8_temp);
394 g_free (combination_utf8_temp);
399 temp_swap = combination_buffer_temp[i % (n_compose - 1) + 1];
400 combination_buffer_temp[i % (n_compose - 1) + 1] = combination_buffer_temp[(i+1) % (n_compose - 1) + 1];
401 combination_buffer_temp[(i+1) % (n_compose - 1) + 1] = temp_swap;
410 /* When updating the table of the compose sequences, also update here.
412 #define IS_DEAD_KEY(k) \
413 (((k) >= GDK_dead_grave && (k) <= (GDK_dead_dasia+1)) || \
414 g_unichar_type (gdk_keyval_to_unicode (k)) == G_UNICODE_NON_SPACING_MARK)
417 check_algorithmically (GtkIMContextSimple *context_simple,
422 gunichar combination_buffer[GTK_MAX_COMPOSE_LEN];
423 gchar *combination_utf8, *nfc;
425 if (n_compose >= GTK_MAX_COMPOSE_LEN)
428 for (i = 0; i < n_compose && IS_DEAD_KEY (context_simple->compose_buffer[i]); i++)
433 if (i > 0 && i == n_compose - 1)
435 combination_buffer[0] = gdk_keyval_to_unicode (context_simple->compose_buffer[i]);
436 combination_buffer[n_compose] = 0;
440 switch (context_simple->compose_buffer[i])
442 #define CASE(keysym, unicode) \
443 case GDK_dead_##keysym: combination_buffer[i+1] = unicode; break
445 CASE (grave, 0x0300);
446 CASE (acute, 0x0301);
447 CASE (circumflex, 0x0302);
448 CASE (tilde, 0x0303); /* Also used with perispomeni, 0x342. */
449 CASE (macron, 0x0304);
450 CASE (breve, 0x0306);
451 CASE (abovedot, 0x0307);
452 CASE (diaeresis, 0x0308);
454 CASE (abovering, 0x030A);
455 CASE (doubleacute, 0x030B);
456 CASE (caron, 0x030C);
457 CASE (abovecomma, 0x0313); /* Equivalent to psili */
458 CASE (abovereversedcomma, 0x0314); /* Equivalent to dasia */
459 CASE (horn, 0x031B); /* Legacy use for psili, 0x313 (or 0x343). */
460 CASE (belowdot, 0x0323);
461 CASE (cedilla, 0x0327);
462 CASE (ogonek, 0x0328); /* Legacy use for dasia, 0x314.*/
464 CASE (voiced_sound, 0x3099); /* Per Markus Kuhn keysyms.txt file. */
465 CASE (semivoiced_sound, 0x309A); /* Per Markus Kuhn keysyms.txt file. */
467 /* The following cases are to be removed once xkeyboard-config,
468 * xorg are fully updated.
470 /* Workaround for typo in 1.4.x xserver-xorg */
471 case 0xfe66: combination_buffer[i+1] = 0x314; break;
472 /* CASE (dasia, 0x314); */
473 /* CASE (perispomeni, 0x342); */
474 /* CASE (psili, 0x343); */
477 combination_buffer[i+1] = gdk_keyval_to_unicode (context_simple->compose_buffer[i]);
482 /* If the buffer normalizes to a single character,
483 * then modify the order of combination_buffer accordingly, if necessary,
486 if (check_normalize_nfc (combination_buffer, n_compose))
489 combination_utf8 = g_ucs4_to_utf8 (combination_buffer, -1, NULL, NULL, NULL);
490 nfc = g_utf8_normalize (combination_utf8, -1, G_NORMALIZE_NFC);
492 value = g_utf8_get_char (nfc);
493 gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
494 context_simple->compose_buffer[0] = 0;
496 g_free (combination_utf8);
506 /* In addition to the table-driven sequences, we allow Unicode hex
507 * codes to be entered. The method chosen here is similar to the
508 * one recommended in ISO 14755, but not exactly the same, since we
509 * don't want to steal 16 valuable key combinations.
511 * A hex Unicode sequence must be started with Ctrl-Shift-U, followed
512 * by a sequence of hex digits entered with Ctrl-Shift still held.
513 * Releasing one of the modifiers or pressing space while the modifiers
514 * are still held commits the character. It is possible to erase
515 * digits using backspace.
517 * As an extension to the above, we also allow to start the sequence
518 * with Ctrl-Shift-U, then release the modifiers before typing any
519 * digits, and enter the digits without modifiers.
521 #define HEX_MOD_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK)
524 check_hex (GtkIMContextSimple *context_simple,
527 /* See if this is a hex sequence, return TRUE if so */
534 context_simple->tentative_match = 0;
535 context_simple->tentative_match_len = 0;
537 str = g_string_new (NULL);
540 while (i < n_compose)
544 ch = gdk_keyval_to_unicode (context_simple->compose_buffer[i]);
549 if (!g_unichar_isxdigit (ch))
552 buf[g_unichar_to_utf8 (ch, buf)] = '\0';
554 g_string_append (str, buf);
559 n = strtoul (str->str, &nptr, 16);
561 /* if strtoul fails it probably means non-latin digits were used;
562 * we should in principle handle that, but we probably don't.
564 if (nptr - str->str < str->len)
566 g_string_free (str, TRUE);
570 g_string_free (str, TRUE);
572 if (g_unichar_validate (n))
574 context_simple->tentative_match = n;
575 context_simple->tentative_match_len = n_compose;
582 beep_window (GdkWindow *window)
586 gdk_window_get_user_data (window, (gpointer) &widget);
588 if (GTK_IS_WIDGET (widget))
590 gtk_widget_error_bell (widget);
594 GdkScreen *screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
597 g_object_get (gtk_settings_get_for_screen (screen),
598 "gtk-error-bell", &beep,
602 gdk_window_beep (window);
607 no_sequence_matches (GtkIMContextSimple *context_simple,
611 GtkIMContext *context;
614 context = GTK_IM_CONTEXT (context_simple);
616 /* No compose sequences found, check first if we have a partial
619 if (context_simple->tentative_match)
621 gint len = context_simple->tentative_match_len;
624 gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
625 context_simple->compose_buffer[0] = 0;
627 for (i=0; i < n_compose - len - 1; i++)
629 GdkEvent *tmp_event = gdk_event_copy ((GdkEvent *)event);
630 tmp_event->key.keyval = context_simple->compose_buffer[len + i];
632 gtk_im_context_filter_keypress (context, (GdkEventKey *)tmp_event);
633 gdk_event_free (tmp_event);
636 return gtk_im_context_filter_keypress (context, event);
640 context_simple->compose_buffer[0] = 0;
641 if (n_compose > 1) /* Invalid sequence */
643 beep_window (event->window);
647 ch = gdk_keyval_to_unicode (event->keyval);
650 gtk_im_context_simple_commit_char (context, ch);
659 is_hex_keyval (guint keyval)
661 gunichar ch = gdk_keyval_to_unicode (keyval);
663 return g_unichar_isxdigit (ch);
667 canonical_hex_keyval (GdkEventKey *event)
669 GdkKeymap *keymap = gdk_keymap_get_for_display (gdk_drawable_get_display (event->window));
671 guint *keyvals = NULL;
675 /* See if the keyval is already a hex digit */
676 if (is_hex_keyval (event->keyval))
677 return event->keyval;
679 /* See if this key would have generated a hex keyval in
680 * any other state, and return that hex keyval if so
682 gdk_keymap_get_entries_for_keycode (keymap,
683 event->hardware_keycode,
691 if (is_hex_keyval (keyvals[i]))
705 /* No way to make it a hex digit
711 gtk_im_context_simple_filter_keypress (GtkIMContext *context,
714 GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
717 gboolean have_hex_mods;
718 gboolean is_hex_start;
720 gboolean is_backspace;
725 while (context_simple->compose_buffer[n_compose] != 0)
728 if (event->type == GDK_KEY_RELEASE)
730 if (context_simple->in_hex_sequence &&
731 (event->keyval == GDK_Control_L || event->keyval == GDK_Control_R ||
732 event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R))
734 if (context_simple->tentative_match &&
735 g_unichar_validate (context_simple->tentative_match))
737 gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
738 context_simple->compose_buffer[0] = 0;
741 else if (n_compose == 0)
743 context_simple->modifiers_dropped = TRUE;
747 /* invalid hex sequence */
748 beep_window (event->window);
750 context_simple->tentative_match = 0;
751 context_simple->in_hex_sequence = FALSE;
752 context_simple->compose_buffer[0] = 0;
754 g_signal_emit_by_name (context_simple, "preedit-changed");
755 g_signal_emit_by_name (context_simple, "preedit-end");
764 /* Ignore modifier key presses */
765 for (i = 0; i < G_N_ELEMENTS (gtk_compose_ignore); i++)
766 if (event->keyval == gtk_compose_ignore[i])
769 if (context_simple->in_hex_sequence && context_simple->modifiers_dropped)
770 have_hex_mods = TRUE;
772 have_hex_mods = (event->state & (HEX_MOD_MASK)) == HEX_MOD_MASK;
773 is_hex_start = event->keyval == GDK_U;
774 is_hex_end = (event->keyval == GDK_space ||
775 event->keyval == GDK_KP_Space ||
776 event->keyval == GDK_Return ||
777 event->keyval == GDK_ISO_Enter ||
778 event->keyval == GDK_KP_Enter);
779 is_backspace = event->keyval == GDK_BackSpace;
780 is_escape = event->keyval == GDK_Escape;
781 hex_keyval = canonical_hex_keyval (event);
783 /* If we are already in a non-hex sequence, or
784 * this keystroke is not hex modifiers + hex digit, don't filter
785 * key events with accelerator modifiers held down.
787 if (!have_hex_mods ||
788 (n_compose > 0 && !context_simple->in_hex_sequence) ||
789 (n_compose == 0 && !context_simple->in_hex_sequence && !is_hex_start) ||
790 (context_simple->in_hex_sequence && !hex_keyval &&
791 !is_hex_start && !is_hex_end && !is_escape && !is_backspace))
793 if (event->state & (gtk_accelerator_get_default_mod_mask () & ~GDK_SHIFT_MASK) ||
794 (context_simple->in_hex_sequence && context_simple->modifiers_dropped &&
795 (event->keyval == GDK_Return ||
796 event->keyval == GDK_ISO_Enter ||
797 event->keyval == GDK_KP_Enter)))
803 /* Handle backspace */
804 if (context_simple->in_hex_sequence && have_hex_mods && is_backspace)
809 context_simple->compose_buffer[n_compose] = 0;
810 check_hex (context_simple, n_compose);
814 context_simple->in_hex_sequence = FALSE;
817 g_signal_emit_by_name (context_simple, "preedit-changed");
819 if (!context_simple->in_hex_sequence)
820 g_signal_emit_by_name (context_simple, "preedit-end");
825 /* Check for hex sequence restart */
826 if (context_simple->in_hex_sequence && have_hex_mods && is_hex_start)
828 if (context_simple->tentative_match &&
829 g_unichar_validate (context_simple->tentative_match))
831 gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
832 context_simple->compose_buffer[0] = 0;
836 /* invalid hex sequence */
838 beep_window (event->window);
840 context_simple->tentative_match = 0;
841 context_simple->in_hex_sequence = FALSE;
842 context_simple->compose_buffer[0] = 0;
846 /* Check for hex sequence start */
847 if (!context_simple->in_hex_sequence && have_hex_mods && is_hex_start)
849 context_simple->compose_buffer[0] = 0;
850 context_simple->in_hex_sequence = TRUE;
851 context_simple->modifiers_dropped = FALSE;
852 context_simple->tentative_match = 0;
854 g_signal_emit_by_name (context_simple, "preedit-start");
855 g_signal_emit_by_name (context_simple, "preedit-changed");
860 /* Then, check for compose sequences */
861 if (context_simple->in_hex_sequence)
864 context_simple->compose_buffer[n_compose++] = hex_keyval;
867 gtk_im_context_simple_reset (context);
871 else if (!is_hex_end)
873 /* non-hex character in hex sequence */
874 beep_window (event->window);
880 context_simple->compose_buffer[n_compose++] = event->keyval;
882 context_simple->compose_buffer[n_compose] = 0;
884 if (context_simple->in_hex_sequence)
886 /* If the modifiers are still held down, consider the sequence again */
889 /* space or return ends the sequence, and we eat the key */
890 if (n_compose > 0 && is_hex_end)
892 if (context_simple->tentative_match &&
893 g_unichar_validate (context_simple->tentative_match))
895 gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
896 context_simple->compose_buffer[0] = 0;
900 /* invalid hex sequence */
901 beep_window (event->window);
903 context_simple->tentative_match = 0;
904 context_simple->in_hex_sequence = FALSE;
905 context_simple->compose_buffer[0] = 0;
908 else if (!check_hex (context_simple, n_compose))
909 beep_window (event->window);
911 g_signal_emit_by_name (context_simple, "preedit-changed");
913 if (!context_simple->in_hex_sequence)
914 g_signal_emit_by_name (context_simple, "preedit-end");
921 tmp_list = context_simple->tables;
924 if (check_table (context_simple, tmp_list->data, n_compose))
926 tmp_list = tmp_list->next;
929 if (check_algorithmically (context_simple, n_compose))
932 if (check_compact_table (context_simple, >k_compose_table_compact, n_compose))
936 /* The current compose_buffer doesn't match anything */
937 return no_sequence_matches (context_simple, n_compose, event);
941 gtk_im_context_simple_reset (GtkIMContext *context)
943 GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
945 context_simple->compose_buffer[0] = 0;
947 if (context_simple->tentative_match || context_simple->in_hex_sequence)
949 context_simple->in_hex_sequence = FALSE;
950 context_simple->tentative_match = 0;
951 context_simple->tentative_match_len = 0;
952 g_signal_emit_by_name (context_simple, "preedit-changed");
953 g_signal_emit_by_name (context_simple, "preedit-end");
958 gtk_im_context_simple_get_preedit_string (GtkIMContext *context,
960 PangoAttrList **attrs,
963 char outbuf[37]; /* up to 6 hex digits */
966 GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
968 if (context_simple->in_hex_sequence)
975 while (context_simple->compose_buffer[hexchars] != 0)
977 len += g_unichar_to_utf8 (gdk_keyval_to_unicode (context_simple->compose_buffer[hexchars]),
984 else if (context_simple->tentative_match)
985 len = g_unichar_to_utf8 (context_simple->tentative_match, outbuf);
990 *str = g_strdup (outbuf);
994 *attrs = pango_attr_list_new ();
998 PangoAttribute *attr = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
999 attr->start_index = 0;
1000 attr->end_index = len;
1001 pango_attr_list_insert (*attrs, attr);
1010 * gtk_im_context_simple_add_table:
1011 * @context_simple: A #GtkIMContextSimple
1013 * @max_seq_len: Maximum length of a sequence in the table
1014 * (cannot be greater than #GTK_MAX_COMPOSE_LEN)
1015 * @n_seqs: number of sequences in the table
1017 * Adds an additional table to search to the input context.
1018 * Each row of the table consists of @max_seq_len key symbols
1019 * followed by two #guint16 interpreted as the high and low
1020 * words of a #gunicode value. Tables are searched starting
1021 * from the last added.
1023 * The table must be sorted in dictionary order on the
1024 * numeric value of the key symbol fields. (Values beyond
1025 * the length of the sequence should be zero.)
1028 gtk_im_context_simple_add_table (GtkIMContextSimple *context_simple,
1033 GtkComposeTable *table;
1035 g_return_if_fail (GTK_IS_IM_CONTEXT_SIMPLE (context_simple));
1036 g_return_if_fail (data != NULL);
1037 g_return_if_fail (max_seq_len <= GTK_MAX_COMPOSE_LEN);
1039 table = g_new (GtkComposeTable, 1);
1041 table->max_seq_len = max_seq_len;
1042 table->n_seqs = n_seqs;
1044 context_simple->tables = g_slist_prepend (context_simple->tables, table);
1047 #define __GTK_IM_CONTEXT_SIMPLE_C__
1048 #include "gtkaliasdef.c"