Back to index

im-sdk  12.3.91
Functions
imswitcher.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

gboolean im_info_switcher_active (GtkIIIMInfo *info)
gboolean im_info_switcher_new (GtkIIIMInfo *info)
void im_info_switcher_shutdown (GtkIIIMInfo *info)
void im_context_switcher_new (GtkIMContextIIIM *context_iiim)
void im_context_switcher_finalize (GtkIMContextIIIM *context_iiim)
void im_context_switcher_set_switcher_list (GtkIMContextIIIM *context_iiim, gchar *switcher_list)
void im_context_switcher_set_language_list (GtkIMContextIIIM *context_iiim, IIIMCF_language *lang_list, int n_lang)
void im_context_switcher_set_status_text (GtkIMContextIIIM *context_iiim, gchar *utf8)
void im_context_switcher_set_focus (GtkIMContextIIIM *context_iiim)
void im_context_switcher_set_input_language (GtkIMContextIIIM *context_iiim, gchar *input_lang)
void im_context_switcher_set_language_engine_list (GtkIMContextIIIM *context_iiim, gchar *le_list)
void im_context_switcher_set_conversion_mode (GtkIMContextIIIM *context_iiim)
char * im_context_switcher_get_hotkey_with_atom (GtkIMContextIIIM *)
char * im_context_switcher_get_hotkey (GtkIMContextIIIM *)
void im_context_switcher_set_hotkey (GtkIMContextIIIM *, char *)
char * im_context_switcher_get_hotkey_with_type (char *, char *)
void im_context_switcher_change_hotkey_with_type (GtkIMContextIIIM *, char *, char *)

Function Documentation

void im_context_switcher_change_hotkey_with_type ( GtkIMContextIIIM *  ,
char *  ,
char *   
)
void im_context_switcher_finalize ( GtkIMContextIIIM *  context_iiim)

Definition at line 610 of file imswitcher.c.

{
  SwitcherContext *w = context_iiim->switcher_context;

  if (w == NULL)
    return;
  g_signal_handler_disconnect (G_OBJECT (w->invisible), w->destroy_handler_id);
  g_signal_handler_disconnect (G_OBJECT (w->invisible), w->property_handler_id);
  gtk_widget_destroy (w->invisible);
  g_free (w);
  context_iiim->switcher_context = NULL;
  return;
}

Here is the caller graph for this function:

char* im_context_switcher_get_hotkey ( GtkIMContextIIIM *  )

Definition at line 652 of file imswitcher.c.

