Back to index

im-sdk  12.3.91
Typedefs | Functions
language.h File Reference
#include "gnome-im-switcher.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct _GimletLanguage

Functions

void gimlet_language_init (GimletWindow *gimlet)
GtkWidget * gimlet_langmenu_dialog_new (GtkWindow *transient_parent, GimletWindow *gimlet)
void gimlet_language_free (GimletLanguage *language)
gchar * gimlet_language_get_name (GimletLanguage *data)
gchar * gimlet_language_get_iiim_lang_name (GimletLanguage *data)
gchar * gimlet_language_get_conversion_mode (char *iiim_lang_name)
gchar * gimlet_language_find_name (char *iiim_lang_name)
gchar * gimlet_language_find_description (char *iiim_lang_name)
gchar * gimlet_language_find_short (char *iiim_lang_name)
GSList * gimlet_language_get_active_languages (void)
void gimlet_language_add_active_language (GimletWindow *gimlet, char *iiim_lang_name)
GtkWidget * gimlet_hotkey_dialog_new (GtkWidget *, GimletWindow *)

Typedef Documentation

typedef struct _GimletLanguage

Definition at line 27 of file language.h.


Function Documentation

GtkWidget* gimlet_hotkey_dialog_new ( GtkWidget *  ,
GimletWindow *   
)

Definition at line 1101 of file language.c.

{
  GladeXML *xml;
  GtkWidget *dialog = NULL;
  GtkWidget *vbox, *table;
  GtkWidget *trigger_entry, *w;
  int num_hotkeys = 0;
  gchar *label_delimiter = ":";
  gchar **hotkeys;
  int i;

  if (!gimlet->hotkey) return NULL;

  hotkeys = g_strsplit (gimlet->hotkey, label_delimiter, -1);

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

  xml = gimlet_util_load_glade_file (GIMLET_GLADE_FILE,
                                 "hotkey-dialog",
                                 transient_parent);

  if (xml == NULL) goto END_HOTKEY_DIALOG;

  dialog = glade_xml_get_widget (xml, "hotkey-dialog");

  gimlet_util_set_unique_role (GTK_WINDOW (dialog), "gimlet-hotkeys");

  /* dynamically create the table */
  vbox = glade_xml_get_widget (xml, "hotkey-vbox");
  table = gtk_table_new (num_hotkeys, 2, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 4);
  gtk_table_set_col_spacings (GTK_TABLE (table), 4);
  gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);

  for (i = 0; i < num_hotkeys; ++i)
    {
      w = gtk_label_new (hotkeys [i * 2]);
      gtk_table_attach_defaults (GTK_TABLE (table),
                             w,
                             0, 1, i, i + 1);

      w = gtk_entry_new ();
      gtk_entry_set_text (w, hotkeys[i * 2 + 1]);
      gtk_table_attach_defaults (GTK_TABLE (table),
                             w,
                             1, 2, i, i + 1);
      if (!strcasecmp (hotkeys[i * 2], TRIGGER_KEY_LABEL))
       trigger_entry = w;
      else
       gtk_widget_set_sensitive (w, FALSE);
    }

  w = glade_xml_get_widget (xml, "hotkey-okbutton");
  g_object_set_data (G_OBJECT (w), "iiim-hotkey-trigger",
                   trigger_entry);
  g_object_set_data (G_OBJECT (w), "iiim-hotkey-dialog",
                   dialog);

  g_signal_connect (G_OBJECT (w), "clicked",
                  G_CALLBACK (hotkey_changed_callback),
                  gimlet);

  w = glade_xml_get_widget (xml, "hotkey-cancelbutton");
  g_signal_connect (G_OBJECT (w), "clicked",
                  G_CALLBACK (hotkey_cancel_callback),
                  gimlet);

  /* FIXME one 'reset' button should be added here in order 
   * to reset the trigger key
   */

  g_object_unref (G_OBJECT (xml));

 END_HOTKEY_DIALOG:
  g_strfreev (hotkeys);
  return dialog;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GtkWidget* gimlet_langmenu_dialog_new ( GtkWindow *  transient_parent,
GimletWindow *  gimlet 
)

Definition at line 663 of file language.c.

