a6314c18e1f296a2b63018046d20f3185eb5c4cd
[profile/ivi/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("EcoreIMF", ECORE_IMF_DEFAULT_LOG_COLOR);
40    if (_ecore_imf_log_dom < 0) 
41      {
42         EINA_LOG_ERR("Impossible to create a log domain for the Ecore IMF module.");
43         ecore_shutdown();
44         return --_ecore_imf_init_count;
45      }
46    ecore_imf_module_init();
47    
48    ECORE_IMF_EVENT_PREEDIT_START = ecore_event_type_new();
49    ECORE_IMF_EVENT_PREEDIT_END = ecore_event_type_new();
50    ECORE_IMF_EVENT_PREEDIT_CHANGED = ecore_event_type_new();
51    ECORE_IMF_EVENT_COMMIT = ecore_event_type_new();
52    ECORE_IMF_EVENT_DELETE_SURROUNDING = ecore_event_type_new();
53
54    return _ecore_imf_init_count;
55 }
56
57 /**
58  * Shuts down the Ecore_IMF library.
59  * @return  Number of times the library has been initialised without being
60  *          shut down.
61  * @ingroup Ecore_IMF_Lib_Group
62  */
63 EAPI int
64 ecore_imf_shutdown(void)
65 {
66    if (--_ecore_imf_init_count != 0) return _ecore_imf_init_count;
67    ecore_imf_module_shutdown();
68    eina_log_domain_unregister(_ecore_imf_log_dom);
69    _ecore_imf_log_dom = -1;
70    ecore_shutdown();
71    return _ecore_imf_init_count;
72 }
73
74 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/