Small fix of unused variables, add todos
[mim] / src / ui / mim-immodule.c
1 /*
2  * GTK+ MiM input module 
3  */
4
5 #ifdef HAVE_CONFIG_H
6 # include <config.h>
7 #endif
8
9 #include <gtk/gtkimcontext.h>
10 #include <gtk/gtkimmodule.h>
11 #include <gdk/gdkkeysyms.h>
12 #include <string.h>
13
14 #include "im-extra-intl.h"
15
16 GType type_mim = 0;
17
18 static gboolean
19 mim_filter_keypress(GtkIMContext *context,
20                     GdkEventKey *event)
21 {
22     if (event->type == GDK_KEY_RELEASE)
23         return FALSE;
24
25     /* don't filter key events with accelerator modifiers held down */
26 //    if (event->state & (gtk_accelerator_get_default_mod_mask()
27 //            & ~GDK_SHIFT_MASK))
28 //        return FALSE;
29
30     return TRUE;
31 }
32
33 static void
34 mim_set_client_window(GtkIMContext *context,
35                       GdkWindow *window)
36 {
37     if (window == NULL) {
38         /*TODO: create new client window */
39         //mim_mui_create_window();
40     }
41 }
42
43 static void
44 mim_reset(GtkIMContext *context)
45 {
46 }
47
48 static void
49 mim_class_init(GtkIMContextClass *clazz)
50 {
51     clazz->filter_keypress = mim_filter_keypress;
52     clazz->reset = mim_reset;
53     clazz->set_client_window = mim_set_client_window;
54 }
55
56 static void
57 mim_init(GtkIMContext *im_context)
58 {
59 }
60
61 static void
62 mim_register_type(GTypeModule *module)
63 {
64     static const GTypeInfo object_info =
65     {
66         sizeof(GtkIMContextClass),
67         (GBaseInitFunc) NULL,
68         (GBaseFinalizeFunc) NULL,
69         (GClassInitFunc) mim_class_init,
70         NULL, /* class_finalize */
71         NULL, /* class_data */
72         sizeof(GtkIMContext),
73         0,
74         (GInstanceInitFunc) mim_init,
75     };
76
77     type_mim = g_type_module_register_type(module,
78                                            GTK_TYPE_IM_CONTEXT,
79                                            "GtkIMContextYiddishNoah",
80                                            &object_info,
81                                            0);
82 }
83
84 static const
85 GtkIMContextInfo mim_info =
86 {
87     "mim", /* ID */
88     N_("MiM"), /* Human readable name */
89     GETTEXT_PACKAGE, /* Translation domain */
90     LOCALEDIR, /* Dir for bindtextdomain */
91     "zh_CN", /* Languages for which this module is the default */
92 };
93
94 static const
95 GtkIMContextInfo *info_list[] =
96 {
97     &mim_info,
98 };
99
100 void
101 im_module_init(GTypeModule *module)
102 {
103     g_debug("mim-immodule imported!");
104     mim_register_type(module);
105     /*TODO: Mask off the accelerators, except the CTRL (need for CTRL
106      * ^SPACE) */
107 }
108
109 void
110 im_module_exit()
111 {
112     g_debug("mim-immodule released!");
113 }
114
115 void
116 im_module_list(const GtkIMContextInfo ***contexts,
117                gint *n_contexts)
118 {
119     *contexts = info_list;
120     *n_contexts = G_N_ELEMENTS(info_list);
121 }
122
123 GtkIMContext *
124 im_module_create(const gchar *context_id)
125 {
126     if (strcmp(context_id, "mim") == 0)
127         return GTK_IM_CONTEXT(g_object_new(type_mim, NULL));
128     else
129         return NULL;
130 }
131