caf967142ac8d431660ccd1c7d7ed38788d0af39
[framework/uifw/ecore.git] / src / lib / ecore_imf / ecore_imf.c
1 /*
2  * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3  */
4
5 #include "config.h"
6
7 #include "Ecore_IMF.h"
8 #include "ecore_imf_private.h"
9
10 #include <Ecore.h>
11
12 EAPI int ECORE_IMF_EVENT_PREEDIT_START = 0;
13 EAPI int ECORE_IMF_EVENT_PREEDIT_END = 0;
14 EAPI int ECORE_IMF_EVENT_PREEDIT_CHANGED = 0;
15 EAPI int ECORE_IMF_EVENT_COMMIT = 0;
16 EAPI int ECORE_IMF_EVENT_DELETE_SURROUNDING = 0;
17
18 static int init_count = 0;
19
20 /**
21  * @defgroup Ecore_IMF_Lib_Group Ecore Input Method Library Functions
22  *
23  * Utility functions that set up and shut down the Ecore Input Method
24  * library.
25  */
26
27 /**
28  * Initialises the Ecore_IMF library.
29  * @return  Number of times the library has been initialised without being
30  *          shut down.
31  * @ingroup Ecore_IMF_Lib_Group
32  */
33 EAPI int
34 ecore_imf_init(void)
35 {
36    if (++init_count != 1) return init_count;
37
38    ecore_init();
39    ecore_imf_module_init();
40
41    ECORE_IMF_EVENT_PREEDIT_START = ecore_event_type_new();
42    ECORE_IMF_EVENT_PREEDIT_END = ecore_event_type_new();
43    ECORE_IMF_EVENT_PREEDIT_CHANGED = ecore_event_type_new();
44    ECORE_IMF_EVENT_COMMIT = ecore_event_type_new();
45    ECORE_IMF_EVENT_DELETE_SURROUNDING = ecore_event_type_new();
46
47    return init_count;
48 }
49
50 /**
51  * Shuts down the Ecore_IMF library.
52  * @return  Number of times the library has been initialised without being
53  *          shut down.
54  * @ingroup Ecore_IMF_Lib_Group
55  */
56 EAPI int
57 ecore_imf_shutdown(void)
58 {
59    if (--init_count != 0) return init_count;
60
61    ecore_shutdown();
62    ecore_imf_module_shutdown();
63
64    return init_count;
65 }