--- gtkimcontextsimple.c.SUBMITTED	2008-09-09 01:32:51.000000000 +0100
+++ gtkimcontextsimple.c	2008-09-09 03:42:00.000000000 +0100
@@ -28,9 +28,11 @@
 #include "gtkwidget.h"
 #include "gtkintl.h"
 #include "gtkalias.h"
+#include "gtkimcontextsimplemultiseqs.h"
 
 typedef struct _GtkComposeTable GtkComposeTable;
 typedef struct _GtkComposeTableCompact GtkComposeTableCompact;
+typedef struct _GtkComposeTableMulti GtkComposeTableMulti;
 
 struct _GtkComposeTable 
 {
@@ -47,6 +49,14 @@
   gint n_index_stride;
 };
 
+struct _GtkComposeTableMulti
+{
+  const guint16 *data;
+  gint max_seq_len;
+  gint max_codepoint_len;
+  gint n_seqs;
+};
+
 /* This file contains the table of the compose sequences, 
  * static const guint16 gtk_compose_seqs_compact[] = {}
  * IT is generated from the compose-parse.py script.
@@ -65,6 +75,22 @@
   6
 };
 
+static const GtkComposeTableMulti gtk_compose_table_multi = {
+  gtk_compose_multi_seqs,
+  1,
+  2,
+  9 
+};
+
+/* 
+ *  static const GtkComposeTableMulti gtk_compose_table_multi = {
+ *  gtk_compose_multi_seqs,
+ *  compose_multi_max_sequence_len,
+ *  compose_multi_index_size,
+ *  compose_multi_max_sequence_len + compose_multi_max_codepoint_len
+ *  };
+ */
+
 static const guint16 gtk_compose_ignore[] = {
   GDK_Shift_L,
   GDK_Shift_R,
@@ -340,6 +366,108 @@
   return FALSE;
 }
 
+static int
+compare_seq_multi (const void *key, const void *value)
+{
+  int i = 0;
+  const guint *keysyms = key;
+  const guint16 *seq = value;
+
+  while (keysyms[i])
+    {
+      if (i < compose_multi_max_sequence_len)
+        {
+          if (keysyms[i] < seq[i])
+	    return -1;
+          else if (keysyms[i] > seq[i])
+	    return 1;
+        }
+      else
+        return -1;
+
+      i++;
+    }
+
+  return 0;
+}
+
+/*
+ *
+ *
+ *
+ *
+ *
+ */
+static gboolean
+check_multi_table (GtkIMContextSimple   *context_simple,
+	     const GtkComposeTableMulti *table,
+	     gint                        n_compose)
+{
+  guint16 *seq; 
+  guint row_stride = table->max_seq_len + table->max_codepoint_len;
+  
+  /* Will never match, if the sequence in the compose buffer is longer
+   * than the sequences in the table.  Further, compare_seq (key, val)
+   * will overrun val if key is longer than val. */
+  if (n_compose > table->max_seq_len)
+    return FALSE;
+  
+  seq = bsearch (context_simple->compose_buffer,
+		 table->data, table->n_seqs,
+		 sizeof (guint16) *  row_stride, 
+		 compare_seq_multi);
+
+  if (seq)
+    {
+      guint16 *prev_seq;
+
+      /* Back up to the first sequence that matches to make sure
+       * we find the exact match if their is one.
+       */
+      while (seq > table->data)
+	{
+	  prev_seq = seq - row_stride;
+	  if (compare_seq_multi (context_simple->compose_buffer, prev_seq) != 0)
+	    break;
+	  seq = prev_seq;
+	}
+      
+      if (n_compose == table->max_seq_len ||
+	  seq[n_compose] == 0) /* complete sequence */
+	{
+          gint i;
+	  guint16 *next_seq;
+	  gunichar value = 
+	    0x10000 * seq[table->max_seq_len] + seq[table->max_seq_len + 1];
+
+	  /* We found a tentative match. See if there are any longer
+	   * sequences containing this subsequence
+	   */
+	  next_seq = seq + row_stride;
+	  if (next_seq < table->data + row_stride * table->n_seqs)
+	    {
+	      if (compare_seq_multi (context_simple->compose_buffer, next_seq) == 0)
+		{
+		  context_simple->tentative_match = value;
+		  context_simple->tentative_match_len = n_compose;
+		
+		  g_signal_emit_by_name (context_simple, "preedit-changed");
+
+		  return TRUE;
+		}
+	    }
+
+          for (i = 0; i < compose_multi_max_codepoint_len; i++ )
+	  	gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), seq[compose_multi_max_sequence_len + i]);
+	  context_simple->compose_buffer[0] = 0;
+	}
+      
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 /* This function receives a sequence of Unicode characters and tries to
  * normalize it (NFC). We check for the case the the resulting string
  * has length 1 (single character).
@@ -930,6 +1058,9 @@
 
       if (check_compact_table (context_simple, &gtk_compose_table_compact, n_compose))
         return TRUE;
+
+      if (check_multi_table (context_simple, &gtk_compose_table_multi, n_compose))
+        return TRUE;
     }
   
   /* The current compose_buffer doesn't match anything */
