b8a7686012a889bb98195fb0fbe91899001a5a51
[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_FOCUS_PREVIOUS,
112    ELM_FOCUS_NEXT
113 } Elm_Focus_Direction;
114
115 typedef enum
116 {
117    ELM_OBJECT_SELECT_MODE_DEFAULT = 0, /**< default select mode */
118    ELM_OBJECT_SELECT_MODE_ALWAYS, /**< always select mode */
119    ELM_OBJECT_SELECT_MODE_NONE, /**< no select mode */
120    ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY, /**< no select mode with no finger size rule*/
121    ELM_OBJECT_SELECT_MODE_MAX
122 } Elm_Object_Select_Mode;
123
124 /**
125  * @typedef Elm_Object_Item
126  * An Elementary Object item handle.
127  * @ingroup General
128  */
129 typedef struct _Elm_Object_Item Elm_Object_Item;
130
131 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. */
132
133 #ifndef ELM_LIB_QUICKLAUNCH
134 #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 */
135 #else
136 #define ELM_MAIN() int main(int argc, char **argv) {return elm_quicklaunch_fallback(argc, argv); } /**< macro to be used after the elm_main() function */
137 #endif
138
139 /**************************************************************************/
140 /* General calls */
141
142 /**
143  * Initialize Elementary
144  *
145  * @param[in] argc System's argument count value
146  * @param[in] argv System's pointer to array of argument strings
147  * @return The init counter value.
148  *
149  * This function initializes Elementary and increments a counter of
150  * the number of calls to it. It returns the new counter's value.
151  *
152  * @warning This call is exported only for use by the @c ELM_MAIN()
153  * macro. There is no need to use this if you use this macro (which
154  * is highly advisable). An elm_main() should contain the entry
155  * point code for your application, having the same prototype as
156  * elm_init(), and @b not being static (putting the @c EAPI_MAIN symbol
157  * in front of its type declaration is advisable). The @c
158  * ELM_MAIN() call should be placed just after it.
159  *
160  * Example:
161  * @dontinclude bg_example_01.c
162  * @skip static void
163  * @until ELM_MAIN
164  *
165  * See the full @ref bg_example_01_c "example".
166  *
167  * @see elm_shutdown().
168  * @ingroup General
169  */
170 EAPI int       elm_init(int argc, char **argv);
171
172 /**
173  * Shut down Elementary
174  *
175  * @return The init counter value.
176  *
177  * This should be called at the end of your application, just
178  * before it ceases to do any more processing. This will clean up
179  * any permanent resources your application may have allocated via
180  * Elementary that would otherwise persist.
181  *
182  * @see elm_init() for an example
183  *
184  * @note elm_shutdown() will iterate main loop until all ecore_evas are freed.
185  * There is a possibility to call your ecore callbacks(timer, animator, event,
186  * job, and etc.) in elm_shutdown()
187  *
188  * @ingroup General
189  */
190 EAPI int       elm_shutdown(void);
191
192 /**
193  * Run Elementary's main loop
194  *
195  * This call should be issued just after all initialization is
196  * completed. This function will not return until elm_exit() is
197  * called. It will keep looping, running the main
198  * (event/processing) loop for Elementary.
199  *
200  * @see elm_init() for an example
201  *
202  * @ingroup General
203  */
204 EAPI void      elm_run(void);
205
206 /**
207  * Ask to exit Elementary's main loop
208  *
209  * If this call is issued, it will flag the main loop to cease
210  * processing and return back to its parent function (usually your
211  * elm_main() function). This does not mean the main loop instantly quits.
212  * So your ecore callbacks(timer, animator, event, job, and etc.) have chances
213  * to be called even after elm_exit().
214  *
215  * @see elm_init() for an example. There, just after a request to
216  * close the window comes, the main loop will be left.
217  *
218  * @note By using the appropriate #ELM_POLICY_QUIT on your Elementary
219  * applications, you'll be able to get this function called automatically for you.
220  *
221  * @ingroup General
222  */
223 EAPI void      elm_exit(void);
224
225 /**
226  * Exposed symbol used only by macros and should not be used by apps
227  */
228 EAPI void      elm_quicklaunch_mode_set(Eina_Bool ql_on);
229
230 /**
231  * Exposed symbol used only by macros and should not be used by apps
232  */
233 EAPI Eina_Bool elm_quicklaunch_mode_get(void);
234
235 /**
236  * Exposed symbol used only by macros and should not be used by apps
237  */
238 EAPI int       elm_quicklaunch_init(int argc, char **argv);
239
240 /**
241  * Exposed symbol used only by macros and should not be used by apps
242  */
243 EAPI int       elm_quicklaunch_sub_init(int argc, char **argv);
244
245 /**
246  * Exposed symbol used only by macros and should not be used by apps
247  */
248 EAPI int       elm_quicklaunch_sub_shutdown(void);
249
250 /**
251  * Exposed symbol used only by macros and should not be used by apps
252  */
253 EAPI int       elm_quicklaunch_shutdown(void);
254
255 /**
256  * Exposed symbol used only by macros and should not be used by apps
257  */
258 EAPI void      elm_quicklaunch_seed(void);
259
260 /**
261  * Exposed symbol used only by macros and should not be used by apps
262  */
263 EAPI Eina_Bool elm_quicklaunch_prepare(int argc, char **argv);
264
265 /**
266  * Exposed symbol used only by macros and should not be used by apps
267  */
268 EAPI Eina_Bool elm_quicklaunch_fork(int argc, char **argv, char *cwd, void (postfork_func) (void *data), void *postfork_data);
269
270 /**
271  * Exposed symbol used only by macros and should not be used by apps
272  */
273 EAPI void      elm_quicklaunch_cleanup(void);
274
275 /**
276  * Exposed symbol used only by macros and should not be used by apps
277  */
278 EAPI int       elm_quicklaunch_fallback(int argc, char **argv);
279
280 /**
281  * Exposed symbol used only by macros and should not be used by apps
282  */
283 EAPI char     *elm_quicklaunch_exe_path_get(const char *exe);
284
285 /**
286  * Set a new policy's value (for a given policy group/identifier).
287  *
288  * @param policy policy identifier, as in @ref Elm_Policy.
289  * @param value policy value, which depends on the identifier
290  *
291  * @return @c EINA_TRUE on success or @c EINA_FALSE, on error.
292  *
293  * Elementary policies define applications' behavior,
294  * somehow. These behaviors are divided in policy groups
295  * (see #Elm_Policy enumeration). This call will emit the Ecore
296  * event #ELM_EVENT_POLICY_CHANGED, which can be hooked at with
297  * handlers. An #Elm_Event_Policy_Changed struct will be passed,
298  * then.
299  *
300  * @note Currently, we have only one policy identifier/group
301  * (#ELM_POLICY_QUIT), which has two possible values.
302  *
303  * @ingroup General
304  */
305 EAPI Eina_Bool elm_policy_set(unsigned int policy, int value);
306
307 /**
308  * Gets the policy value for given policy identifier.
309  *
310  * @param policy policy identifier, as in #Elm_Policy.
311  * @return The currently set policy value, for that
312  * identifier. Will be @c 0 if @p policy passed is invalid.
313  *
314  * @ingroup General
315  */
316 EAPI int       elm_policy_get(unsigned int policy);
317
318 /**
319  * Change the language of the current application
320  *
321  * The @p lang passed must be the full name of the locale to use, for
322  * example "en_US.utf8" or "es_ES@euro".
323  *
324  * Changing language with this function will make Elementary run through
325  * all its widgets, translating strings set with
326  * elm_object_domain_translatable_text_part_set(). This way, an entire
327  * UI can have its language changed without having to restart the program.
328  *
329  * For more complex cases, like having formatted strings that need
330  * translation, widgets will also emit a "language,changed" signal that
331  * the user can listen to to manually translate the text.
332  *
333  * @param lang Language to set, must be the full name of the locale
334  *
335  * @ingroup General
336  */
337 EAPI void      elm_language_set(const char *lang);
338
339 /**
340  * Set the text for an objects' part, marking it as translatable.
341  *
342  * The string to set as @p text must be the original one. Do not pass the
343  * return of @c gettext() here. Elementary will translate the string
344  * internally and set it on the object using elm_object_part_text_set(),
345  * also storing the original string so that it can be automatically
346  * translated when the language is changed with elm_language_set().
347  *
348  * The @p domain will be stored along to find the translation in the
349  * correct catalog. It can be NULL, in which case it will use whatever
350  * domain was set by the application with @c textdomain(). This is useful
351  * in case you are building a library on top of Elementary that will have
352  * its own translatable strings, that should not be mixed with those of
353  * programs using the library.
354  *
355  * @param obj The object containing the text part
356  * @param part The name of the part to set
357  * @param domain The translation domain to use
358  * @param text The original, non-translated text to set
359  *
360  * @ingroup General
361  */
362 EAPI void      elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text);
363
364 #define elm_object_domain_translatable_text_set(obj, domain, text) elm_object_domain_translatable_text_part_set((obj), NULL, (domain), (text))
365
366 #define elm_object_translatable_text_set(obj, text)                elm_object_domain_translatable_text_part_set((obj), NULL, NULL, (text))
367
368 /**
369  * Gets the original string set as translatable for an object
370  *
371  * When setting translated strings, the function elm_object_part_text_get()
372  * will return the translation returned by @c gettext(). To get the
373  * original string use this function.
374  *
375  * @param obj The object
376  * @param part The name of the part that was set
377  *
378  * @return The original, untranslated string
379  *
380  * @ingroup General
381  */
382 EAPI const char *elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part);
383
384 #define elm_object_translatable_text_get(obj) elm_object_translatable_text_part_get((obj), NULL)
385
386 /**
387  * @}
388  */