Tizen 2.1 base
[framework/uifw/ecore.git] / src / lib / ecore_imf / ecore_imf.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include <Ecore.h>
6 #include <ecore_private.h>
7
8 #include "Ecore_IMF.h"
9 #include "ecore_imf_private.h"
10
11 EAPI int ECORE_IMF_EVENT_PREEDIT_START = 0;
12 EAPI int ECORE_IMF_EVENT_PREEDIT_END = 0;
13 EAPI int ECORE_IMF_EVENT_PREEDIT_CHANGED = 0;
14 EAPI int ECORE_IMF_EVENT_COMMIT = 0;
15 EAPI int ECORE_IMF_EVENT_DELETE_SURROUNDING = 0;
16
17 int _ecore_imf_log_dom = -1;
18 static int _ecore_imf_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 (++_ecore_imf_init_count != 1) return _ecore_imf_init_count;
37
38    if (!ecore_init()) return --_ecore_imf_init_count;
39    _ecore_imf_log_dom = eina_log_domain_register
40       ("ecore_imf", ECORE_IMF_DEFAULT_LOG_COLOR);
41    if (_ecore_imf_log_dom < 0)
42      {
43         EINA_LOG_ERR("Impossible to create a log domain for the Ecore IMF module.");
44         ecore_shutdown();
45         return --_ecore_imf_init_count;
46      }
47    ecore_imf_module_init();
48
49    ECORE_IMF_EVENT_PREEDIT_START = ecore_event_type_new();
50    ECORE_IMF_EVENT_PREEDIT_END = ecore_event_type_new();
51    ECORE_IMF_EVENT_PREEDIT_CHANGED = ecore_event_type_new();
52    ECORE_IMF_EVENT_COMMIT = ecore_event_type_new();
53    ECORE_IMF_EVENT_DELETE_SURROUNDING = ecore_event_type_new();
54
55    return _ecore_imf_init_count;
56 }
57
58 /**
59  * Shuts down the Ecore_IMF library.
60  * @return  Number of times the library has been initialised without being
61  *          shut down.
62  * @ingroup Ecore_IMF_Lib_Group
63  */
64 EAPI int
65 ecore_imf_shutdown(void)
66 {
67    if (--_ecore_imf_init_count != 0) return _ecore_imf_init_count;
68    ecore_imf_module_shutdown();
69    eina_log_domain_unregister(_ecore_imf_log_dom);
70    _ecore_imf_log_dom = -1;
71    ecore_shutdown();
72    return _ecore_imf_init_count;
73 }