Comment fix
[mim] / src / ui / mim-immodule.c
1 /*********************************************************************
2 **
3 **  Copyright (C) 2009  MiM
4 **
5 **          Contact: Handspring <xhealer@gmail.com>
6 **
7 **          AUTHOR:
8 **
9 **  This file is part of MiM Pinyin.
10 **
11 **  This is free software: you can redistribute it and/or modify
12 **  it under the terms of the GNU General Public License as published by
13 **  the Free Software Foundation, either version 3 of the License, or
14 **  (at your option) any later version.
15 **
16 **  This is distributed in the hope that it will be useful,
17 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 **  GNU General Public License for more details.
20 **
21 **  You should have received a copy of the GNU General Public License
22 **  along with Sigil.  If not, see <http://www.gnu.org/licenses/>.
23 **
24 *********************************************************************/
25 #ifdef HAVE_CONFIG_H
26 # include <config.h>
27 #endif
28 /*
29  * GTK+ MiM input module 
30  */
31 #include <gtk/gtkimcontext.h>
32 #include <gtk/gtkimmodule.h>
33 #include <gdk/gdkkeysyms.h>
34 #include <string.h>
35
36 #include "im-extra-intl.h"
37
38 GType type_mim = 0;
39
40 static gboolean
41 mim_filter_keypress(GtkIMContext *context,
42                     GdkEventKey *event)
43 {
44     if (event->type == GDK_KEY_RELEASE)
45         return FALSE;
46
47     return TRUE;
48 }
49
50 static void
51 mim_set_client_window(GtkIMContext *context,
52                       GdkWindow *window)
53 {
54     if (window == NULL) {
55         /*TODO: create new client window */
56         //mim_mui_create_window();
57     }
58 }
59
60 static void
61 mim_reset(GtkIMContext *context)
62 {
63 }
64
65 static void
66 mim_class_init(GtkIMContextClass *clazz)
67 {
68     clazz->filter_keypress = mim_filter_keypress;
69     clazz->reset = mim_reset;
70     clazz->set_client_window = mim_set_client_window;
71 }
72
73 static void
74 mim_init(GtkIMContext *im_context)
75 {
76 }
77
78 static void
79 mim_register_type(GTypeModule *module)
80 {
81     static const GTypeInfo object_info =
82     {
83         sizeof(GtkIMContextClass),
84         (GBaseInitFunc) NULL,
85         (GBaseFinalizeFunc) NULL,
86         (GClassInitFunc) mim_class_init,
87         NULL, /* class_finalize */
88         NULL, /* class_data */
89         sizeof(GtkIMContext),
90         0,
91         (GInstanceInitFunc) mim_init,
92     };
93
94     type_mim = g_type_module_register_type(module,
95                                            GTK_TYPE_IM_CONTEXT,
96                                            "GtkIMContextYiddishNoah",
97                                            &object_info,
98                                            0);
99 }
100
101 static const
102 GtkIMContextInfo mim_info =
103 {
104     "mim", /* ID */
105     N_("MiM"), /* Human readable name */
106     GETTEXT_PACKAGE, /* Translation domain */
107     LOCALEDIR, /* Dir for bindtextdomain */
108     "zh_CN", /* Languages for which this module is the default */
109 };
110
111 static const
112 GtkIMContextInfo *info_list[] =
113 {
114     &mim_info,
115 };
116
117 void
118 im_module_init(GTypeModule *module)
119 {
120     g_debug("mim-immodule imported!");
121     mim_register_type(module);
122     /*TODO: Mask off the accelerators, except the CTRL (need for CTRL
123      * ^SPACE) */
124 }
125
126 void
127 im_module_exit()
128 {
129     g_debug("mim-immodule released!");
130 }
131
132 void
133 im_module_list(const GtkIMContextInfo ***contexts,
134                gint *n_contexts)
135 {
136     *contexts = info_list;
137     *n_contexts = G_N_ELEMENTS(info_list);
138 }
139
140 GtkIMContext *
141 im_module_create(const gchar *context_id)
142 {
143     if (strcmp(context_id, "mim") == 0)
144         return GTK_IM_CONTEXT(g_object_new(type_mim, NULL));
145     else
146         return NULL;
147 }
148