{
  GladeXML *xml;
  GtkWidget *w;
  GtkCellRenderer *cell_renderer;
  int i;
  GtkTreeModel *sort_model;
  GtkListStore *tree;
  GtkTreeViewColumn *column;
  GtkTreeIter parent_iter;
  GtkTreeSelection *selection;
  GtkWidget *dialog;

  xml = gimlet_util_load_glade_file (GIMLET_GLADE_FILE,
                                 "languages-dialog",
                                 transient_parent);
  if (xml == NULL)
    return NULL;

  /* The dialog itself */
  dialog = glade_xml_get_widget (xml, "languages-dialog");

  gimlet_util_set_unique_role (GTK_WINDOW (dialog), "gimlet-languages");

  g_signal_connect (G_OBJECT (dialog), "response",
                    G_CALLBACK (response_callback),
                    NULL);

  /* buttons */
  w = glade_xml_get_widget (xml, "add-button");
  g_object_set_data (G_OBJECT (dialog),
                     "language-dialog-add",
                     w);

  g_object_set_data (G_OBJECT (dialog),
                     "gimlet-applet",
                     gimlet->applet);
  g_signal_connect (G_OBJECT (w), "clicked",
                    G_CALLBACK (add_button_clicked_callback),
                    dialog);

  w = glade_xml_get_widget (xml, "remove-button");
  g_object_set_data (G_OBJECT (dialog),
                     "language-dialog-remove",
                     w);

  g_signal_connect (G_OBJECT (w), "clicked",
                    G_CALLBACK (remove_button_clicked_callback),
                    dialog);
  
  /* Tree view of available languages */
  
  w = glade_xml_get_widget (xml, "available-treeview");
  g_object_set_data (G_OBJECT (dialog),
                     "language-dialog-available-treeview",
                     w);
  
  tree = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);

  /* Column 1 */
  cell_renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes (_("_Language"),
                                               cell_renderer,
                                               "text", COLUMN_NAME,
                                               NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
  
  /* Column 2 */
  cell_renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes (_("_Description"),
                                               cell_renderer,
                                               "text", COLUMN_DESCRIPTION,
                                               NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_DESCRIPTION);  

  /* Add the data */

  i = 0;
  while (i < (int) G_N_ELEMENTS (g_languages))
    {
      if (g_languages[i].valid && (strcmp (g_languages[i].iiim_lang_name,
                                      "ASCII") != 0))
        {
          gtk_list_store_append (tree, &parent_iter);
          gtk_list_store_set (tree, &parent_iter,
                              COLUMN_DESCRIPTION,
                              g_languages[i].description,
                              COLUMN_NAME,
                              g_languages[i].name,
                              -1);
        }
      ++i;
    }

  /* Sort model */
  sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
  
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
                                        COLUMN_NAME,
                                        GTK_SORT_ASCENDING);
  
  gtk_tree_view_set_model (GTK_TREE_VIEW (w), sort_model);
  g_object_unref (G_OBJECT (tree));

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (w));    
  gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
                            GTK_SELECTION_MULTIPLE);

  available_selection_changed_callback (selection, dialog);
  g_signal_connect (G_OBJECT (selection), "changed",                    
                    G_CALLBACK (available_selection_changed_callback),
                    dialog);

  /* Tree view of selected languages */
  
  w = glade_xml_get_widget (xml, "displayed-treeview");
  g_object_set_data (G_OBJECT (dialog),
                     "language-dialog-displayed-treeview",
                     w);
  
  tree = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);

  /* Column 1 */
  cell_renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes (_("_Language"),
                                               cell_renderer,
                                               "text", COLUMN_NAME,
                                               NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
  
  /* Column 2 */
  cell_renderer = gtk_cell_renderer_text_new ();
  column = gtk_tree_view_column_new_with_attributes (_("_Description"),
                                               cell_renderer,
                                               "text", COLUMN_DESCRIPTION,
                                               NULL);
  gtk_tree_view_append_column (GTK_TREE_VIEW (w), column);
  gtk_tree_view_column_set_sort_column_id (column, COLUMN_DESCRIPTION);  

  /* Add the data */
  register_active_language_tree_model (tree);

  /* Sort model */
  sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (tree));
  
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model),
                                        COLUMN_NAME,
                                        GTK_SORT_ASCENDING);
  
  gtk_tree_view_set_model (GTK_TREE_VIEW (w), sort_model);
  g_object_unref (G_OBJECT (tree));  

  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (w));    
  gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
                            GTK_SELECTION_MULTIPLE);

  displayed_selection_changed_callback (selection, dialog);
  g_signal_connect (G_OBJECT (selection), "changed",
                    G_CALLBACK (displayed_selection_changed_callback),
                    dialog);

  g_object_unref (G_OBJECT (xml));
  
  return dialog;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gimlet_language_add_active_language ( GimletWindow *  gimlet,
char *  iiim_lang_name 
)

Definition at line 920 of file language.c.

{
  GtkWidget *gimlet_applet = GTK_WIDGET (gimlet->applet);
  GSList *active_iiim_lang_list;
  GSList *tmp;

  active_iiim_lang_list = language_list_to_iiim_lang_list (active_languages);

  tmp = active_iiim_lang_list;
  while (tmp != NULL)
    {
      if (strcmp (tmp->data, iiim_lang_name) == 0)
       return;
      tmp = tmp->next;
    }
  active_iiim_lang_list = g_slist_prepend (active_iiim_lang_list,
                                      g_strdup (iiim_lang_name));
  gconf_set_active_languages (gimlet_applet, active_iiim_lang_list);

  g_slist_foreach (active_iiim_lang_list, (GFunc) g_free, NULL);
  g_slist_free (active_iiim_lang_list);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* gimlet_language_find_description ( char *  iiim_lang_name)

Definition at line 211 of file language.c.

{
  const GimletLanguage *ilname = find_language_by_iiim_lang_name (iiim_lang_name);
  if (ilname)
    return ilname->description;
  else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* gimlet_language_find_name ( char *  iiim_lang_name)

Definition at line 201 of file language.c.

{
  const GimletLanguage *ilname = find_language_by_iiim_lang_name (iiim_lang_name);
  if (ilname)
    return ilname->name;
  else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* gimlet_language_find_short ( char *  iiim_lang_name)

Definition at line 221 of file language.c.

{
  if (find_language_by_iiim_lang_name (ilname))
    {
      /* treat Chinese specially */
      if (strlen (ilname) == 5 &&
         ilname[0] == 'z' &&
         ilname[1] == 'h')
       {
         if (strcmp (ilname, "zh_CN") == 0)
           return (g_strdup ("SC"));
         else
           return (g_strdup ("TC"));
       }    
      else
       {
         gchar *ll = g_strndup (ilname, 2);
         ll[0] = g_ascii_toupper (ll[0]);
         return ll;
       }
    }
  else
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gimlet_language_free ( GimletLanguage *  language)

Definition at line 945 of file language.c.

{
  g_free (language->name);
  g_free (language->description);
  g_free (language->iiim_lang_name);
  g_free (language);
}

Here is the caller graph for this function:

Definition at line 897 of file language.c.

{
  GSList *copy;
  GSList *tmp;

  copy = NULL;
  tmp = active_languages;
  while (tmp != NULL)
    {
      copy = g_slist_append (copy,
                              gimlet_language_copy (tmp->data));
      
      tmp = tmp->next;
    }

  return copy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* gimlet_language_get_conversion_mode ( char *  iiim_lang_name)

Definition at line 882 of file language.c.

{
  GSList *tmp = active_languages;

  while (tmp != NULL)
    {
      GimletLanguage *lang = tmp->data;
      if (strcmp (lang->iiim_lang_name, iiim_lang_name) == 0)
         return (lang->conversion_on ? "on" : "off");
      tmp = tmp->next;
    }
  return "off";
}

Here is the caller graph for this function:

gchar* gimlet_language_get_iiim_lang_name ( GimletLanguage *  data)

Definition at line 875 of file language.c.

{
  /* avoid returning NULL */
  return data->iiim_lang_name ? data->iiim_lang_name : DEFAULT_LANG;
}

Here is the caller graph for this function:

gchar* gimlet_language_get_name ( GimletLanguage *  data)

Definition at line 869 of file language.c.

{
  return data->name;
}

Here is the caller graph for this function:

void gimlet_language_init ( GimletWindow *  gimlet)

Definition at line 834 of file language.c.

{
  int i;
  int n_elements;
  gchar **p;
  GSList *strings = NULL;

  n_elements = G_N_ELEMENTS (g_languages);

  if (gimlet->client_lang_list != NULL)
    {
      for (p = gimlet->client_lang_list; *p; p++)
       for (i = 0; i < n_elements; i++)
         {
           /* Translate the description */
           g_languages[i].description = _(g_languages[i].description);

           if (g_languages[i].iiim_lang_name != NULL)
             {
              guint len = strlen (g_languages[i].iiim_lang_name);
              if (strncmp (g_languages[i].iiim_lang_name, *p, len) == 0)
                g_languages[i].valid = TRUE;
             }
         }
    }

  strings = gconf_get_active_languages (gimlet);

  update_active_languages_from_string_list (strings);

  g_slist_foreach (strings, (GFunc) g_free, NULL);
  g_slist_free (strings);
}

Here is the call graph for this function:

Here is the caller graph for this function: