]> Pileus Git - ~andy/gtk/blob - modules/input/iminuktitut.c
Merge branch 'master' into broadway
[~andy/gtk] / modules / input / iminuktitut.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2000 Red Hat Software
3  * Copyright (C) 2000 SuSE Linux Ltd
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Original author: Owen Taylor <otaylor@redhat.com>
21  * 
22  * Modified for Inuktitut - Robert Brady <robert@suse.co.uk>
23  *
24  */
25
26 #include "config.h"
27 #include <string.h>
28
29 #include "gtk/gtk.h"
30 #include "gdk/gdkkeysyms.h"
31
32 #include "gtk/gtkimmodule.h"
33 #include "gtk/gtkintl.h"
34
35 GType type_inuktitut_translit = 0;
36
37 static void inuktitut_class_init (GtkIMContextSimpleClass *class);
38 static void inuktitut_init (GtkIMContextSimple *im_context);
39
40 static void
41 inuktitut_register_type (GTypeModule *module)
42 {
43   const GTypeInfo object_info =
44   {
45     sizeof (GtkIMContextSimpleClass),
46     (GBaseInitFunc) NULL,
47     (GBaseFinalizeFunc) NULL,
48     (GClassInitFunc) inuktitut_class_init,
49     NULL,           /* class_finalize */
50     NULL,           /* class_data */
51     sizeof (GtkIMContextSimple),
52     0,
53     (GInstanceInitFunc) inuktitut_init,
54   };
55
56   type_inuktitut_translit = 
57     g_type_module_register_type (module,
58                                  GTK_TYPE_IM_CONTEXT_SIMPLE,
59                                  "GtkIMContextInuktitut",
60                                  &object_info, 0);
61 }
62
63 #define SYL(a,b,c,d) \
64   a, 0,   0, 0, 0, c, \
65   a, 'a', 0, 0, 0, b+7-d, \
66   a, 'a','a',0, 0, b+8-d, \
67   a, 'i', 0, 0, 0, b, \
68   a, 'i','i',0, 0, b+1, \
69   a, 'o', 0, 0, 0, b+2, \
70   a, 'o','o',0, 0, b+3, \
71   a, 'u', 0, 0, 0, b+2, \
72   a, 'u','u',0, 0, b+3,
73
74 static guint16 inuktitut_compose_seqs[] = {
75   'a', 0,   0,   0 ,  0,   0x140a,
76   'a', 'a', 0,   0,   0,   0x140b,
77
78   SYL('c', 0x148b, 0x14a1, 2) /* As g */
79   SYL('f', 0x1555, 0x155d, 2)
80   SYL('g', 0x148b, 0x14a1, 2)
81   SYL('h', 0x14ef, 0x1505, 2)
82
83   'i', 0,   0,   0 ,  0,   0x1403,
84   'i', 'i', 0,   0,   0,   0x1404,
85
86   SYL('j', 0x1528, 0x153e, 2)
87   SYL('k', 0x146d, 0x1483, 2)
88   SYL('l', 0x14d5, 0x14ea, 2)
89   SYL('m', 0x14a5, 0x14bb, 2)
90   SYL('n', 0x14c2, 0x14d0, 2)
91
92   'o', 0,   0,   0 ,  0,   0x1405, /* as u */
93   'o', 'o', 0,   0,   0,   0x1406,
94
95   SYL('p', 0x1431, 0x1449, 0)
96   SYL('q', 0x157f, 0x1585, 3)
97   SYL('r', 0x1546, 0x1550, 2)
98   SYL('s', 0x14ef, 0x1505, 2) /* As h */
99   SYL('t', 0x144e, 0x1466, 0)
100
101   'u', 0,   0,   0 ,  0,   0x1405,
102   'u', 'u', 0,   0,   0,   0x1406,
103
104   SYL('v', 0x1555, 0x155d, 2) /* as f */
105   SYL('y', 0x1528, 0x153e, 2) /* As j */
106
107   SYL(GDK_KEY_lstroke, 0x15a0, 0x15a6, 3) /* l- */
108   SYL(GDK_KEY_eng, 0x158f, 0x1595, 3)     /* ng */
109 };
110
111 static void
112 inuktitut_class_init (GtkIMContextSimpleClass *class)
113 {
114 }
115
116 static void
117 inuktitut_init (GtkIMContextSimple *im_context)
118 {
119   gtk_im_context_simple_add_table (im_context,
120                                    inuktitut_compose_seqs,
121                                    4,
122                                    G_N_ELEMENTS (inuktitut_compose_seqs) / (4 + 2));
123 }
124
125 static const GtkIMContextInfo inuktitut_info = { 
126   "inuktitut",             /* ID */
127   N_("Inuktitut (Transliterated)"),         /* Human readable name */
128   GETTEXT_PACKAGE,         /* Translation domain */
129   GTK_LOCALEDIR,           /* Dir for bindtextdomain (not strictly needed for "gtk+") */
130   "iu"                     /* Languages for which this module is the default */
131 };
132
133 static const GtkIMContextInfo *info_list[] = {
134   &inuktitut_info
135 };
136
137 #ifndef INCLUDE_IM_inuktitut
138 #define MODULE_ENTRY(type, function) G_MODULE_EXPORT type im_module_ ## function
139 #else
140 #define MODULE_ENTRY(type, function) type _gtk_immodule_inuktitut_ ## function
141 #endif
142
143 MODULE_ENTRY (void, init) (GTypeModule *module)
144 {
145   inuktitut_register_type (module);
146 }
147
148 MODULE_ENTRY (void, exit) (void)
149 {
150 }
151
152 MODULE_ENTRY (void, list) (const GtkIMContextInfo ***contexts,
153                            int                      *n_contexts)
154 {
155   *contexts = info_list;
156   *n_contexts = G_N_ELEMENTS (info_list);
157 }
158
159 MODULE_ENTRY (GtkIMContext *, create) (const gchar *context_id)
160 {
161   if (strcmp (context_id, "inuktitut") == 0)
162     return g_object_new (type_inuktitut_translit, NULL);
163   else
164     return NULL;
165 }