/* Finish composing, provide the character, and clear our compose buffer.
 */
static void
accept_character (GtkImContextMultipress *multipress_context, const gchar *characters)
{
  /* Clear the compose buffer, so we are ready to compose the next character.
   * Note that if we emit "preedit-changed" after "commit", there's a segfault/
   * invalid-write with GtkTextView in gtk_text_layout_free_line_display(), when
   * destroying a PangoLayout (this can also be avoided by not using any Pango
   * attributes in get_preedit_string(). */
  clear_compose_buffer (multipress_context);

  /* Provide the character to GTK+ */
  g_signal_emit_by_name (multipress_context, "commit", characters);
}
Example #2
0
static gboolean
tamil99_filter_keypress (GtkIMContext *context,
                         GdkEventKey  *event)
{
  ComposeSequence *comp_seq;
  gint i;

  if (event->type == GDK_KEY_RELEASE)
    return FALSE;

  /* don't filter key events with accelerator modifiers held down */
  if (event->state 
      & (gtk_accelerator_get_default_mod_mask () & ~GDK_SHIFT_MASK))
    return FALSE;

  for (i = 0;  i < G_N_ELEMENTS (tamil99_compose_ignore);  i++)
    if (event->keyval == tamil99_compose_ignore[i])
      return FALSE;

  /* '|' commits what we have */
  if (event->keyval == GDK_bar && n_compose > 0) 
    {
      comp_seq = find_complete_compose_sequence (compose_buffer);
      if (comp_seq != NULL)
        {
          g_signal_emit_by_name (context, "commit", comp_seq->string);
          clear_compose_buffer ();
        }

      g_signal_emit_by_name (context, "preedit-changed");
      return TRUE;
    }

  compose_buffer[n_compose] = event->keyval;
  n_compose++;

  if (find_incomplete_compose_sequence (compose_buffer) != NULL)
    {
      g_signal_emit_by_name (context, "preedit-changed");
      return TRUE;
    }

  comp_seq = find_complete_compose_sequence (compose_buffer);
  if (comp_seq != NULL)
    {
      g_signal_emit_by_name (context, "commit", comp_seq->string);
      clear_compose_buffer ();
      g_signal_emit_by_name (context, "preedit-changed");
      return TRUE;
    }

  /* if we reach this point, the sequence *with the key just pressed*
   * cannot be a complete or incomplete match, so: commit the old sequence,
   * then reprocess this key */

  n_compose--;
  compose_buffer[n_compose] = 0;

  if (n_compose > 0)
    {
      comp_seq = find_complete_compose_sequence (compose_buffer);
      g_signal_emit_by_name (context, "commit", comp_seq->string);
      clear_compose_buffer ();
      g_signal_emit_by_name (context, "preedit-changed");

      return tamil99_filter_keypress (context, event);
    }

  return no_sequence_matches (context, event);
}
Example #3
0
static void
tamil99_reset (GtkIMContext *context)
{
  clear_compose_buffer ();
  g_signal_emit_by_name (context, "preedit-changed");
}
static void
vfunc_reset (GtkIMContext *context)
{
  clear_compose_buffer (GTK_IM_CONTEXT_MULTIPRESS (context));
}