summaryrefslogtreecommitdiff
path: root/src/modules/ecore_imf/ibus/ibus_module.c
blob: 8ac1bf35bc0c214bab00ceb03a130015614746b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <stdio.h>

#include <Ecore.h>
#include <Ecore_IMF.h>

#include <ibus.h>
#include "ibus_imcontext.h"

#define IBUS_LOCALDIR ""
static const Ecore_IMF_Context_Info ibus_im_info = {
    "ibus",
    "IBus (Intelligent Input Bus)",
    "*",
    NULL,
    0
};

static Ecore_IMF_Context_Class ibus_imf_class = {
    ibus_im_context_add,                    /* add */
    ibus_im_context_del,                    /* del */
    ibus_im_context_client_window_set,      /* client_window_set */
    ibus_im_context_client_canvas_set,      /* client_canvas_set */
    NULL,                                   /* input_panel_show */
    NULL,                                   /* input_panel_hide */
    ibus_im_context_preedit_string_get,     /* get_preedit_string */
    ibus_im_context_focus_in,               /* focus_in */
    ibus_im_context_focus_out,              /* focus_out */
    ibus_im_context_reset,                  /* reset */
    NULL,                                   /* cursor_position_set */
    ibus_im_context_use_preedit_set,        /* use_preedit_set */
    NULL,                                   /* input_mode_set */
    ibus_im_context_filter_event,           /* filter_event */
    ibus_im_context_preedit_string_with_attributes_get,  /* preedit_string_with_attribute_get */
    NULL,                                   /* prediction_allow_set */
    NULL,                                   /* autocapital_type_set */
    NULL,                                   /* control panel show */
    NULL,                                   /* control panel hide */
    NULL,                                   /* input_panel_layout_set */
    NULL,                                   /* ibus_im_context_input_panel_layout_get, */
    NULL,                                   /* ibus_im_context_input_panel_language_set, */
    NULL,                                   /* ibus_im_context_input_panel_language_get, */
    ibus_im_context_cursor_location_set,    /* cursor_location_set */
    NULL,                                   /* input_panel_imdata_set */
    NULL,                                   /* input_panel_imdata_get */
    NULL,                                   /* input_panel_return_key_type_set */
    NULL,                                   /* input_panel_return_key_disabled_set */
    NULL,                                   /* input_panel_caps_lock_mode_set */
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL
};

static Ecore_IMF_Context *im_module_create (void);
static Ecore_IMF_Context *im_module_exit (void);

static Eina_Bool
im_module_init(void)
{
    ecore_main_loop_glib_integrate();
    ibus_init();
    ecore_imf_module_register(&ibus_im_info, im_module_create, im_module_exit);

    return EINA_TRUE;
}

static void im_module_shutdown(void)
{
}

static Ecore_IMF_Context *
im_module_exit(void)
{
    return NULL;
}

static Ecore_IMF_Context *
im_module_create(void)
{
    Ecore_IMF_Context *ctx = NULL;
    IBusIMContext *ctxd = NULL;

    ctxd = ibus_im_context_new();
    if (!ctxd)
      {
         return NULL;
      }

    ctx = ecore_imf_context_new(&ibus_imf_class);
    if (!ctx)
      {
         free(ctxd);
         return NULL;
      }

    ecore_imf_context_data_set(ctx, ctxd);

    return ctx;
}

EINA_MODULE_INIT(im_module_init);
EINA_MODULE_SHUTDOWN(im_module_shutdown);