svn update: 48958 (latest:48959)
[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 #ifdef HAVE_CONFIG_H
6 # include <config.h>
7 #endif
8
9 #include <Ecore.h>
10 #include <ecore_private.h>
11
12 #include "Ecore_IMF.h"
13 #include "ecore_imf_private.h"
14
15 EAPI int ECORE_IMF_EVENT_PREEDIT_START = 0;
16 EAPI int ECORE_IMF_EVENT_PREEDIT_END = 0;
17 EAPI int ECORE_IMF_EVENT_PREEDIT_CHANGED = 0;
18 EAPI int ECORE_IMF_EVENT_COMMIT = 0;
19 EAPI int ECORE_IMF_EVENT_DELETE_SURROUNDING = 0;
20
21 int _ecore_imf_log_dom = -1;
22 static int _ecore_imf_init_count = 0;
23
24 /**
25  * @defgroup Ecore_IMF_Lib_Group Ecore Input Method Library Functions
26  *
27  * Utility functions that set up and shut down the Ecore Input Method
28  * library.
29  */
30
31 /**
32  * Initialises the Ecore_IMF library.
33  * @return  Number of times the library has been initialised without being
34  *          shut down.
35  * @ingroup Ecore_IMF_Lib_Group
36  */
37 EAPI int
38 ecore_imf_init(void)
39 {
40    if (++_ecore_imf_init_count != 1)
41      return _ecore_imf_init_count;
42
43    if (!ecore_init())
44      return --_ecore_imf_init_count;
45    _ecore_imf_log_dom = eina_log_domain_register("EcoreIMF", ECORE_IMF_DEFAULT_LOG_COLOR);
46    if(_ecore_imf_log_dom < 0) 
47      {
48        EINA_LOG_ERR("Impossible to create a log domain for the Ecore IMF module.");
49        ecore_shutdown();
50        return --_ecore_imf_init_count;
51      }
52    ecore_imf_module_init();
53
54    ECORE_IMF_EVENT_PREEDIT_START = ecore_event_type_new();
55    ECORE_IMF_EVENT_PREEDIT_END = ecore_event_type_new();
56    ECORE_IMF_EVENT_PREEDIT_CHANGED = ecore_event_type_new();
57    ECORE_IMF_EVENT_COMMIT = ecore_event_type_new();
58    ECORE_IMF_EVENT_DELETE_SURROUNDING = ecore_event_type_new();
59
60    return _ecore_imf_init_count;
61 }
62
63 /**
64  * Shuts down the Ecore_IMF library.
65  * @return  Number of times the library has been initialised without being
66  *          shut down.
67  * @ingroup Ecore_IMF_Lib_Group
68  */
69 EAPI int
70 ecore_imf_shutdown(void)
71 {
72    if (--_ecore_imf_init_count != 0)
73      return _ecore_imf_init_count;
74
75    ecore_shutdown();
76    ecore_imf_module_shutdown();
77    eina_log_domain_unregister(_ecore_imf_log_dom);
78    _ecore_imf_log_dom = -1;
79    return _ecore_imf_init_count;
80 }