Back to index

im-sdk  12.3.91
Functions
iiim-interface.c File Reference
#include <config.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkdrawingarea.h>
#include <gtk/gtksignal.h>
#include <gdk/gdkx.h>
#include <gnome.h>
#include <X11/Xlib.h>
#include "gnome-im-switcher.h"
#include "widgets.h"
#include "language.h"
#include "iiim-interface.h"
#include "quick-access-menu.h"

Go to the source code of this file.

Functions

void process_hotkey (GimletWindow *, gpointer, int)
char * change_hotkey_with_trigger (char *, char *)
static void process_language_list (GimletWindow *gimlet, gpointer data, int count)
static void process_current_input_language (GimletWindow *gimlet, gpointer data, int length)
static void process_status_text (GimletWindow *gimlet, gpointer data, int length)
static void process_language_engine_list (GimletWindow *gimlet, gpointer data, int length)
static void process_conversion_mode (GimletWindow *gimlet, gpointer data, int length)
static void selection_request_switcher_window (GtkWidget *widget, GdkEventSelection *ev, GimletWindow *gimlet)
static void property_notify_switcher_window (GtkWidget *widget, GdkEventProperty *ev, GimletWindow *gimlet)
gboolean gimlet_iiim_selection_set (GimletWindow *gimlet)
void gimlet_iiim_language_set (GimletWindow *gimlet, const gchar *iiim_lang)
void gimlet_iiim_conversion_mode_set (GimletWindow *gimlet, const gchar *conversion_mode)
void gimlet_iiim_hotkey_set (GimletWindow *gimlet, const gchar *trigger)

Function Documentation

static char * change_hotkey_with_trigger ( char *  s,
char *  trigger 
)

Definition at line 364 of file iiim-interface.c.

{
  char *label_delimiter = ":";
  char **hotkeys = g_strsplit (s, label_delimiter, -1);
  int num_hotkeys = 0;
  int i;

  // num_hotkeys = g_strv_length (hotkeys)/2;
  while (hotkeys[num_hotkeys]) ++num_hotkeys;
  num_hotkeys /= 2;

  for (i = 0; i < num_hotkeys; ++i)
    {
      if (!strcmp (hotkeys[i * 2], TRIGGER_KEY_LABEL))
        {
          g_free (hotkeys[i * 2 + 1]);
          hotkeys[i * 2 + 1] = strdup (trigger);
        }
    }

  return g_strjoinv (label_delimiter, hotkeys);
}

Here is the caller graph for this function:

void gimlet_iiim_conversion_mode_set ( GimletWindow *  gimlet,
const gchar *  conversion_mode 
)

Definition at line 313 of file iiim-interface.c.

{
  g_return_if_fail (conversion_mode != NULL);

  gdk_property_change (gimlet->last_client,
                     gimlet->set_conversion_mode_atom,
                     gimlet->set_conversion_mode_atom,
                     8,
                     GDK_PROP_MODE_REPLACE,
                     (guchar *)conversion_mode,
                     strlen (conversion_mode) + 1); /* including last NULL */
}

Here is the caller graph for this function:

void gimlet_iiim_hotkey_set ( GimletWindow *  gimlet,
const gchar *  trigger 
)

Definition at line 388 of file iiim-interface.c.

{
  char *hotkey;

  g_return_if_fail (trigger != NULL);

  hotkey = change_hotkey_with_trigger (gimlet->hotkey, trigger);

  gdk_property_change (gimlet->invisible->window,
                       gimlet->set_hotkey_atom,
                       gimlet->set_hotkey_atom,
                       8,
                       GDK_PROP_MODE_REPLACE,
                       (guchar *)hotkey,
                       strlen (hotkey) + 1); /* including last NULL */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gimlet_iiim_language_set ( GimletWindow *  gimlet,
const gchar *  iiim_lang 
)

Definition at line 298 of file iiim-interface.c.

{
  g_return_if_fail (iiim_lang != NULL);

  gdk_property_change (gimlet->last_client,
                     gimlet->set_current_input_language_atom,
                     gimlet->set_current_input_language_atom,
                     8,
                     GDK_PROP_MODE_REPLACE,
                     (guchar *)iiim_lang,
                     strlen (iiim_lang) + 1); /* including last NULL */
}

Here is the caller graph for this function:

gboolean gimlet_iiim_selection_set ( GimletWindow *  gimlet)

Definition at line 230 of file iiim-interface.c.

{
  GdkAtom atom = GDK_NONE;
  GdkWindow *owner = NULL;
  GdkDisplay *display;
  GdkScreen *screen;

  display = gtk_widget_get_display (GTK_WIDGET(gimlet->applet));
  screen = gtk_widget_get_screen (GTK_WIDGET(gimlet->applet));
  atom = gdk_atom_intern ("_IIIM_SWITCHER", FALSE);
  if (atom == GDK_NONE)
    return FALSE;

  owner = gdk_selection_owner_get_for_display (display, atom);
  if (owner)
    {
      g_warning ("There is IIIM input method switcher already.");
      return FALSE;
    }

  gimlet->invisible = gtk_invisible_new_for_screen (screen);
  gtk_widget_realize (gimlet->invisible);

  if (!gtk_selection_owner_set_for_display (display, 
                                       gimlet->invisible,
                                       atom,
                                       GDK_CURRENT_TIME))
    {
      g_warning ("Cannot become IIIM input method switcher selection atom owner.");
      return FALSE;
    }
  gimlet->selection = atom;

  atom = gdk_atom_intern ("_IIIM_SWITCHER_CURRENT_INPUT_LANGUAGE", FALSE);
  gimlet->set_current_input_language_atom = atom;

  atom = gdk_atom_intern ("_IIIM_SWITCHER_CURRENT_CLIENT", FALSE);
  gimlet->set_current_client_atom = atom;

  atom = gdk_atom_intern ("_IIIM_SWITCHER_INPUT_LANGUAGE_LIST", FALSE);
  gimlet->set_input_language_list_atom = atom;

  atom = gdk_atom_intern ("_IIIM_SWITCHER_STATUS_TEXT", FALSE);
  gimlet->set_status_text_atom = atom;

  atom = gdk_atom_intern ("_IIIM_SWITCHER_SET_CONVERSION_MODE", FALSE);
  gimlet->set_conversion_mode_atom = atom;

  atom = gdk_atom_intern ("_IIIM_SWITCHER_LANGUAGE_ENGINE_LIST", FALSE);
  gimlet->set_language_engine_list_atom = atom;

  atom = gdk_atom_intern ("_IIIM_SWITCHER_SET_HOTKEY", FALSE);
  gimlet->set_hotkey_atom = atom;

  gtk_widget_add_events (gimlet->invisible,
                      GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);

  g_signal_connect (G_OBJECT (gimlet->invisible),
                  "selection-request-event",
                  G_CALLBACK (selection_request_switcher_window),
                  gimlet);
  g_signal_connect (G_OBJECT (gimlet->invisible), "property-notify-event",
                  G_CALLBACK (property_notify_switcher_window),
                  gimlet);
  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void process_conversion_mode ( GimletWindow *  gimlet,
gpointer  data,
int  length 
) [static]

Definition at line 164 of file iiim-interface.c.

{
  gimlet->conversion_mode = ((gulong*)data)[0];
  gimlet_update_lang (gimlet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void process_current_input_language ( GimletWindow *  gimlet,
gpointer  data,
int  length 
) [static]

Definition at line 85 of file iiim-interface.c.

{
  switch (gimlet->input_lang_policy)
    {
    case FOLLOW_APPLICATION :
      if (gimlet->current_iiim_lang)
       g_free (gimlet->current_iiim_lang);

      gimlet->current_iiim_lang = g_strndup (data, length);

      gimlet_language_add_active_language (gimlet, gimlet->current_iiim_lang);
      break;
    case FOLLOW_QUICK_ACCESS_MENU:
      /*
       notify the application of the language currently selected in quick
       access menu
      */
      gimlet_iiim_language_set (gimlet, gimlet->current_iiim_lang);
      break;
#ifdef MEANINGLESS_OPTION_PERHAPS
    case FOLLOW_OPTION_MENU:
      /*
       notify the application of the language currently selected in option
       menu
      */
      gimlet_iiim_language_set (gimlet, gimlet->iiim_lang_in_option_menu);

      if (gimlet->current_iiim_lang)
       g_free (gimlet->current_iiim_lang);

      gimlet->current_iiim_lang = g_strdup (gimlet->iiim_lang_in_option_menu);

      gimlet_language_add_active_language (gimlet, gimlet->current_iiim_lang);

      break;
    case FOLLOW_CURRENT_LOCALE:
      break;
#endif
    }

  gimlet_update_lang (gimlet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void process_hotkey ( GimletWindow *  gimlet,
gpointer  data,
int  length 
)

Definition at line 328 of file iiim-interface.c.

{
  char *trigger, *old_trigger;
  char *hotkey = g_strndup (data, length);

  /*
   * FIXME why process_hotkey would be invoked when put focus on the TRIGGER entry
   * of the hotkey configuration window?
   */

  /*
   * FIXME override hotkey with the trigger value from gconf.
   */
#if 0
  old_trigger = gconf_get_conversion_keys (gimlet);
  trigger = get_trigger_from_hotkey (hotkey);
  if (old_trigger && strcasecmp (old_trigger, trigger) != 0)
    {
      char *tmp_hotkey = change_hotkey_with_trigger (hotkey, old_trigger);

      g_free (hotkey);
      hotkey = tmp_hotkey;
    }

  g_free (old_trigger);
  g_free (trigger);
#endif

  g_free (gimlet->hotkey);
  gimlet->hotkey = g_strdup (hotkey);

  g_free (hotkey);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void process_language_engine_list ( GimletWindow *  gimlet,
gpointer  data,
int  length 
) [static]

Definition at line 154 of file iiim-interface.c.

{
  g_free (gimlet->le_list);
  gimlet->le_list = g_strndup (data, length);
  return;
}

Here is the caller graph for this function:

static void process_language_list ( GimletWindow *  gimlet,
gpointer  data,
int  count 
) [static]

Definition at line 39 of file iiim-interface.c.

{
  gchar *new_lang_list = g_strndup (data, count);
  const gchar *delimiter = ";";
  gchar **new_client_lang_list;

  new_client_lang_list = g_strsplit (new_lang_list, delimiter, -1);
  g_free (new_lang_list);

  if (gimlet->client_lang_list)
    {
      gchar **p;
      gchar **q;
      gboolean update = FALSE;
      for (p = gimlet->client_lang_list, q = new_client_lang_list;
          *p && *q;
          p++, q++)
       if (strcmp (*p, *q))
         {
           update = TRUE;
           break;
         }
      if (update == FALSE)
       {
         g_strfreev (new_client_lang_list);
         return;
       }
      else
       g_strfreev (gimlet->client_lang_list);
    }
  gimlet->client_lang_list = new_client_lang_list;

  gimlet_language_init (gimlet);

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void process_status_text ( GimletWindow *  gimlet,
gpointer  data,
int  length 
) [static]

Definition at line 130 of file iiim-interface.c.

{
  gchar *text = (char *) data;
  gchar *display_name;

  if (length == 1 && text[0] == 0x20)
    {
      display_name = g_strdup ("");
      gimlet->conversion_mode = FALSE;
    }    
  else
    {
      display_name = g_strndup (text, length);
      gimlet->conversion_mode = TRUE;
    }

  gimlet_status_set_text (gimlet, display_name);
  g_free (display_name);

  gimlet_update_lang (gimlet);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void property_notify_switcher_window ( GtkWidget *  widget,
GdkEventProperty *  ev,
GimletWindow *  gimlet 
) [static]

Definition at line 198 of file iiim-interface.c.

{
  GdkAtom  type;
  guchar   *data = NULL;
  gint     format;
  gint     length = 0;

  gdk_property_get (widget->window, ev->atom, ev->atom,
                  0, INT_MAX, FALSE,
                  &type, &format, &length, &data);
  if (data)
    {
      if (type == gimlet->set_input_language_list_atom)
       process_language_list (gimlet, data, length);
      else if (type == gimlet->set_current_input_language_atom)
       process_current_input_language (gimlet, data, length);
      else if (type == gimlet->set_status_text_atom)
       process_status_text (gimlet, data, length);
      else if (type == gimlet->set_conversion_mode_atom)
       process_conversion_mode (gimlet, data, length);
      else if (type == gimlet->set_language_engine_list_atom)
       process_language_engine_list (gimlet, data, length);
      else if (type == gimlet->set_hotkey_atom)
       process_hotkey (gimlet, data, length);

      g_free (data);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void selection_request_switcher_window ( GtkWidget *  widget,
GdkEventSelection *  ev,
GimletWindow *  gimlet 
) [static]

Definition at line 172 of file iiim-interface.c.

{
  GdkDisplay *display = gtk_widget_get_display (widget);

  if (ev->target == gimlet->set_current_client_atom)
    {
      gimlet->last_client =
       gdk_window_foreign_new_for_display (display, ev->requestor);
    }
  else if (ev->target == gimlet->selection)
    {
#if PLACE_HOLDER
      gdk_property_change (ev->requestor,
                        gimlet->selection,
                        gimlet->selection,
                        8,
                        GDK_PROP_MODE_REPLACE,
                        (guchar *)"dummy",
                        strlen ("dummy"));
#endif
    }
  gimlet_update_lang (gimlet);
}

Here is the call graph for this function:

Here is the caller graph for this function: