Initialize Tizen 2.3
[framework/uifw/elementary.git] / mobile / src / lib / elm_main.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4
5 #ifdef HAVE_FORK
6 #include <dlfcn.h> /* dlopen,dlclose,etc */
7 #endif
8
9 #ifdef HAVE_CRT_EXTERNS_H
10 # include <crt_externs.h>
11 #endif
12
13 #ifdef HAVE_EVIL
14 # include <Evil.h>
15 #endif
16
17 #ifdef HAVE_EMOTION
18 # include <Emotion.h>
19 #endif
20
21 #include <Elementary.h>
22 #include "elm_priv.h"
23
24 #define SEMI_BROKEN_QUICKLAUNCH 1
25
26 static Elm_Version _version = { VMAJ, VMIN, VMIC, VREV };
27 EAPI Elm_Version *elm_version = &_version;
28
29 Eina_Bool
30 _elm_dangerous_call_check(const char *call)
31 {
32    char buf[256];
33    const char *eval;
34
35    snprintf(buf, sizeof(buf), "%i.%i.%i.%i", VMAJ, VMIN, VMIC, VREV);
36    eval = getenv("ELM_NO_FINGER_WAGGLING");
37    if ((eval) && (!strcmp(eval, buf)))
38      return 0;
39    printf("ELEMENTARY FINGER WAGGLE!!!!!!!!!!\n"
40           "\n"
41           "  %s() used.\n"
42           "PLEASE see the API documentation for this function. This call\n"
43           "should almost never be used. Only in very special cases.\n"
44           "\n"
45           "To remove this warning please set the environment variable:\n"
46           "  ELM_NO_FINGER_WAGGLING\n"
47           "To the value of the Elementary version + revision number. e.g.:\n"
48           "  1.2.5.40295\n"
49           "\n"
50           ,
51           call);
52    return 1;
53 }
54
55 static Eina_Bool _elm_signal_exit(void *data,
56                                   int   ev_type,
57                                   void *ev);
58
59 static Eina_Prefix *pfx = NULL;
60 char *_elm_appname = NULL;
61 const char *_elm_data_dir = NULL;
62 const char *_elm_lib_dir = NULL;
63 int _elm_log_dom = -1;
64
65 EAPI int ELM_EVENT_POLICY_CHANGED = 0;
66
67 static int _elm_init_count = 0;
68 static int _elm_sub_init_count = 0;
69 static int _elm_ql_init_count = 0;
70 static int _elm_policies[ELM_POLICY_LAST];
71 static Ecore_Event_Handler *_elm_exit_handler = NULL;
72 static Eina_Bool quicklaunch_on = 0;
73
74 static Eina_Bool
75 _elm_signal_exit(void *data  __UNUSED__,
76                  int ev_type __UNUSED__,
77                  void *ev    __UNUSED__)
78 {
79    elm_exit();
80    return ECORE_CALLBACK_PASS_ON;
81 }
82
83 void
84 _elm_rescale(void)
85 {
86    edje_scale_set(_elm_config->scale);
87    _elm_win_rescale(NULL, EINA_FALSE);
88    _elm_ews_wm_rescale(NULL, EINA_FALSE);
89 }
90
91 static Eina_Bool _emotion_inited = EINA_FALSE;
92
93 void
94 _elm_emotion_init(void)
95 {
96    if (_emotion_inited) return ;
97
98 #if HAVE_EMOTION
99    emotion_init();
100    _emotion_inited = EINA_TRUE;
101 #endif
102 }
103
104 void
105 _elm_emotion_shutdown(void)
106 {
107    if (!_emotion_inited) return ;
108
109 #if HAVE_EMOTION
110    emotion_shutdown();
111    _emotion_inited = EINA_FALSE;
112 #endif
113 }
114
115 static void *app_mainfunc = NULL;
116 static const char *app_domain = NULL;
117 static const char *app_checkfile = NULL;
118
119 static const char *app_compile_bin_dir = NULL;
120 static const char *app_compile_lib_dir = NULL;
121 static const char *app_compile_data_dir = NULL;
122 static const char *app_compile_locale_dir = NULL;
123 static const char *app_prefix_dir = NULL;
124 static const char *app_bin_dir = NULL;
125 static const char *app_lib_dir = NULL;
126 static const char *app_data_dir = NULL;
127 static const char *app_locale_dir = NULL;
128
129 static Eina_Prefix *app_pfx = NULL;
130
131 static void
132 _prefix_check(void)
133 {
134    int argc = 0;
135    char **argv = NULL;
136    const char *dirs[4] = { NULL, NULL, NULL, NULL };
137    char *caps = NULL, *p1, *p2;
138    char buf[PATH_MAX];
139
140    if (app_pfx) return;
141    if (!app_domain) return;
142
143    ecore_app_args_get(&argc, &argv);
144    if (argc < 1) return;
145
146    dirs[0] = app_compile_bin_dir;
147    dirs[1] = app_compile_lib_dir;
148    dirs[2] = app_compile_data_dir;
149    dirs[3] = app_compile_locale_dir;
150
151    if (!dirs[0]) dirs[0] = "/usr/local/bin";
152    if (!dirs[1]) dirs[1] = "/usr/local/lib";
153    if (!dirs[2])
154      {
155         snprintf(buf, sizeof(buf), "/usr/local/share/%s", app_domain);
156         dirs[2] = buf;
157      }
158    if (!dirs[3]) dirs[3] = dirs[2];
159
160    if (app_domain)
161      {
162         caps = alloca(strlen(app_domain) + 1);
163         for (p1 = (char *)app_domain, p2 = caps; *p1; p1++, p2++)
164            *p2 = toupper(*p1);
165         *p2 = 0;
166      }
167    app_pfx = eina_prefix_new(argv[0], app_mainfunc, caps, app_domain,
168                              app_checkfile, dirs[0], dirs[1], dirs[2], dirs[3]);
169 }
170
171 static void
172 _prefix_shutdown(void)
173 {
174    if (app_pfx) eina_prefix_free(app_pfx);
175    if (app_domain) eina_stringshare_del(app_domain);
176    if (app_checkfile) eina_stringshare_del(app_checkfile);
177    if (app_compile_bin_dir) eina_stringshare_del(app_compile_bin_dir);
178    if (app_compile_lib_dir) eina_stringshare_del(app_compile_lib_dir);
179    if (app_compile_data_dir) eina_stringshare_del(app_compile_data_dir);
180    if (app_compile_locale_dir) eina_stringshare_del(app_compile_locale_dir);
181    if (app_prefix_dir) eina_stringshare_del(app_prefix_dir);
182    if (app_bin_dir) eina_stringshare_del(app_bin_dir);
183    if (app_lib_dir) eina_stringshare_del(app_lib_dir);
184    if (app_data_dir) eina_stringshare_del(app_data_dir);
185    if (app_locale_dir) eina_stringshare_del(app_locale_dir);
186    app_mainfunc = NULL;
187    app_domain = NULL;
188    app_checkfile = NULL;
189    app_compile_bin_dir = NULL;
190    app_compile_lib_dir = NULL;
191    app_compile_data_dir = NULL;
192    app_compile_locale_dir = NULL;
193    app_prefix_dir = NULL;
194    app_bin_dir = NULL;
195    app_lib_dir = NULL;
196    app_data_dir = NULL;
197    app_locale_dir = NULL;
198    app_pfx = NULL;
199 }
200
201 EAPI int
202 elm_init(int    argc,
203          char **argv)
204 {
205    _elm_init_count++;
206    if (_elm_init_count > 1) return _elm_init_count;
207    elm_quicklaunch_init(argc, argv);
208    elm_quicklaunch_sub_init(argc, argv);
209    _prefix_shutdown();
210    return _elm_init_count;
211 }
212
213 EAPI int
214 elm_shutdown(void)
215 {
216    if (_elm_init_count <= 0)
217      {
218         ERR("Init count not greater than 0 in shutdown.");
219         return 0;
220      }
221    _elm_init_count--;
222    if (_elm_init_count > 0) return _elm_init_count;
223    _elm_win_shutdown();
224    while (_elm_win_deferred_free) ecore_main_loop_iterate();
225 // wrningz :(
226 //   _prefix_shutdown();
227    elm_quicklaunch_sub_shutdown();
228    elm_quicklaunch_shutdown();
229    return _elm_init_count;
230 }
231
232 EAPI void
233 elm_app_info_set(void *mainfunc, const char *dom, const char *checkfile)
234 {
235    app_mainfunc = mainfunc;
236    eina_stringshare_replace(&app_domain, dom);
237    eina_stringshare_replace(&app_checkfile, checkfile);
238 }
239
240 EAPI void
241 elm_app_compile_bin_dir_set(const char *dir)
242 {
243    eina_stringshare_replace(&app_compile_bin_dir, dir);
244 }
245
246 EAPI void
247 elm_app_compile_lib_dir_set(const char *dir)
248 {
249    eina_stringshare_replace(&app_compile_lib_dir, dir);
250 }
251
252 EAPI void
253 elm_app_compile_data_dir_set(const char *dir)
254 {
255    eina_stringshare_replace(&app_compile_data_dir, dir);
256 }
257
258 EAPI void
259 elm_app_compile_locale_set(const char *dir)
260 {
261    eina_stringshare_replace(&app_compile_locale_dir, dir);
262 }
263
264 EAPI const char *
265 elm_app_prefix_dir_get(void)
266 {
267    if (app_prefix_dir) return app_prefix_dir;
268    _prefix_check();
269   if (!app_pfx) return "";
270    app_prefix_dir = eina_prefix_get(app_pfx);
271    return app_prefix_dir;
272 }
273
274 EAPI const char *
275 elm_app_bin_dir_get(void)
276 {
277    if (app_bin_dir) return app_bin_dir;
278    _prefix_check();
279    if (!app_pfx) return "";
280    app_bin_dir = eina_prefix_bin_get(app_pfx);
281    return app_bin_dir;
282 }
283
284 EAPI const char *
285 elm_app_lib_dir_get(void)
286 {
287    if (app_lib_dir) return app_lib_dir;
288    _prefix_check();
289    if (!app_pfx) return "";
290    app_lib_dir = eina_prefix_lib_get(app_pfx);
291    return app_lib_dir;
292 }
293
294 EAPI const char *
295 elm_app_data_dir_get(void)
296 {
297    if (app_data_dir) return app_data_dir;
298    _prefix_check();
299    if (!app_pfx) return "";
300    app_data_dir = eina_prefix_data_get(app_pfx);
301    return app_data_dir;
302 }
303
304 EAPI const char *
305 elm_app_locale_dir_get(void)
306 {
307    if (app_locale_dir) return app_locale_dir;
308    _prefix_check();
309    if (!app_pfx) return "";
310    app_locale_dir = eina_prefix_locale_get(app_pfx);
311    return app_locale_dir;
312 }
313
314 #ifdef ELM_EDBUS
315 static int _elm_need_e_dbus = 0;
316 #endif
317 EAPI Eina_Bool
318 elm_need_e_dbus(void)
319 {
320 #ifdef ELM_EDBUS
321    if (_elm_need_e_dbus++) return EINA_TRUE;
322    e_dbus_init();
323    return EINA_TRUE;
324 #else
325    return EINA_FALSE;
326 #endif
327 }
328
329 static void
330 _elm_unneed_e_dbus(void)
331 {
332 #ifdef ELM_EDBUS
333    if (--_elm_need_e_dbus) return;
334
335    _elm_need_e_dbus = 0;
336    e_dbus_shutdown();
337 #endif
338 }
339
340 #ifdef ELM_EFREET
341 static int _elm_need_efreet = 0;
342 #endif
343 EAPI Eina_Bool
344 elm_need_efreet(void)
345 {
346 #ifdef ELM_EFREET
347    if (_elm_need_efreet++) return EINA_TRUE;
348    efreet_init();
349    efreet_mime_init();
350    efreet_trash_init();
351     /*
352      {
353         Eina_List **list;
354
355         list = efreet_icon_extra_list_get();
356         if (list)
357           {
358              e_user_dir_concat_static(buf, "icons");
359              *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
360              e_prefix_data_concat_static(buf, "data/icons");
361              *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
362           }
363      }
364    */
365    return EINA_TRUE;
366 #else
367    return EINA_FALSE;
368 #endif
369 }
370
371 static void
372 _elm_unneed_efreet(void)
373 {
374 #ifdef ELM_EFREET
375    if (--_elm_need_efreet) return;
376
377    _elm_need_efreet = 0;
378    efreet_trash_shutdown();
379    efreet_mime_shutdown();
380    efreet_shutdown();
381 #endif
382 }
383
384 EAPI void
385 elm_quicklaunch_mode_set(Eina_Bool ql_on)
386 {
387    quicklaunch_on = ql_on;
388 }
389
390 EAPI Eina_Bool
391 elm_quicklaunch_mode_get(void)
392 {
393    return quicklaunch_on;
394 }
395
396 EAPI int
397 elm_quicklaunch_init(int    argc,
398                      char **argv)
399 {
400    _elm_ql_init_count++;
401    if (_elm_ql_init_count > 1) return _elm_ql_init_count;
402    eina_init();
403    _elm_log_dom = eina_log_domain_register("elementary", EINA_COLOR_LIGHTBLUE);
404    if (!_elm_log_dom)
405      {
406         EINA_LOG_ERR("could not register elementary log domain.");
407         _elm_log_dom = EINA_LOG_DOMAIN_GLOBAL;
408      }
409
410    eet_init();
411    ecore_init();
412
413 #ifdef HAVE_ELEMENTARY_EMAP
414    emap_init();
415 #endif
416    ecore_app_args_set(argc, (const char **)argv);
417
418    memset(_elm_policies, 0, sizeof(_elm_policies));
419    if (!ELM_EVENT_POLICY_CHANGED)
420      ELM_EVENT_POLICY_CHANGED = ecore_event_type_new();
421
422    ecore_file_init();
423
424    _elm_exit_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, NULL);
425
426    if (argv) _elm_appname = strdup(ecore_file_file_get(argv[0]));
427
428    pfx = eina_prefix_new(argv ? argv[0] : NULL, elm_quicklaunch_init,
429                          "ELM", "elementary", "config/profile.cfg",
430                          PACKAGE_LIB_DIR, /* don't have a bin dir currently */
431                          PACKAGE_LIB_DIR,
432                          PACKAGE_DATA_DIR,
433                          LOCALE_DIR);
434    if (pfx)
435      {
436         _elm_data_dir = eina_stringshare_add(eina_prefix_data_get(pfx));
437         _elm_lib_dir = eina_stringshare_add(eina_prefix_lib_get(pfx));
438      }
439    if (!_elm_data_dir) _elm_data_dir = eina_stringshare_add("/");
440    if (!_elm_lib_dir) _elm_lib_dir = eina_stringshare_add("/");
441
442    return _elm_ql_init_count;
443 }
444
445 EAPI int
446 elm_quicklaunch_sub_init(int    argc,
447                          char **argv)
448 {
449    _elm_sub_init_count++;
450    if (_elm_sub_init_count > 1) return _elm_sub_init_count;
451    if (quicklaunch_on)
452      {
453         _elm_config_init();
454 #ifdef SEMI_BROKEN_QUICKLAUNCH
455         return _elm_sub_init_count;
456 #endif
457      }
458
459    if (!quicklaunch_on)
460      {
461         ecore_app_args_set(argc, (const char **)argv);
462         evas_init();
463         edje_init();
464         _elm_module_init();
465         _elm_config_init();
466         _elm_config_sub_init();
467         ecore_evas_init(); // FIXME: check errors
468 #ifdef HAVE_ELEMENTARY_ECORE_IMF
469         ecore_imf_init();
470 #endif
471 #ifdef HAVE_ELEMENTARY_ECORE_CON
472         ecore_con_init();
473         ecore_con_url_init();
474 #endif
475         _elm_ews_wm_init();
476      }
477    return _elm_sub_init_count;
478 }
479
480 EAPI int
481 elm_quicklaunch_sub_shutdown(void)
482 {
483    _elm_sub_init_count--;
484    if (_elm_sub_init_count > 0) return _elm_sub_init_count;
485    if (quicklaunch_on)
486      {
487 #ifdef SEMI_BROKEN_QUICKLAUNCH
488         return _elm_sub_init_count;
489 #endif
490      }
491    if (!quicklaunch_on)
492      {
493         _elm_win_shutdown();
494         _elm_module_shutdown();
495         _elm_ews_wm_shutdown();
496 #ifdef HAVE_ELEMENTARY_ECORE_CON
497         ecore_con_url_shutdown();
498         ecore_con_shutdown();
499 #endif
500 #ifdef HAVE_ELEMENTARY_ECORE_IMF
501         ecore_imf_shutdown();
502 #endif
503         ecore_evas_shutdown();
504         _elm_config_sub_shutdown();
505 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
506         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
507             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
508             ENGINE_COMPARE(ELM_XRENDER_X11) ||
509             ENGINE_COMPARE(ELM_OPENGL_X11) ||
510             ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
511             ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
512             ENGINE_COMPARE(ELM_OPENGL_SDL) ||
513             ENGINE_COMPARE(ELM_OPENGL_COCOA) ||
514             ENGINE_COMPARE(ELM_SOFTWARE_WIN32) ||
515             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
516             ENGINE_COMPARE(ELM_EWS))
517 #undef ENGINE_COMPARE
518           evas_cserve_disconnect();
519         edje_shutdown();
520         evas_shutdown();
521      }
522    return _elm_sub_init_count;
523 }
524
525 EAPI int
526 elm_quicklaunch_shutdown(void)
527 {
528    _elm_ql_init_count--;
529    if (_elm_ql_init_count > 0) return _elm_ql_init_count;
530    if (pfx) eina_prefix_free(pfx);
531    pfx = NULL;
532    eina_stringshare_del(_elm_data_dir);
533    _elm_data_dir = NULL;
534    eina_stringshare_del(_elm_lib_dir);
535    _elm_lib_dir = NULL;
536
537    free(_elm_appname);
538    _elm_appname = NULL;
539
540    _elm_config_shutdown();
541
542    ecore_event_handler_del(_elm_exit_handler);
543    _elm_exit_handler = NULL;
544
545    _elm_theme_shutdown();
546    _elm_unneed_efreet();
547    _elm_unneed_e_dbus();
548    _elm_unneed_ethumb();
549    _elm_unneed_web();
550    ecore_file_shutdown();
551
552 #ifdef HAVE_ELEMENTARY_EMAP
553    emap_shutdown();
554 #endif
555 #ifdef HAVE_EMOTION
556    _elm_emotion_shutdown();
557 #endif
558
559    ecore_shutdown();
560    eet_shutdown();
561
562    if ((_elm_log_dom > -1) && (_elm_log_dom != EINA_LOG_DOMAIN_GLOBAL))
563      {
564         eina_log_domain_unregister(_elm_log_dom);
565         _elm_log_dom = -1;
566      }
567
568    eina_shutdown();
569    return _elm_ql_init_count;
570 }
571
572 EAPI void
573 elm_quicklaunch_seed(void)
574 {
575 #ifndef SEMI_BROKEN_QUICKLAUNCH
576    if (quicklaunch_on)
577      {
578         Evas_Object *win, *bg, *bt;
579
580         win = elm_win_add(NULL, "seed", ELM_WIN_BASIC);
581         bg = elm_bg_add(win);
582         elm_win_resize_object_add(win, bg);
583         evas_object_show(bg);
584         bt = elm_button_add(win);
585         elm_object_text_set(bt, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~-_=+\\|]}[{;:'\",<.>/?");
586         elm_win_resize_object_add(win, bt);
587         ecore_main_loop_iterate();
588         evas_object_del(win);
589         ecore_main_loop_iterate();
590 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
591         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
592             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
593             ENGINE_COMPARE(ELM_XRENDER_X11) ||
594             ENGINE_COMPARE(ELM_OPENGL_X11))
595 #undef ENGINE_COMPARE
596           {
597 # ifdef HAVE_ELEMENTARY_X
598              ecore_x_sync();
599 # endif
600           }
601         ecore_main_loop_iterate();
602      }
603 #endif
604 }
605
606 #ifdef HAVE_FORK
607 static void *qr_handle = NULL;
608 #endif
609 static int (*qr_main)(int    argc,
610                       char **argv) = NULL;
611
612 EAPI Eina_Bool
613 elm_quicklaunch_prepare(int    argc,
614                         char **argv)
615 {
616 #ifdef HAVE_FORK
617    char *exe;
618
619    if (argc <= 0 || argv == NULL) return EINA_FALSE;
620
621    exe = elm_quicklaunch_exe_path_get(argv[0]);
622    if (!exe)
623      {
624         ERR("requested quicklaunch binary '%s' does not exist\n", argv[0]);
625         return EINA_FALSE;
626      }
627    else
628      {
629         char *exe2, *p;
630         char *exename;
631
632         exe2 = malloc(strlen(exe) + 1 + 10);
633         strcpy(exe2, exe);
634         p = strrchr(exe2, '/');
635         if (p) p++;
636         else p = exe2;
637         exename = alloca(strlen(p) + 1);
638         strcpy(exename, p);
639         *p = 0;
640         strcat(p, "../lib/");
641         strcat(p, exename);
642         strcat(p, ".so");
643         if (!access(exe2, R_OK | X_OK))
644           {
645              free(exe);
646              exe = exe2;
647           }
648         else
649           free(exe2);
650      }
651    qr_handle = dlopen(exe, RTLD_NOW | RTLD_GLOBAL);
652    if (!qr_handle)
653      {
654         fprintf(stderr, "dlerr: %s\n", dlerror());
655         WRN("dlopen('%s') failed: %s", exe, dlerror());
656         free(exe);
657         return EINA_FALSE;
658      }
659    INF("dlopen('%s') = %p", exe, qr_handle);
660    qr_main = dlsym(qr_handle, "elm_main");
661    INF("dlsym(%p, 'elm_main') = %p", qr_handle, qr_main);
662    if (!qr_main)
663      {
664         WRN("not quicklauncher capable: no elm_main in '%s'", exe);
665         dlclose(qr_handle);
666         qr_handle = NULL;
667         free(exe);
668         return EINA_FALSE;
669      }
670    free(exe);
671    return EINA_TRUE;
672 #else
673    return EINA_FALSE;
674    (void)argv;
675 #endif
676 }
677
678 EAPI Eina_Bool
679 elm_quicklaunch_fork(int    argc,
680                      char **argv,
681                      char  *cwd,
682                      void (postfork_func) (void *data),
683                      void  *postfork_data)
684 {
685 #ifdef HAVE_FORK
686    pid_t child;
687    int ret;
688
689    if (!qr_main)
690      {
691         int i;
692         char **args;
693
694         child = fork();
695         if (child > 0) return EINA_TRUE;
696         else if (child < 0)
697           {
698              perror("could not fork");
699              return EINA_FALSE;
700           }
701         setsid();
702         if (chdir(cwd) != 0) perror("could not chdir");
703         args = alloca((argc + 1) * sizeof(char *));
704         for (i = 0; i < argc; i++) args[i] = argv[i];
705         args[argc] = NULL;
706         WRN("%s not quicklaunch capable, fallback...", argv[0]);
707         execvp(argv[0], args);
708         ERR("failed to execute '%s': %s", argv[0], strerror(errno));
709         exit(-1);
710      }
711    child = fork();
712    if (child > 0) return EINA_TRUE;
713    else if (child < 0)
714      {
715         perror("could not fork");
716         return EINA_FALSE;
717      }
718    if (postfork_func) postfork_func(postfork_data);
719
720    ecore_fork_reset();
721
722    if (quicklaunch_on)
723      {
724         if (_elm_appname) free(_elm_appname);
725         _elm_appname = NULL;
726         if ((argv) && (argv[0]))
727           _elm_appname = strdup(ecore_file_file_get(argv[0]));
728
729 #ifdef SEMI_BROKEN_QUICKLAUNCH
730         ecore_app_args_set(argc, (const char **)argv);
731         evas_init();
732         edje_init();
733         _elm_module_init();
734         _elm_config_sub_init();
735 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
736         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
737             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
738             ENGINE_COMPARE(ELM_XRENDER_X11) ||
739             ENGINE_COMPARE(ELM_OPENGL_X11))
740 #undef ENGINE_COMPARE
741           {
742 # ifdef HAVE_ELEMENTARY_X
743              ecore_x_init(NULL);
744 # endif
745           }
746         ecore_evas_init(); // FIXME: check errors
747 # ifdef HAVE_ELEMENTARY_ECORE_IMF
748         ecore_imf_init();
749 # endif
750 #endif
751      }
752
753    setsid();
754    if (chdir(cwd) != 0) perror("could not chdir");
755    ecore_app_args_set(argc, (const char **)argv);
756    ret = qr_main(argc, argv);
757    exit(ret);
758    return EINA_TRUE;
759 #else
760    return EINA_FALSE;
761    (void)argc;
762    (void)argv;
763    (void)cwd;
764    (void)postfork_func;
765    (void)postfork_data;
766 #endif
767 }
768
769 EAPI void
770 elm_quicklaunch_cleanup(void)
771 {
772 #ifdef HAVE_FORK
773    if (qr_handle)
774      {
775         dlclose(qr_handle);
776         qr_handle = NULL;
777         qr_main = NULL;
778      }
779 #endif
780 }
781
782 EAPI int
783 elm_quicklaunch_fallback(int    argc,
784                          char **argv)
785 {
786    int ret;
787    elm_quicklaunch_init(argc, argv);
788    elm_quicklaunch_sub_init(argc, argv);
789    elm_quicklaunch_prepare(argc, argv);
790    ret = qr_main(argc, argv);
791    exit(ret);
792    return ret;
793 }
794
795 EAPI char *
796 elm_quicklaunch_exe_path_get(const char *exe)
797 {
798    static char *path = NULL;
799    static Eina_List *pathlist = NULL;
800    const char *pathitr;
801    const Eina_List *l;
802    char buf[PATH_MAX];
803    if (exe[0] == '/') return strdup(exe);
804    if ((exe[0] == '.') && (exe[1] == '/')) return strdup(exe);
805    if ((exe[0] == '.') && (exe[1] == '.') && (exe[2] == '/')) return strdup(exe);
806    if (!path)
807      {
808         const char *p, *pp;
809         char *buf2;
810         path = getenv("PATH");
811         buf2 = alloca(strlen(path) + 1);
812         p = path;
813         pp = p;
814         for (;; )
815           {
816              if ((*p == ':') || (!*p))
817                {
818                   int len;
819
820                   len = p - pp;
821                   strncpy(buf2, pp, len);
822                   buf2[len] = 0;
823                   pathlist = eina_list_append(pathlist, eina_stringshare_add(buf2));
824                   if (!*p) break;
825                   p++;
826                   pp = p;
827                }
828              else
829                {
830                   if (!*p) break;
831                   p++;
832                }
833           }
834      }
835    EINA_LIST_FOREACH(pathlist, l, pathitr)
836      {
837         snprintf(buf, sizeof(buf), "%s/%s", pathitr, exe);
838         if (!access(buf, R_OK | X_OK)) return strdup(buf);
839      }
840    return NULL;
841 }
842
843 EAPI void
844 elm_run(void)
845 {
846    ecore_main_loop_begin();
847 }
848
849 EAPI void
850 elm_exit(void)
851 {
852    ecore_main_loop_quit();
853
854    if (elm_policy_get(ELM_POLICY_EXIT) == ELM_POLICY_EXIT_WINDOWS_DEL)
855      {
856         Eina_List *l, *l_next;
857         Evas_Object *win;
858
859         EINA_LIST_FOREACH_SAFE(_elm_win_list, l, l_next, win)
860            evas_object_del(win);
861      }
862 }
863
864 //FIXME: Use Elm_Policy Parameter when 2.0 is released.
865 EAPI Eina_Bool
866 elm_policy_set(unsigned int policy,
867                int          value)
868 {
869    Elm_Event_Policy_Changed *ev;
870
871    if (policy >= ELM_POLICY_LAST)
872      return EINA_FALSE;
873
874    if (value == _elm_policies[policy])
875      return EINA_TRUE;
876
877    /* TODO: validate policy? */
878
879    ev = malloc(sizeof(*ev));
880    ev->policy = policy;
881    ev->new_value = value;
882    ev->old_value = _elm_policies[policy];
883
884    _elm_policies[policy] = value;
885
886    ecore_event_add(ELM_EVENT_POLICY_CHANGED, ev, NULL, NULL);
887
888    return EINA_TRUE;
889 }
890
891 //FIXME: Use Elm_Policy Parameter when 2.0 is released.
892 EAPI int
893 elm_policy_get(unsigned int policy)
894 {
895    if (policy >= ELM_POLICY_LAST)
896      return 0;
897    return _elm_policies[policy];
898 }
899
900 EAPI void
901 elm_language_set(const char *lang)
902 {
903    setlocale(LC_ALL, lang);
904    _elm_win_translate();
905 }
906
907 EAPI Eina_Bool
908 elm_object_mirrored_get(const Evas_Object *obj)
909 {
910    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
911    return elm_widget_mirrored_get(obj);
912 }
913
914 EAPI void
915 elm_object_mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
916 {
917    EINA_SAFETY_ON_NULL_RETURN(obj);
918    elm_widget_mirrored_set(obj, mirrored);
919 }
920
921 EAPI Eina_Bool
922 elm_object_mirrored_automatic_get(const Evas_Object *obj)
923 {
924    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
925    return elm_widget_mirrored_automatic_get(obj);
926 }
927
928 EAPI void
929 elm_object_mirrored_automatic_set(Evas_Object *obj, Eina_Bool automatic)
930 {
931    EINA_SAFETY_ON_NULL_RETURN(obj);
932    elm_widget_mirrored_automatic_set(obj, automatic);
933 }
934
935 /**
936  * @}
937  */
938
939 EAPI void
940 elm_object_scale_set(Evas_Object *obj,
941                      double       scale)
942 {
943    EINA_SAFETY_ON_NULL_RETURN(obj);
944    elm_widget_scale_set(obj, scale);
945 }
946
947 EAPI double
948 elm_object_scale_get(const Evas_Object *obj)
949 {
950    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0.0);
951    return elm_widget_scale_get(obj);
952 }
953
954 EAPI void
955 elm_object_part_text_set(Evas_Object *obj, const char *part, const char *label)
956 {
957    EINA_SAFETY_ON_NULL_RETURN(obj);
958    elm_widget_text_part_set(obj, part, label);
959 }
960
961 EAPI const char *
962 elm_object_part_text_get(const Evas_Object *obj, const char *part)
963 {
964    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
965    return elm_widget_text_part_get(obj, part);
966 }
967
968 EAPI void
969 elm_object_domain_translatable_part_text_set(Evas_Object *obj, const char *part, const char *domain, const char *text)
970 {
971    EINA_SAFETY_ON_NULL_RETURN(obj);
972    elm_widget_domain_translatable_part_text_set(obj, part, domain, text);
973 }
974
975 EAPI const char *
976 elm_object_translatable_part_text_get(const Evas_Object *obj, const char *part)
977 {
978    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
979    return elm_widget_translatable_part_text_get(obj, part);
980 }
981
982 EAPI void
983 elm_object_domain_part_text_translatable_set(Evas_Object *obj, const char *part, const char *domain, Eina_Bool translatable)
984 {
985    EINA_SAFETY_ON_NULL_RETURN(obj);
986    elm_widget_domain_part_text_translatable_set(obj, part, domain, translatable);
987 }
988
989 EINA_DEPRECATED EAPI void
990 elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text)
991 {
992    elm_object_domain_translatable_part_text_set(obj, part, domain, text);
993 }
994
995 EINA_DEPRECATED EAPI const char *
996 elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part)
997 {
998    return elm_object_translatable_part_text_get(obj, part);
999 }
1000
1001 EAPI void
1002 elm_object_part_content_set(Evas_Object *obj, const char *part, Evas_Object *content)
1003 {
1004    EINA_SAFETY_ON_NULL_RETURN(obj);
1005    elm_widget_content_part_set(obj, part, content);
1006 }
1007
1008 EAPI Evas_Object *
1009 elm_object_part_content_get(const Evas_Object *obj, const char *part)
1010 {
1011    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1012    return elm_widget_content_part_get(obj, part);
1013 }
1014
1015 EAPI Evas_Object *
1016 elm_object_part_content_unset(Evas_Object *obj, const char *part)
1017 {
1018    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1019    return elm_widget_content_part_unset(obj, part);
1020 }
1021
1022 EAPI Evas_Object *
1023 elm_object_part_access_register(Evas_Object *obj, const char *part)
1024 {
1025    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1026    EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
1027    if (!evas_object_smart_type_check(obj, "elm_layout"))
1028      {
1029         ERR("Only for parts of a layout, access object can be registered");
1030         return NULL;
1031      }
1032
1033    Evas_Object *edj = elm_layout_edje_get(obj);
1034    return _elm_access_edje_object_part_object_register(obj, edj, part);
1035 }
1036
1037 EAPI Eina_Bool
1038 elm_object_style_set(Evas_Object *obj,
1039                      const char  *style)
1040 {
1041    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1042    return elm_widget_style_set(obj, style);
1043 }
1044
1045 EAPI const char *
1046 elm_object_style_get(const Evas_Object *obj)
1047 {
1048    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1049    return elm_widget_style_get(obj);
1050 }
1051
1052 EAPI void
1053 elm_object_disabled_set(Evas_Object *obj,
1054                         Eina_Bool    disabled)
1055 {
1056    EINA_SAFETY_ON_NULL_RETURN(obj);
1057    elm_widget_disabled_set(obj, disabled);
1058 }
1059
1060 EAPI Eina_Bool
1061 elm_object_disabled_get(const Evas_Object *obj)
1062 {
1063    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1064    return elm_widget_disabled_get(obj);
1065 }
1066
1067 EAPI void
1068 elm_cache_all_flush(void)
1069 {
1070    const Eina_List *l;
1071    Evas_Object *obj;
1072
1073    edje_file_cache_flush();
1074    edje_collection_cache_flush();
1075    eet_clearcache();
1076    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1077      {
1078         Evas *e = evas_object_evas_get(obj);
1079         evas_image_cache_flush(e);
1080         evas_font_cache_flush(e);
1081         evas_render_dump(e);
1082      }
1083 }
1084
1085 EAPI Eina_Bool
1086 elm_object_focus_get(const Evas_Object *obj)
1087 {
1088    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1089    return elm_widget_focus_get(obj);
1090 }
1091
1092 EAPI void
1093 elm_object_focus_set(Evas_Object *obj,
1094                      Eina_Bool    focus)
1095 {
1096    EINA_SAFETY_ON_NULL_RETURN(obj);
1097
1098    if (elm_widget_is(obj))
1099      {
1100         const char *type;
1101
1102         //if the focus_next api of each widget does not use elm_object_focus_set();
1103         //you don't need to check the highlight with elm_widget_highlight_get();
1104         if (focus == elm_widget_focus_get(obj)) return;
1105
1106         // ugly, but, special case for inlined windows
1107         type = evas_object_type_get(obj);
1108         if ((type) && (!strcmp(type, "elm_win")))
1109           {
1110              Evas_Object *inlined = elm_win_inlined_image_object_get(obj);
1111
1112              if (inlined)
1113                {
1114                   evas_object_focus_set(inlined, focus);
1115                   return;
1116                }
1117           }
1118         if (focus)
1119           elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1120         else
1121           elm_widget_focused_object_clear(obj);
1122      }
1123    else
1124      {
1125         evas_object_focus_set(obj, focus);
1126      }
1127 }
1128
1129 EAPI void
1130 elm_object_focus_allow_set(Evas_Object *obj,
1131                            Eina_Bool    enable)
1132 {
1133    EINA_SAFETY_ON_NULL_RETURN(obj);
1134    elm_widget_can_focus_set(obj, enable);
1135 /*FIXME: According to the elm_object_focus_allow_get(), child_can_focus field
1136 of the parent should be updated. Otherwise, the checking of it's child focus allow states should not be in elm_object_focus_allow_get() */
1137 }
1138
1139 EAPI Eina_Bool
1140 elm_object_focus_allow_get(const Evas_Object *obj)
1141 {
1142    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1143    return (elm_widget_can_focus_get(obj)) || (elm_widget_child_can_focus_get(obj));
1144 }
1145
1146 EAPI void
1147 elm_object_focus_custom_chain_set(Evas_Object *obj,
1148                                   Eina_List   *objs)
1149 {
1150    EINA_SAFETY_ON_NULL_RETURN(obj);
1151    elm_widget_focus_custom_chain_set(obj, objs);
1152 }
1153
1154 EAPI void
1155 elm_object_focus_custom_chain_unset(Evas_Object *obj)
1156 {
1157    EINA_SAFETY_ON_NULL_RETURN(obj);
1158    elm_widget_focus_custom_chain_unset(obj);
1159 }
1160
1161 EAPI const Eina_List *
1162 elm_object_focus_custom_chain_get(const Evas_Object *obj)
1163 {
1164    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1165    return elm_widget_focus_custom_chain_get(obj);
1166 }
1167
1168 EAPI void
1169 elm_object_focus_custom_chain_append(Evas_Object *obj,
1170                                      Evas_Object *child,
1171                                      Evas_Object *relative_child)
1172 {
1173    EINA_SAFETY_ON_NULL_RETURN(obj);
1174    elm_widget_focus_custom_chain_append(obj, child, relative_child);
1175 }
1176
1177 EAPI void
1178 elm_object_focus_custom_chain_prepend(Evas_Object *obj,
1179                                       Evas_Object *child,
1180                                       Evas_Object *relative_child)
1181 {
1182    EINA_SAFETY_ON_NULL_RETURN(obj);
1183    elm_widget_focus_custom_chain_prepend(obj, child, relative_child);
1184 }
1185
1186 EINA_DEPRECATED EAPI void
1187 elm_object_focus_cycle(Evas_Object        *obj,
1188                        Elm_Focus_Direction dir)
1189 {
1190    elm_object_focus_next(obj, dir);
1191 }
1192
1193 EAPI void
1194 elm_object_focus_next(Evas_Object        *obj,
1195                       Elm_Focus_Direction dir)
1196 {
1197    EINA_SAFETY_ON_NULL_RETURN(obj);
1198    elm_widget_focus_cycle(obj, dir);
1199 }
1200
1201 EAPI Evas_Object *
1202 elm_object_focus_next_object_get(const Evas_Object  *obj,
1203                                  Elm_Focus_Direction dir)
1204 {
1205    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1206    return elm_widget_focus_next_object_get(obj, dir);
1207 }
1208
1209 EAPI void
1210 elm_object_focus_next_object_set(Evas_Object        *obj,
1211                                  Evas_Object        *next,
1212                                  Elm_Focus_Direction dir)
1213 {
1214    EINA_SAFETY_ON_NULL_RETURN(obj);
1215    elm_widget_focus_next_object_set(obj, next, dir);
1216 }
1217
1218 EAPI Evas_Object *
1219 elm_object_focused_object_get(const Evas_Object *obj)
1220 {
1221    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1222    return elm_widget_focused_object_get(obj);
1223 }
1224
1225 EAPI void
1226 elm_object_tree_focus_allow_set(Evas_Object *obj,
1227                                 Eina_Bool    tree_focusable)
1228 {
1229    EINA_SAFETY_ON_NULL_RETURN(obj);
1230    elm_widget_tree_unfocusable_set(obj, !tree_focusable);
1231 }
1232
1233 EAPI Eina_Bool
1234 elm_object_tree_focus_allow_get(const Evas_Object *obj)
1235 {
1236    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1237    return !elm_widget_tree_unfocusable_get(obj);
1238 }
1239
1240 EAPI void
1241 elm_object_scroll_hold_push(Evas_Object *obj)
1242 {
1243    EINA_SAFETY_ON_NULL_RETURN(obj);
1244    elm_widget_scroll_hold_push(obj);
1245 }
1246
1247 EAPI void
1248 elm_object_scroll_hold_pop(Evas_Object *obj)
1249 {
1250    EINA_SAFETY_ON_NULL_RETURN(obj);
1251    elm_widget_scroll_hold_pop(obj);
1252 }
1253
1254 EAPI int
1255 elm_object_scroll_hold_get(const Evas_Object *obj)
1256 {
1257    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0);
1258    return elm_widget_scroll_hold_get(obj);
1259 }
1260
1261 EAPI void
1262 elm_object_scroll_freeze_push(Evas_Object *obj)
1263 {
1264    EINA_SAFETY_ON_NULL_RETURN(obj);
1265    elm_widget_scroll_freeze_push(obj);
1266 }
1267
1268 EAPI void
1269 elm_object_scroll_freeze_pop(Evas_Object *obj)
1270 {
1271    EINA_SAFETY_ON_NULL_RETURN(obj);
1272    elm_widget_scroll_freeze_pop(obj);
1273 }
1274
1275 EAPI int
1276 elm_object_scroll_freeze_get(const Evas_Object *obj)
1277 {
1278    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0);
1279    return elm_widget_scroll_freeze_get(obj);
1280 }
1281
1282 EAPI void
1283 elm_object_scroll_lock_x_set(Evas_Object *obj,
1284                              Eina_Bool    lock)
1285 {
1286    EINA_SAFETY_ON_NULL_RETURN(obj);
1287    elm_widget_drag_lock_x_set(obj, lock);
1288 }
1289
1290 EAPI void
1291 elm_object_scroll_lock_y_set(Evas_Object *obj,
1292                              Eina_Bool    lock)
1293 {
1294    EINA_SAFETY_ON_NULL_RETURN(obj);
1295    elm_widget_drag_lock_y_set(obj, lock);
1296 }
1297
1298 EAPI Eina_Bool
1299 elm_object_scroll_lock_x_get(const Evas_Object *obj)
1300 {
1301    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1302    return elm_widget_drag_lock_x_get(obj);
1303 }
1304
1305 EAPI Eina_Bool
1306 elm_object_scroll_lock_y_get(const Evas_Object *obj)
1307 {
1308    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1309    return elm_widget_drag_lock_y_get(obj);
1310 }
1311
1312 EAPI Eina_Bool
1313 elm_object_widget_check(const Evas_Object *obj)
1314 {
1315    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1316    return elm_widget_is(obj);
1317 }
1318
1319 EAPI Evas_Object *
1320 elm_object_parent_widget_get(const Evas_Object *obj)
1321 {
1322    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1323    return elm_widget_parent_widget_get(obj);
1324 }
1325
1326 EAPI Evas_Object *
1327 elm_object_top_widget_get(const Evas_Object *obj)
1328 {
1329    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1330    return elm_widget_top_get(obj);
1331 }
1332
1333 EAPI const char *
1334 elm_object_widget_type_get(const Evas_Object *obj)
1335 {
1336    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1337    return elm_widget_type_get(obj);
1338 }
1339
1340 EAPI void
1341 elm_object_signal_emit(Evas_Object *obj,
1342                        const char  *emission,
1343                        const char  *source)
1344 {
1345    EINA_SAFETY_ON_NULL_RETURN(obj);
1346    elm_widget_signal_emit(obj, emission, source);
1347 }
1348
1349 EAPI void
1350 elm_object_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
1351 {
1352     EINA_SAFETY_ON_NULL_RETURN(obj);
1353     EINA_SAFETY_ON_NULL_RETURN(func);
1354     elm_widget_signal_callback_add(obj, emission, source, func, data);
1355 }
1356
1357 EAPI void *
1358 elm_object_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func)
1359 {
1360     EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1361     EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1362     return elm_widget_signal_callback_del(obj, emission, source, func);
1363 }
1364
1365 EAPI void
1366 elm_object_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1367 {
1368    EINA_SAFETY_ON_NULL_RETURN(obj);
1369    EINA_SAFETY_ON_NULL_RETURN(func);
1370    elm_widget_event_callback_add(obj, func, data);
1371 }
1372
1373 EAPI void *
1374 elm_object_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1375 {
1376    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1377    EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1378    return elm_widget_event_callback_del(obj, func, data);
1379 }
1380
1381 EAPI void
1382 elm_object_tree_dump(const Evas_Object *top)
1383 {
1384 #ifdef ELM_DEBUG
1385    elm_widget_tree_dump(top);
1386 #else
1387    (void)top;
1388    return;
1389 #endif
1390 }
1391
1392 EAPI void
1393 elm_object_tree_dot_dump(const Evas_Object *top,
1394                          const char        *file)
1395 {
1396 #ifdef ELM_DEBUG
1397    FILE *f = fopen(file, "wb");
1398    elm_widget_tree_dot_dump(top, f);
1399    fclose(f);
1400 #else
1401    (void)top;
1402    (void)file;
1403    return;
1404 #endif
1405 }
1406
1407 EAPI void
1408 elm_coords_finger_size_adjust(int times_w,
1409                               Evas_Coord *w,
1410                               int times_h,
1411                               Evas_Coord *h)
1412 {
1413    if ((w) && (*w < (elm_config_finger_size_get() * times_w)))
1414      *w = elm_config_finger_size_get() * times_w;
1415    if ((h) && (*h < (elm_config_finger_size_get() * times_h)))
1416      *h = elm_config_finger_size_get() * times_h;
1417 }
1418
1419 EAPI Evas_Object *
1420 elm_object_item_widget_get(const Elm_Object_Item *it)
1421 {
1422    return elm_widget_item_widget_get(it);
1423 }
1424
1425 EAPI void
1426 elm_object_item_part_content_set(Elm_Object_Item *it,
1427                                  const char *part,
1428                                  Evas_Object *content)
1429 {
1430    _elm_widget_item_part_content_set((Elm_Widget_Item *)it, part, content);
1431 }
1432
1433 EAPI Evas_Object *
1434 elm_object_item_part_content_get(const Elm_Object_Item *it,
1435                                  const char *part)
1436 {
1437    return _elm_widget_item_part_content_get((Elm_Widget_Item *)it, part);
1438 }
1439
1440 EAPI Evas_Object *
1441 elm_object_item_part_content_unset(Elm_Object_Item *it, const char *part)
1442 {
1443    return _elm_widget_item_part_content_unset((Elm_Widget_Item *)it, part);
1444 }
1445
1446 EAPI void
1447 elm_object_item_part_text_set(Elm_Object_Item *it,
1448                               const char *part,
1449                               const char *label)
1450 {
1451    _elm_widget_item_part_text_set((Elm_Widget_Item *)it, part, label);
1452 }
1453
1454 EAPI const char *
1455 elm_object_item_part_text_get(const Elm_Object_Item *it, const char *part)
1456 {
1457    return _elm_widget_item_part_text_get((Elm_Widget_Item *)it, part);
1458 }
1459
1460 EAPI void
1461 elm_object_item_domain_translatable_part_text_set(Elm_Object_Item *it, const char *part, const char *domain, const char *text)
1462 {
1463    _elm_widget_item_domain_translatable_part_text_set((Elm_Widget_Item *)it, part, domain, text);
1464 }
1465
1466 EAPI const char *
1467 elm_object_item_translatable_part_text_get(const Elm_Object_Item *it, const char *part)
1468 {
1469    return _elm_widget_item_translatable_part_text_get((Elm_Widget_Item *)it, part);
1470 }
1471
1472 EAPI void
1473 elm_object_item_domain_part_text_translatable_set(Elm_Object_Item *it, const char *part, const char *domain, Eina_Bool translatable)
1474 {
1475    _elm_widget_item_domain_part_text_translatable_set((Elm_Widget_Item *)it, part, domain, translatable);
1476 }
1477
1478 EAPI void
1479 elm_object_access_info_set(Evas_Object *obj, const char *txt)
1480 {
1481    elm_widget_access_info_set(obj, txt);
1482 }
1483
1484 EAPI Evas_Object *
1485 elm_object_name_find(const Evas_Object *obj, const char *name, int recurse)
1486 {
1487    return elm_widget_name_find(obj, name, recurse);
1488 }
1489
1490 EAPI void
1491 elm_object_orientation_mode_disabled_set(Evas_Object *obj, Eina_Bool disabled)
1492 {
1493    elm_widget_orientation_mode_disabled_set(obj, disabled);
1494 }
1495
1496 EAPI Eina_Bool
1497 elm_object_orientation_mode_disabled_get(const Evas_Object *obj)
1498 {
1499    return elm_widget_orientation_mode_disabled_get(obj);
1500 }
1501
1502 EAPI void
1503 elm_object_item_access_info_set(Elm_Object_Item *it, const char *txt)
1504 {
1505    _elm_widget_item_access_info_set((Elm_Widget_Item *)it, txt);
1506 }
1507
1508 EAPI Evas_Object *
1509 elm_object_item_part_access_register(Elm_Object_Item *item, const char *part)
1510 {
1511    EINA_SAFETY_ON_NULL_RETURN_VAL(item, NULL);
1512    EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
1513
1514    Elm_Widget_Item *it = (Elm_Widget_Item *)item;
1515    Evas_Object *edj;
1516    Evas_Object *parent;
1517
1518    const char *type = elm_widget_type_get(VIEW(item));
1519
1520    if (type && !strcmp(type, "elm_layout"))
1521      {
1522         edj = elm_layout_edje_get(VIEW(item));
1523         parent = VIEW(item);
1524      }
1525    else
1526      {
1527         edj = VIEW(item);
1528         parent = WIDGET(item);
1529      }
1530
1531    elm_object_item_access_unregister(item);
1532    it->access_obj =
1533       _elm_access_edje_object_part_object_register(parent, edj, part);
1534    return it->access_obj;
1535 }
1536
1537 EAPI Evas_Object *
1538 elm_object_item_access_register(Elm_Object_Item *item)
1539 {
1540    Elm_Widget_Item *it;
1541
1542    it = (Elm_Widget_Item *)item;
1543
1544    _elm_access_widget_item_register(it);
1545
1546    if (it) return it->access_obj;
1547    return NULL;
1548 }
1549
1550 EAPI void
1551 elm_object_item_access_unregister(Elm_Object_Item *item)
1552 {
1553    _elm_access_widget_item_unregister((Elm_Widget_Item *)item);
1554 }
1555
1556 EAPI Evas_Object *
1557 elm_object_item_access_object_get(const Elm_Object_Item *item)
1558 {
1559    if (!item) return NULL;
1560    return ((Elm_Widget_Item *)item)->access_obj;
1561 }
1562
1563 EAPI void
1564 elm_object_item_access_order_set(Elm_Object_Item *item, Eina_List *objs)
1565 {
1566    _elm_access_widget_item_access_order_set((Elm_Widget_Item *)item, objs);
1567 }
1568
1569 EAPI const Eina_List *
1570 elm_object_item_access_order_get(const Elm_Object_Item *item)
1571 {
1572    return _elm_access_widget_item_access_order_get((Elm_Widget_Item *)item);
1573 }
1574
1575 EAPI void
1576 elm_object_item_access_order_unset(Elm_Object_Item *item)
1577 {
1578    _elm_access_widget_item_access_order_unset((Elm_Widget_Item *)item);
1579 }
1580
1581 EAPI void *
1582 elm_object_item_data_get(const Elm_Object_Item *it)
1583 {
1584    return elm_widget_item_data_get(it);
1585 }
1586
1587 EAPI void
1588 elm_object_item_data_set(Elm_Object_Item *it, void *data)
1589 {
1590    elm_widget_item_data_set(it, data);
1591 }
1592
1593 EAPI void
1594 elm_object_item_signal_emit(Elm_Object_Item *it, const char *emission, const char *source)
1595 {
1596    _elm_widget_item_signal_emit((Elm_Widget_Item *)it, emission, source);
1597 }
1598
1599 EAPI void
1600 elm_object_item_signal_callback_add(Elm_Object_Item *it, const char *emission, const char *source, Elm_Object_Item_Signal_Cb func, void *data)
1601 {
1602    _elm_widget_item_signal_callback_add((Elm_Widget_Item *)it, emission, source, (Elm_Widget_Item_Signal_Cb) func, data);
1603 }
1604
1605 EAPI void *
1606 elm_object_item_signal_callback_del(Elm_Object_Item *it, const char *emission, const char *source, Elm_Object_Item_Signal_Cb func)
1607 {
1608    return _elm_widget_item_signal_callback_del((Elm_Widget_Item *)it, emission, source, (Elm_Widget_Item_Signal_Cb) func);
1609 }
1610
1611 EAPI void elm_object_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
1612 {
1613    _elm_widget_item_disabled_set((Elm_Widget_Item *)it, disabled);
1614 }
1615
1616 EAPI Eina_Bool elm_object_item_disabled_get(const Elm_Object_Item *it)
1617 {
1618    return _elm_widget_item_disabled_get((Elm_Widget_Item *)it);
1619 }
1620
1621 EAPI void elm_object_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb del_cb)
1622 {
1623    _elm_widget_item_del_cb_set((Elm_Widget_Item *)it, del_cb);
1624 }
1625
1626 EAPI void elm_object_item_del(Elm_Object_Item *it)
1627 {
1628    _elm_widget_item_del((Elm_Widget_Item *)it);
1629 }
1630
1631 EAPI void
1632 elm_object_item_tooltip_text_set(Elm_Object_Item *it, const char *text)
1633 {
1634    elm_widget_item_tooltip_text_set(it, text);
1635 }
1636
1637 EAPI void
1638 elm_object_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
1639 {
1640    elm_widget_item_tooltip_content_cb_set(it, func, data, del_cb);
1641 }
1642
1643 EAPI void
1644 elm_object_item_tooltip_unset(Elm_Object_Item *it)
1645 {
1646    elm_widget_item_tooltip_unset(it);
1647 }
1648
1649 EAPI Eina_Bool
1650 elm_object_item_tooltip_window_mode_set(Elm_Object_Item *it, Eina_Bool disable)
1651 {
1652    return elm_widget_item_tooltip_window_mode_set(it, disable);
1653 }
1654
1655 EAPI Eina_Bool
1656 elm_object_item_tooltip_window_mode_get(const Elm_Object_Item *it)
1657 {
1658    return elm_widget_item_tooltip_window_mode_get(it);
1659 }
1660
1661 EAPI void
1662 elm_object_item_tooltip_style_set(Elm_Object_Item *it, const char *style)
1663 {
1664    elm_widget_item_tooltip_style_set(it, style);
1665 }
1666
1667 EAPI const char *
1668 elm_object_item_tooltip_style_get(const Elm_Object_Item *it)
1669 {
1670    return elm_widget_item_tooltip_style_get(it);
1671 }
1672
1673 EAPI void
1674 elm_object_item_cursor_set(Elm_Object_Item *it, const char *cursor)
1675 {
1676    elm_widget_item_cursor_set(it, cursor);
1677 }
1678
1679 EAPI const char *
1680 elm_object_item_cursor_get(const Elm_Object_Item *it)
1681 {
1682    return elm_widget_item_cursor_get(it);
1683 }
1684
1685 EAPI void
1686 elm_object_item_cursor_unset(Elm_Object_Item *it)
1687 {
1688    elm_widget_item_cursor_unset(it);
1689 }
1690
1691 EAPI void
1692 elm_object_item_cursor_style_set(Elm_Object_Item *it, const char *style)
1693 {
1694    elm_widget_item_cursor_style_set(it, style);
1695 }
1696
1697 EAPI const char *
1698 elm_object_item_cursor_style_get(const Elm_Object_Item *it)
1699 {
1700    return elm_widget_item_cursor_style_get(it);
1701 }
1702
1703 EAPI void
1704 elm_object_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only)
1705 {
1706    elm_widget_item_cursor_engine_only_set(it, engine_only);
1707 }
1708
1709 EAPI Eina_Bool
1710 elm_object_item_cursor_engine_only_get(const Elm_Object_Item *it)
1711 {
1712    return elm_widget_item_cursor_engine_only_get(it);
1713 }