{
  int num_hotkey = 0, i;
  IIIMCF_hotkey *hotkeys;
  char s[512], *p = s;

  memset (s, 0, 512);

  iiimcf_get_hotkeys (context_iiim->context, &num_hotkey, &hotkeys);

  if (num_hotkey == 0) return NULL;

  for (i = 0; i < num_hotkey; ++i)
    {
      char label_delimiter = ':';
      char key_delimiter = ',';
      int k;

      strcpy (p, hotkeys[i].hotkey_label);
      p += strlen (hotkeys[i].hotkey_label);
      *p++ = label_delimiter;

      for (k = 0; k < hotkeys[i].nkeys; ++k)
       {
         IIIMCF_keyevent *key = hotkeys[i].keys + k;
         GdkEventKey event;
         char *keyname;

         if (k) *p++ = key_delimiter;

         if (key->modifier & IIIMF_CONTROL_MODIFIER)
           {
             strcpy (p, "Ctrl+");
             p += strlen ("Ctrl+");
           }
         if (key->modifier & IIIMF_SHIFT_MODIFIER)
           {
             strcpy (p, "Shift+");
             p += strlen ("Shift+");
           }
         if (key->modifier & IIIMF_ALT_MODIFIER)
           {
             strcpy (p, "Alt+");
             p += strlen ("Alt+");
           }

         convert_IIIMCF_keyevent_to_GdkEventKey (key, &event);
         keyname = gdk_keyval_name (event.keyval);

         if (keyname)
           {
             strcpy (p, keyname);
             p += strlen (keyname);
           }
       }

      if (i < num_hotkey - 1) *p++ = label_delimiter;
    }

  return strdup (s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* im_context_switcher_get_hotkey_with_atom ( GtkIMContextIIIM *  )

Definition at line 844 of file imswitcher.c.

{
  SwitcherInfo *sw_info = im_info_get_switcher_info (context_iiim->iiim_info);
  GdkScreen *screen;
  GdkDisplay *display;
  Atom x_atom;
  int format;
  unsigned long length, nitem;
  unsigned char *data = NULL;
  Atom type;

  if (!im_info_switcher_active (context_iiim->iiim_info))
    return NULL;

  screen = im_info_get_screen (context_iiim->iiim_info);
  display = gdk_screen_get_display (screen);
  x_atom = gdk_x11_atom_to_xatom_for_display (display, sw_info->set_hotkey_atom);

  XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
                    sw_info->switcher_x_window,
                    x_atom,
                    0, INT_MAX, False, x_atom,
                    &type, &format, &nitem, &length, &data);

  return data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* im_context_switcher_get_hotkey_with_type ( char *  ,
char *   
)

Definition at line 625 of file imswitcher.c.

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

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

  for (i = 0; i < num_hotkeys; ++i)
    {
      if (!strcasecmp (hotkeys[i * 2], type))
       {
         keys = strdup (hotkeys[i * 2 + 1]);
         break;
       }
    }

  g_strfreev (hotkeys);

  return keys;
}

Here is the caller graph for this function:

void im_context_switcher_new ( GtkIMContextIIIM *  context_iiim)

Definition at line 486 of file imswitcher.c.

{
  SwitcherContext *w = g_new0 (SwitcherContext, 1);

  g_return_if_fail (context_iiim != NULL);
  g_return_if_fail (context_iiim->iiim_info != NULL);

  w->invisible = gtk_invisible_new ();
  gtk_widget_realize (w->invisible);

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

  w->destroy_handler_id =
    g_signal_connect (G_OBJECT (w->invisible), "destroy",      
                    G_CALLBACK (destroy_switcher_window),
                    context_iiim);

  w->property_handler_id = 
    g_signal_connect (G_OBJECT (w->invisible), "property-notify-event",
                    G_CALLBACK (property_notify_switcher_window),
                    context_iiim);
  context_iiim->switcher_context = w;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_conversion_mode ( GtkIMContextIIIM *  context_iiim)

Definition at line 246 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  IIIMF_status st;
  gint conversion_mode = FALSE;

  if (sw_info == NULL)
    return;

  st = iiimcf_get_current_conversion_mode (context_iiim->context,
                                      &conversion_mode);

  if (sw_info->switcher)
    {
      gdk_property_change (sw_info->switcher, 
                        sw_info->set_conversion_mode_atom,
                        sw_info->set_conversion_mode_atom,
                        32,
                        GDK_PROP_MODE_REPLACE,
                        (unsigned char*)&conversion_mode,
                        1);
    }
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                            sw_info->set_conversion_mode_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     32,
                     PropModeReplace,
                     (guchar *)&conversion_mode,
                     1);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_focus ( GtkIMContextIIIM *  context_iiim)

Definition at line 519 of file imswitcher.c.

{
  SwitcherContext *w;
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info;

  if (!im_info_switcher_active (info))
    {
      im_info_switcher_new (info);
      if (!im_info_switcher_active (info))
       return;
    }

  if (context_iiim->switcher_context == NULL)
    im_context_switcher_new (context_iiim);

  w = context_iiim->switcher_context;
  sw_info = im_info_get_switcher_info (info);
  if (w && w->invisible)
    gdk_selection_convert (w->invisible->window,
                        sw_info->selection_atom,
                        sw_info->set_current_client_atom,
                        gtk_get_current_event_time ());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_hotkey ( GtkIMContextIIIM *  ,
char *   
)

Definition at line 289 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info == NULL || hotkey == NULL)
    return;

  if (sw_info->switcher)
    {
      gdk_property_change (sw_info->switcher,
                           sw_info->set_hotkey_atom,
                           sw_info->set_hotkey_atom,
                           8,
                           GDK_PROP_MODE_REPLACE,
                           (unsigned char*)hotkey,
                           strlen (hotkey));
    }
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                               sw_info->set_hotkey_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                       sw_info->switcher_x_window,
                       x_atom,
                       x_atom,
                       8,
                       PropModeReplace,
                       (guchar *)hotkey,
                       strlen (hotkey));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_input_language ( GtkIMContextIIIM *  context_iiim,
gchar *  input_lang 
)

Definition at line 327 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info == NULL)
    return;

  if (input_lang == NULL)
    input_lang = context_iiim->current_language;
  if (sw_info->switcher && input_lang)
    {
      gdk_property_change (sw_info->switcher, 
                        sw_info->set_current_input_language_atom,
                        sw_info->set_current_input_language_atom,
                        8,
                        GDK_PROP_MODE_REPLACE,
                        (unsigned char*)input_lang,
                        strlen (input_lang));
    }
  else if (sw_info->switcher_x_window && input_lang)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                            sw_info->set_current_input_language_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)input_lang,
                     strlen (input_lang));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_language_engine_list ( GtkIMContextIIIM *  context_iiim,
gchar *  le_list 
)

Definition at line 367 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  gsize len;

  if (sw_info == NULL)
    return;

  len = strlen (le_list);

  if (len == 0)
    return;

  if (sw_info->switcher)
    gdk_property_change (sw_info->switcher, 
                      sw_info->set_language_engine_list_atom,
                      sw_info->set_language_engine_list_atom,
                      8,
                      GDK_PROP_MODE_REPLACE,
                      (guchar*)le_list, len);
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                                                 sw_info->set_language_engine_list_atom);
      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)le_list, len);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_language_list ( GtkIMContextIIIM *  context_iiim,
IIIMCF_language lang_list,
int  n_lang 
)

