]> Pileus Git - ~andy/gtk/blob - modules/input/imhangul.c
24a67a6b212ed22a6f0f126d81c31cd04f0ddb23
[~andy/gtk] / modules / input / imhangul.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 2000 Red Hat Software
3  * Copyright (C) 2002 Yusuke Tabata
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  * Authors: Owen Taylor <otaylor@redhat.com>
21  *          Yusuke Tabata <tee@kuis.kyoto-u.ac.jp>
22  *
23  * This module is a port of the korean-hangul module from Emacs.
24  */
25
26 #include <string.h>
27
28 #include <gdk/gdkkeysyms.h>
29
30 #include "gtk/gtkintl.h"
31 #include "gtk/gtkimcontextsimple.h"
32 #include "gtk/gtkimmodule.h"
33
34 GType type_hangul = 0;
35
36 static void hangul_class_init (GtkIMContextSimpleClass *class);
37 static void hangul_init (GtkIMContextSimple *im_context);
38
39 static void
40 hangul_register_type (GTypeModule *module)
41 {
42   static const GTypeInfo object_info =
43   {
44     sizeof (GtkIMContextSimpleClass),
45     (GBaseInitFunc) NULL,
46     (GBaseFinalizeFunc) NULL,
47     (GClassInitFunc) hangul_class_init,
48     NULL,           /* class_finalize */
49     NULL,           /* class_data */
50     sizeof (GtkIMContextSimple),
51     0,
52     (GInstanceInitFunc) hangul_init,
53   };
54
55   type_hangul = 
56     g_type_module_register_type (module,
57                                  GTK_TYPE_IM_CONTEXT_SIMPLE,
58                                  "GtkIMContextHangul",
59                                  &object_info, 0);
60 }
61
62 static guint16 hangul_compose_seqs[] = {
63 #include "imhangul-defs.h"
64 };
65
66 static void
67 hangul_class_init (GtkIMContextSimpleClass *class)
68 {
69 }
70
71 static void
72 hangul_init (GtkIMContextSimple *im_context)
73 {
74   gtk_im_context_simple_add_table (im_context,
75                                    hangul_compose_seqs,
76                                    4,
77                                    G_N_ELEMENTS (hangul_compose_seqs) / (4 + 2));
78 }
79
80 static const GtkIMContextInfo hangul_info = { 
81   "hangul",                /* ID */
82   /*N_("Hangul"),*/
83   "Hangul (KSC 5601)",             /* Human readable name */
84   "gtk+",                          /* Translation domain */
85   /* GTK_LOCALEDIR, */
86    "",             /* Dir for bindtextdomain (not strictly needed for "gtk+") */
87    ""                              /* Languages for which this module is the default */
88 };
89
90 static const GtkIMContextInfo *info_list[] = {
91   &hangul_info
92 };
93
94 void
95 im_module_init (GTypeModule *module)
96 {
97   hangul_register_type (module);
98 }
99
100 void 
101 im_module_exit (void)
102 {
103 }
104
105 void 
106 im_module_list (const GtkIMContextInfo ***contexts,
107                 int                      *n_contexts)
108 {
109   *contexts = info_list;
110   *n_contexts = G_N_ELEMENTS (info_list);
111 }
112
113 GtkIMContext *
114 im_module_create (const gchar *context_id)
115 {
116   if (strcmp (context_id, "hangul") == 0)
117     return GTK_IM_CONTEXT (g_object_new (type_hangul, NULL));
118   else
119     return NULL;
120 }