elementary - added elm_object_item_translatable_part_text_set() elm_object_item_trans...
[framework/uifw/elementary.git] / src / lib / elm_general.h
1 /**
2  * @defgroup General General
3  * @ingroup Elementary
4  *
5  * @brief General Elementary API. Functions that don't relate to
6  * Elementary objects specifically.
7  *
8  * Here are documented functions which init/shutdown the library,
9  * that apply to generic Elementary objects, that deal with
10  * configuration, et cetera.
11  *
12  * @ref general_functions_example_page "This" example contemplates
13  * some of these functions.
14  */
15
16 /**
17  * @addtogroup General
18  * @{
19  */
20
21 /**
22  * Defines couple of standard Evas_Object layers to be used
23  * with evas_object_layer_set().
24  *
25  * @note whenever extending with new values, try to keep some padding
26  *       to siblings so there is room for further extensions.
27  */
28 typedef enum
29 {
30    ELM_OBJECT_LAYER_BACKGROUND = EVAS_LAYER_MIN + 64, /**< where to place backgrounds */
31    ELM_OBJECT_LAYER_DEFAULT = 0, /**< Evas_Object default layer (and thus for Elementary) */
32    ELM_OBJECT_LAYER_FOCUS = EVAS_LAYER_MAX - 128, /**< where focus object visualization is */
33    ELM_OBJECT_LAYER_TOOLTIP = EVAS_LAYER_MAX - 64, /**< where to show tooltips */
34    ELM_OBJECT_LAYER_CURSOR = EVAS_LAYER_MAX - 32, /**< where to show cursors */
35    ELM_OBJECT_LAYER_LAST /**< last layer known by Elementary */
36 } Elm_Object_Layer;
37
38 /**************************************************************************/
39 EAPI extern int ELM_ECORE_EVENT_ETHUMB_CONNECT;
40
41 /**
42  * Emitted when the application has reconfigured elementary settings due
43  * to an external configuration tool asking it to.
44  */
45 EAPI extern int ELM_EVENT_CONFIG_ALL_CHANGED;
46
47 /**
48  * Emitted when any Elementary's policy value is changed.
49  */
50 EAPI extern int ELM_EVENT_POLICY_CHANGED;
51
52 /**
53  * @typedef Elm_Event_Policy_Changed
54  *
55  * Data on the event when an Elementary policy has changed
56  */
57 typedef struct _Elm_Event_Policy_Changed Elm_Event_Policy_Changed;
58
59 /**
60  * @struct _Elm_Event_Policy_Changed
61  *
62  * Data on the event when an Elementary policy has changed
63  */
64 struct _Elm_Event_Policy_Changed
65 {
66    unsigned int policy; /**< the policy identifier */
67    int          new_value; /**< value the policy had before the change */
68    int          old_value; /**< new value the policy got */
69 };
70
71 /**
72  * Policy identifiers.
73  */
74 typedef enum
75 {
76    ELM_POLICY_QUIT, /**< under which circumstances the application
77                      * should quit automatically. @see
78                      * Elm_Policy_Quit.
79                      */
80    ELM_POLICY_EXIT, /**< defines elm_exit() behaviour. @see Elm_Policy_Exit.
81                      * @since 1.8
82                      */
83    ELM_POLICY_LAST
84 } Elm_Policy; /**< Elementary policy identifiers/groups enumeration.  @see elm_policy_set() */
85
86 /**
87  * Possible values for the #ELM_POLICY_QUIT policy
88  */
89 typedef enum
90 {
91    ELM_POLICY_QUIT_NONE = 0, /**< never quit the application
92                               * automatically */
93    ELM_POLICY_QUIT_LAST_WINDOW_CLOSED /**< quit when the
94                                        * application's last
95                                        * window is closed */
96 } Elm_Policy_Quit;
97
98 /**
99  * Possible values for the #ELM_POLICY_EXIT policy.
100  * @since 1.8
101  */
102 typedef enum
103 {
104    ELM_POLICY_EXIT_NONE = 0, /**< just quit the main loop on elm_exit() */
105    ELM_POLICY_EXIT_WINDOWS_DEL /**< delete all the windows after quitting
106                                 * the main loop */
107 } Elm_Policy_Exit;
108
109 typedef enum
110 {
111    ELM_OBJECT_SELECT_MODE_DEFAULT = 0, /**< default select mode */
112    ELM_OBJECT_SELECT_MODE_ALWAYS, /**< always select mode */
113    ELM_OBJECT_SELECT_MODE_NONE, /**< no select mode */
114    ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY, /**< no select mode with no finger size rule*/
115    ELM_OBJECT_SELECT_MODE_MAX
116 } Elm_Object_Select_Mode;
117
118 /**
119  * @typedef Elm_Object_Item
120  * An Elementary Object item handle.
121  * @ingroup General
122  */
123 typedef struct _Elm_Object_Item Elm_Object_Item;
124
125 typedef Eina_Bool             (*Elm_Event_Cb)(void *data, Evas_Object *obj, Evas_Object *src, Evas_Callback_Type type, void *event_info); /**< Function prototype definition for callbacks on input events happening on Elementary widgets. @a data will receive the user data pointer passed to elm_object_event_callback_add(). @a src will be a pointer to the widget on which the input event took place. @a type will get the type of this event and @a event_info, the struct with details on this event. */
126
127 #ifndef ELM_LIB_QUICKLAUNCH
128 #define ELM_MAIN() int main(int argc, char **argv) {elm_init(argc, argv); return elm_main(argc, argv); } /**< macro to be used after the elm_main() function */
129 #else
130 #define ELM_MAIN() int main(int argc, char **argv) {return elm_quicklaunch_fallback(argc, argv); } /**< macro to be used after the elm_main() function */
131 #endif
132
133 /**************************************************************************/
134 /* General calls */
135
136 /**
137  * Initialize Elementary
138  *
139  * @param[in] argc System's argument count value
140  * @param[in] argv System's pointer to array of argument strings
141  * @return The init counter value.
142  *
143  * This function initializes Elementary and increments a counter of
144  * the number of calls to it. It returns the new counter's value.
145  *
146  * @warning This call is exported only for use by the @c ELM_MAIN()
147  * macro. There is no need to use this if you use this macro (which
148  * is highly advisable). An elm_main() should contain the entry
149  * point code for your application, having the same prototype as
150  * elm_init(), and @b not being static (putting the @c EAPI_MAIN symbol
151  * in front of its type declaration is advisable). The @c
152  * ELM_MAIN() call should be placed just after it.
153  *
154  * Example:
155  * @dontinclude bg_example_01.c
156  * @skip static void
157  * @until ELM_MAIN
158  *
159  * See the full @ref bg_example_01_c "example".
160  *
161  * @see elm_shutdown().
162  * @ingroup General
163  */
164 EAPI int       elm_init(int argc, char **argv);
165
166 /**
167  * Shut down Elementary
168  *
169  * @return The init counter value.
170  *
171  * This should be called at the end of your application, just
172  * before it ceases to do any more processing. This will clean up
173  * any permanent resources your application may have allocated via
174  * Elementary that would otherwise persist.
175  *
176  * @see elm_init() for an example
177  *
178  * @note elm_shutdown() will iterate main loop until all ecore_evas are freed.
179  * There is a possibility to call your ecore callbacks(timer, animator, event,
180  * job, and etc.) in elm_shutdown()
181  *
182  * @ingroup General
183  */
184 EAPI int       elm_shutdown(void);
185
186 /**
187  * Run Elementary's main loop
188  *
189  * This call should be issued just after all initialization is
190  * completed. This function will not return until elm_exit() is
191  * called. It will keep looping, running the main
192  * (event/processing) loop for Elementary.
193  *
194  * @see elm_init() for an example
195  *
196  * @ingroup General
197  */
198 EAPI void      elm_run(void);
199
200 /**
201  * Ask to exit Elementary's main loop
202  *
203  * If this call is issued, it will flag the main loop to cease
204  * processing and return back to its parent function (usually your
205  * elm_main() function). This does not mean the main loop instantly quits.
206  * So your ecore callbacks(timer, animator, event, job, and etc.) have chances
207  * to be called even after elm_exit().
208  *
209  * @see elm_init() for an example. There, just after a request to
210  * close the window comes, the main loop will be left.
211  *
212  * @note By using the appropriate #ELM_POLICY_QUIT on your Elementary
213  * applications, you'll be able to get this function called automatically for you.
214  *
215  * @ingroup General
216  */
217 EAPI void      elm_exit(void);
218
219 /**
220  * Exposed symbol used only by macros and should not be used by apps
221  */
222 EAPI void      elm_quicklaunch_mode_set(Eina_Bool ql_on);
223
224 /**
225  * Exposed symbol used only by macros and should not be used by apps
226  */
227 EAPI Eina_Bool elm_quicklaunch_mode_get(void);
228
229 /**
230  * Exposed symbol used only by macros and should not be used by apps
231  */
232 EAPI int       elm_quicklaunch_init(int argc, char **argv);
233
234 /**
235  * Exposed symbol used only by macros and should not be used by apps
236  */
237 EAPI int       elm_quicklaunch_sub_init(int argc, char **argv);
238
239 /**
240  * Exposed symbol used only by macros and should not be used by apps
241  */
242 EAPI int       elm_quicklaunch_sub_shutdown(void);
243
244 /**
245  * Exposed symbol used only by macros and should not be used by apps
246  */
247 EAPI int       elm_quicklaunch_shutdown(void);
248
249 /**
250  * Exposed symbol used only by macros and should not be used by apps
251  */
252 EAPI void      elm_quicklaunch_seed(void);
253
254 /**
255  * Exposed symbol used only by macros and should not be used by apps
256  */
257 EAPI Eina_Bool elm_quicklaunch_prepare(int argc, char **argv);
258
259 /**
260  * Exposed symbol used only by macros and should not be used by apps
261  */
262 EAPI Eina_Bool elm_quicklaunch_fork(int argc, char **argv, char *cwd, void (postfork_func) (void *data), void *postfork_data);
263
264 /**
265  * Exposed symbol used only by macros and should not be used by apps
266  */
267 EAPI void      elm_quicklaunch_cleanup(void);
268
269 /**
270  * Exposed symbol used only by macros and should not be used by apps
271  */
272 EAPI int       elm_quicklaunch_fallback(int argc, char **argv);
273
274 /**
275  * Exposed symbol used only by macros and should not be used by apps
276  */
277 EAPI char     *elm_quicklaunch_exe_path_get(const char *exe);
278
279 /**
280  * Set a new policy's value (for a given policy group/identifier).
281  *
282  * @param policy policy identifier, as in @ref Elm_Policy.
283  * @param value policy value, which depends on the identifier
284  *
285  * @return @c EINA_TRUE on success or @c EINA_FALSE, on error.
286  *
287  * Elementary policies define applications' behavior,
288  * somehow. These behaviors are divided in policy groups
289  * (see #Elm_Policy enumeration). This call will emit the Ecore
290  * event #ELM_EVENT_POLICY_CHANGED, which can be hooked at with
291  * handlers. An #Elm_Event_Policy_Changed struct will be passed,
292  * then.
293  *
294  * @note Currently, we have only one policy identifier/group
295  * (#ELM_POLICY_QUIT), which has two possible values.
296  *
297  * @ingroup General
298  */
299 EAPI Eina_Bool elm_policy_set(unsigned int policy, int value);
300
301 /**
302  * Gets the policy value for given policy identifier.
303  *
304  * @param policy policy identifier, as in #Elm_Policy.
305  * @return The currently set policy value, for that
306  * identifier. Will be @c 0 if @p policy passed is invalid.
307  *
308  * @ingroup General
309  */
310 EAPI int       elm_policy_get(unsigned int policy);
311
312 /**
313  * Change the language of the current application
314  *
315  * The @p lang passed must be the full name of the locale to use, for
316  * example "en_US.utf8" or "es_ES@euro".
317  *
318  * Changing language with this function will make Elementary run through
319  * all its widgets, translating strings set with
320  * elm_object_domain_translatable_text_part_set(). This way, an entire
321  * UI can have its language changed without having to restart the program.
322  *
323  * For more complex cases, like having formatted strings that need
324  * translation, widgets will also emit a "language,changed" signal that
325  * the user can listen to to manually translate the text.
326  *
327  * @param lang Language to set, must be the full name of the locale
328  *
329  * @ingroup General
330  */
331 EAPI void      elm_language_set(const char *lang);
332
333 /**
334  * @}
335  */