Definition at line 406 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  gchar *languages;
  gchar *ptr;
  IIIMF_status st;
  char *langid;
  gint i;
  gsize len;
  const char *separator = ";";
  gsize separator_len;

  if (sw_info == NULL)
    return;

  if (lang_list == NULL || n_lang == 0)
    return;

  /* First part, getting length */
  st = iiimcf_get_language_id (lang_list[0],
                            (const char **) &langid);
  if (st != IIIMF_STATUS_SUCCESS)
    return;

  separator_len = strlen (separator);
  len = strlen (langid);
  for (i = 1; i < n_lang; i++)
    {
      st = iiimcf_get_language_id (lang_list[i],
                               (const char **) &langid);
      if (st != IIIMF_STATUS_SUCCESS)
       continue;
      len += strlen (langid);
    }
  len += separator_len * (i - 1);

  /* Second part, building string */
  languages = g_new (gchar, len + 1);

  st = iiimcf_get_language_id (lang_list[0],
                            (const char **) &langid);
  ptr = g_stpcpy (languages, langid);
  for (i = 1; i < n_lang; i++)
    {
      ptr = g_stpcpy (ptr, separator);
      st = iiimcf_get_language_id (lang_list[i],
                               (const char **) &langid);
      if (st != IIIMF_STATUS_SUCCESS)
       continue;
      ptr = g_stpcpy (ptr, langid);
    }

  if (sw_info->switcher)
    gdk_property_change (sw_info->switcher, 
                      sw_info->set_input_language_list_atom,
                      sw_info->set_input_language_list_atom,
                      8,
                      GDK_PROP_MODE_REPLACE,
                      (guchar*)languages, len);
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                                                 sw_info->set_input_language_list_atom);
      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)languages, len);
    }
  g_free (languages);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_status_text ( GtkIMContextIIIM *  context_iiim,
gchar *  utf8 
)

Definition at line 208 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info == NULL)
    return;

  if (sw_info->switcher)
    {
      gdk_property_change (sw_info->switcher, 
                        sw_info->set_status_text_atom,
                        sw_info->set_status_text_atom,
                        8,
                        GDK_PROP_MODE_REPLACE,
                        (unsigned char*)utf8,
                        strlen (utf8));
    }
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                               sw_info->set_status_text_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)utf8,
                     strlen (utf8));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_switcher_list ( GtkIMContextIIIM *  context_iiim,
gchar *  switcher_list 
)
gboolean im_info_switcher_active ( GtkIIIMInfo *  info)

Definition at line 512 of file imswitcher.c.

{
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  return (sw_info && (sw_info->switcher || sw_info->switcher_x_window));
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean im_info_switcher_new ( GtkIIIMInfo *  info)

Definition at line 79 of file imswitcher.c.

{
  GdkAtom selection = GDK_NONE;
  SwitcherInfo *sw_info;

  if (info == NULL)
    return FALSE;

  selection = gdk_atom_intern ("_IIIM_SWITCHER", FALSE);

  sw_info = im_info_get_switcher_info (info);
  if (sw_info == NULL)
    {
      sw_info = g_new0 (SwitcherInfo, 1);
      im_info_set_switcher_info (info, sw_info);
    }

  if (selection != GDK_NONE)
    sw_info->switcher = gdk_selection_owner_get (selection);

  sw_info->selection_atom = selection;

  if (sw_info->switcher)
    gdk_window_add_filter (sw_info->switcher,
                        switcher_owner_filter, info);
  else
    {
      /*
       this could be due to bugzilla 126375, hence try to
       do Xlib directly.
      */
      GdkScreen *screen;
      GdkDisplay *display;
      Atom x_atom;
      Window xwindow;

      screen = im_info_get_screen (info);
      if (screen == None)
         return FALSE;

      display = gdk_screen_get_display (screen);
      x_atom = gdk_x11_atom_to_xatom_for_display (display, 
                                            selection);
      xwindow = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
                                x_atom);
      if (xwindow == None)
       {
         DEBUG_DO (g_message ("Unable to find input method switcher"));
         return FALSE;
       }
      sw_info->switcher_x_window = xwindow;

      _XRegisterFilterByType (GDK_DISPLAY_XDISPLAY (display), xwindow,
                           DestroyNotify, DestroyNotify,
                           filter_destroy_event, info);
      XSelectInput (GDK_DISPLAY_XDISPLAY (display), xwindow, StructureNotifyMask);
    }

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

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

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

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

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

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

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

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_info_switcher_shutdown ( GtkIIIMInfo *  info)

Definition at line 589 of file imswitcher.c.

{
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  if (sw_info)
    {
      if (sw_info->switcher)
       gdk_window_remove_filter (sw_info->switcher,
                              switcher_owner_filter, info);
      else if (sw_info->switcher_x_window)
       {
         GdkScreen *screen = im_info_get_screen (info);
         GdkDisplay *display = gdk_screen_get_display (screen);

         _XUnregisterFilter (GDK_DISPLAY_XDISPLAY (display), 
                           sw_info->switcher_x_window,
                           filter_destroy_event, info);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function: