Get us some nice auto translation scheme
[framework/uifw/elementary.git] / 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 #include <Elementary.h>
18 #include "elm_priv.h"
19
20 #define SEMI_BROKEN_QUICKLAUNCH 1
21
22 static Elm_Version _version = { VMAJ, VMIN, VMIC, VREV };
23 EAPI Elm_Version *elm_version = &_version;
24
25 Eina_Bool
26 _elm_dangerous_call_check(const char *call)
27 {
28    char buf[256];
29    const char *eval;
30
31    snprintf(buf, sizeof(buf), "%i.%i.%i.%i", VMAJ, VMIN, VMIC, VREV);
32    eval = getenv("ELM_NO_FINGER_WAGGLING");
33    if ((eval) && (!strcmp(eval, buf)))
34      return 0;
35    printf("ELEMENTARY FINGER WAGGLE!!!!!!!!!!\n"
36           "\n"
37           "  %s() used.\n"
38           "PLEASE see the API documentation for this function. This call\n"
39           "should almost never be used. Only in very special cases.\n"
40           "\n"
41           "To remove this warning please set the environment variable:\n"
42           "  ELM_NO_FINGER_WAGGLING\n"
43           "To the value of the Elementary version + revision number. e.g.:\n"
44           "  1.2.5.40295\n"
45           "\n"
46           ,
47           call);
48    return 1;
49 }
50
51 static Eina_Bool _elm_signal_exit(void *data,
52                                   int   ev_type,
53                                   void *ev);
54
55 static Eina_Prefix *pfx = NULL;
56 char *_elm_appname = NULL;
57 const char *_elm_data_dir = NULL;
58 const char *_elm_lib_dir = NULL;
59 int _elm_log_dom = -1;
60
61 EAPI int ELM_EVENT_POLICY_CHANGED = 0;
62
63 static int _elm_init_count = 0;
64 static int _elm_sub_init_count = 0;
65 static int _elm_ql_init_count = 0;
66 static int _elm_policies[ELM_POLICY_LAST];
67 static Ecore_Event_Handler *_elm_exit_handler = NULL;
68 static Eina_Bool quicklaunch_on = 0;
69
70 static Eina_Bool
71 _elm_signal_exit(void *data  __UNUSED__,
72                  int ev_type __UNUSED__,
73                  void *ev    __UNUSED__)
74 {
75    elm_exit();
76    return ECORE_CALLBACK_PASS_ON;
77 }
78
79 void
80 _elm_rescale(void)
81 {
82    edje_scale_set(_elm_config->scale);
83    _elm_win_rescale(NULL, EINA_FALSE);
84    _elm_ews_wm_rescale(NULL, EINA_FALSE);
85 }
86
87 static void *app_mainfunc = NULL;
88 static const char *app_domain = NULL;
89 static const char *app_checkfile = NULL;
90
91 static const char *app_compile_bin_dir = NULL;
92 static const char *app_compile_lib_dir = NULL;
93 static const char *app_compile_data_dir = NULL;
94 static const char *app_compile_locale_dir = NULL;
95 static const char *app_prefix_dir = NULL;
96 static const char *app_bin_dir = NULL;
97 static const char *app_lib_dir = NULL;
98 static const char *app_data_dir = NULL;
99 static const char *app_locale_dir = NULL;
100
101 static Eina_Prefix *app_pfx = NULL;
102
103 static void
104 _prefix_check(void)
105 {
106    int argc = 0;
107    char **argv = NULL;
108    const char *dirs[4] = { NULL, NULL, NULL, NULL };
109    char *caps = NULL, *p1, *p2;
110
111    if (app_pfx) return;
112    if (!app_domain) return;
113
114    ecore_app_args_get(&argc, &argv);
115    if (argc < 1) return;
116
117    dirs[0] = app_compile_bin_dir;
118    dirs[1] = app_compile_lib_dir;
119    dirs[2] = app_compile_data_dir;
120    dirs[3] = app_compile_locale_dir;
121
122    if (!dirs[1]) dirs[1] = dirs[0];
123    if (!dirs[0]) dirs[0] = dirs[1];
124    if (!dirs[3]) dirs[3] = dirs[2];
125    if (!dirs[2]) dirs[2] = dirs[3];
126
127    if (app_domain)
128      {
129         caps = alloca(strlen(app_domain) + 1);
130         for (p1 = (char *)app_domain, p2 = caps; *p1; p1++, p2++)
131            *p2 = toupper(*p1);
132         *p2 = 0;
133      }
134    app_pfx = eina_prefix_new(argv[0], app_mainfunc, caps, app_domain,
135                              app_checkfile, dirs[0], dirs[1], dirs[2], dirs[3]);
136 }
137
138 static void
139 _prefix_shutdown(void)
140 {
141    if (app_pfx) eina_prefix_free(app_pfx);
142    if (app_domain) eina_stringshare_del(app_domain);
143    if (app_checkfile) eina_stringshare_del(app_checkfile);
144    if (app_compile_bin_dir) eina_stringshare_del(app_compile_bin_dir);
145    if (app_compile_lib_dir) eina_stringshare_del(app_compile_lib_dir);
146    if (app_compile_data_dir) eina_stringshare_del(app_compile_data_dir);
147    if (app_compile_locale_dir) eina_stringshare_del(app_compile_locale_dir);
148    if (app_prefix_dir) eina_stringshare_del(app_prefix_dir);
149    if (app_bin_dir) eina_stringshare_del(app_bin_dir);
150    if (app_lib_dir) eina_stringshare_del(app_lib_dir);
151    if (app_data_dir) eina_stringshare_del(app_data_dir);
152    if (app_locale_dir) eina_stringshare_del(app_locale_dir);
153    app_mainfunc = NULL;
154    app_domain = NULL;
155    app_checkfile = NULL;
156    app_compile_bin_dir = NULL;
157    app_compile_lib_dir = NULL;
158    app_compile_data_dir = NULL;
159    app_compile_locale_dir = NULL;
160    app_prefix_dir = NULL;
161    app_bin_dir = NULL;
162    app_lib_dir = NULL;
163    app_data_dir = NULL;
164    app_locale_dir = NULL;
165    app_pfx = NULL;
166 }
167
168 EAPI int
169 elm_init(int    argc,
170          char **argv)
171 {
172    _elm_init_count++;
173    if (_elm_init_count > 1) return _elm_init_count;
174    elm_quicklaunch_init(argc, argv);
175    elm_quicklaunch_sub_init(argc, argv);
176    _prefix_shutdown();
177    return _elm_init_count;
178 }
179
180 EAPI int
181 elm_shutdown(void)
182 {
183    _elm_init_count--;
184    if (_elm_init_count > 0) return _elm_init_count;
185    _elm_win_shutdown();
186    while (_elm_win_deferred_free) ecore_main_loop_iterate();
187 // wrningz :(
188 //   _prefix_shutdown();
189    elm_quicklaunch_sub_shutdown();
190    elm_quicklaunch_shutdown();
191    return _elm_init_count;
192 }
193
194 EAPI void
195 elm_app_info_set(void *mainfunc, const char *dom, const char *checkfile)
196 {
197    app_mainfunc = mainfunc;
198    eina_stringshare_replace(&app_domain, dom);
199    eina_stringshare_replace(&app_checkfile, checkfile);
200 }
201
202 EAPI void
203 elm_app_compile_bin_dir_set(const char *dir)
204 {
205    eina_stringshare_replace(&app_compile_bin_dir, dir);
206 }
207
208 EAPI void
209 elm_app_compile_lib_dir_set(const char *dir)
210 {
211    eina_stringshare_replace(&app_compile_lib_dir, dir);
212 }
213
214 EAPI void
215 elm_app_compile_data_dir_set(const char *dir)
216 {
217    eina_stringshare_replace(&app_compile_data_dir, dir);
218 }
219
220 EAPI void
221 elm_app_compile_locale_set(const char *dir)
222 {
223    eina_stringshare_replace(&app_compile_locale_dir, dir);
224 }
225
226 EAPI const char *
227 elm_app_prefix_dir_get(void)
228 {
229    if (app_prefix_dir) return app_prefix_dir;
230    _prefix_check();
231   if (!app_pfx) return "";
232    app_prefix_dir = eina_prefix_get(app_pfx);
233    return app_prefix_dir;
234 }
235
236 EAPI const char *
237 elm_app_bin_dir_get(void)
238 {
239    if (app_bin_dir) return app_bin_dir;
240    _prefix_check();
241    if (!app_pfx) return "";
242    app_bin_dir = eina_prefix_bin_get(app_pfx);
243    return app_bin_dir;
244 }
245
246 EAPI const char *
247 elm_app_lib_dir_get(void)
248 {
249    if (app_lib_dir) return app_lib_dir;
250    _prefix_check();
251    if (!app_pfx) return "";
252    app_lib_dir = eina_prefix_lib_get(app_pfx);
253    return app_lib_dir;
254 }
255
256 EAPI const char *
257 elm_app_data_dir_get(void)
258 {
259    if (app_data_dir) return app_data_dir;
260    _prefix_check();
261    if (!app_pfx) return "";
262    app_data_dir = eina_prefix_data_get(app_pfx);
263    return app_data_dir;
264 }
265
266 EAPI const char *
267 elm_app_locale_dir_get(void)
268 {
269    if (app_locale_dir) return app_locale_dir;
270    _prefix_check();
271    if (!app_pfx) return "";
272    app_locale_dir = eina_prefix_locale_get(app_pfx);
273    return app_locale_dir;
274 }
275
276 #ifdef ELM_EDBUS
277 static int _elm_need_e_dbus = 0;
278 #endif
279 EAPI Eina_Bool
280 elm_need_e_dbus(void)
281 {
282 #ifdef ELM_EDBUS
283    if (_elm_need_e_dbus++) return EINA_TRUE;
284    e_dbus_init();
285    return EINA_TRUE;
286 #else
287    return EINA_FALSE;
288 #endif
289 }
290
291 static void
292 _elm_unneed_e_dbus(void)
293 {
294 #ifdef ELM_EDBUS
295    if (--_elm_need_e_dbus) return;
296
297    _elm_need_e_dbus = 0;
298    e_dbus_shutdown();
299 #endif
300 }
301
302 #ifdef ELM_EFREET
303 static int _elm_need_efreet = 0;
304 #endif
305 EAPI Eina_Bool
306 elm_need_efreet(void)
307 {
308 #ifdef ELM_EFREET
309    if (_elm_need_efreet++) return EINA_TRUE;
310    efreet_init();
311    efreet_mime_init();
312    efreet_trash_init();
313     /*
314      {
315         Eina_List **list;
316
317         list = efreet_icon_extra_list_get();
318         if (list)
319           {
320              e_user_dir_concat_static(buf, "icons");
321              *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
322              e_prefix_data_concat_static(buf, "data/icons");
323              *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
324           }
325      }
326    */
327    return EINA_TRUE;
328 #else
329    return EINA_FALSE;
330 #endif
331 }
332
333 static void
334 _elm_unneed_efreet(void)
335 {
336 #ifdef ELM_EFREET
337    if (--_elm_need_efreet) return;
338
339    _elm_need_efreet = 0;
340    efreet_trash_shutdown();
341    efreet_mime_shutdown();
342    efreet_shutdown();
343 #endif
344 }
345
346 EAPI void
347 elm_quicklaunch_mode_set(Eina_Bool ql_on)
348 {
349    quicklaunch_on = ql_on;
350 }
351
352 EAPI Eina_Bool
353 elm_quicklaunch_mode_get(void)
354 {
355    return quicklaunch_on;
356 }
357
358 EAPI int
359 elm_quicklaunch_init(int    argc,
360                      char **argv)
361 {
362    _elm_ql_init_count++;
363    if (_elm_ql_init_count > 1) return _elm_ql_init_count;
364    eina_init();
365    _elm_log_dom = eina_log_domain_register("elementary", EINA_COLOR_LIGHTBLUE);
366    if (!_elm_log_dom)
367      {
368         EINA_LOG_ERR("could not register elementary log domain.");
369         _elm_log_dom = EINA_LOG_DOMAIN_GLOBAL;
370      }
371
372    eet_init();
373    ecore_init();
374
375 #ifdef HAVE_ELEMENTARY_EMAP
376    emap_init();
377 #endif
378    ecore_app_args_set(argc, (const char **)argv);
379
380    memset(_elm_policies, 0, sizeof(_elm_policies));
381    if (!ELM_EVENT_POLICY_CHANGED)
382      ELM_EVENT_POLICY_CHANGED = ecore_event_type_new();
383
384    ecore_file_init();
385
386    _elm_exit_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, NULL);
387
388    if (argv) _elm_appname = strdup(ecore_file_file_get(argv[0]));
389
390    pfx = eina_prefix_new(argv[0], elm_quicklaunch_init,
391                          "ELM", "elementary", "config/profile.cfg",
392                          PACKAGE_LIB_DIR, /* don't have a bin dir currently */
393                          PACKAGE_LIB_DIR,
394                          PACKAGE_DATA_DIR,
395                          LOCALE_DIR);
396    if (pfx)
397      {
398         _elm_data_dir = eina_stringshare_add(eina_prefix_data_get(pfx));
399         _elm_lib_dir = eina_stringshare_add(eina_prefix_lib_get(pfx));
400      }
401    if (!_elm_data_dir) _elm_data_dir = eina_stringshare_add("/");
402    if (!_elm_lib_dir) _elm_lib_dir = eina_stringshare_add("/");
403
404    _elm_config_init();
405    return _elm_ql_init_count;
406 }
407
408 EAPI int
409 elm_quicklaunch_sub_init(int    argc,
410                          char **argv)
411 {
412    _elm_sub_init_count++;
413    if (_elm_sub_init_count > 1) return _elm_sub_init_count;
414    if (quicklaunch_on)
415      {
416 #ifdef SEMI_BROKEN_QUICKLAUNCH
417         return _elm_sub_init_count;
418 #endif
419      }
420    if (!quicklaunch_on)
421      {
422         ecore_app_args_set(argc, (const char **)argv);
423         evas_init();
424         edje_init();
425         _elm_module_init();
426         _elm_config_sub_init();
427         ecore_evas_init(); // FIXME: check errors
428         ecore_imf_init();
429         ecore_con_init();
430         ecore_con_url_init();
431         _elm_ews_wm_init();
432      }
433    return _elm_sub_init_count;
434 }
435
436 EAPI int
437 elm_quicklaunch_sub_shutdown(void)
438 {
439    _elm_sub_init_count--;
440    if (_elm_sub_init_count > 0) return _elm_sub_init_count;
441    if (quicklaunch_on)
442      {
443 #ifdef SEMI_BROKEN_QUICKLAUNCH
444         return _elm_sub_init_count;
445 #endif
446      }
447    if (!quicklaunch_on)
448      {
449         _elm_win_shutdown();
450         _elm_module_shutdown();
451         _elm_ews_wm_shutdown();
452         ecore_con_url_shutdown();
453         ecore_con_shutdown();
454         ecore_imf_shutdown();
455         ecore_evas_shutdown();
456         _elm_config_sub_shutdown();
457 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
458         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
459             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
460             ENGINE_COMPARE(ELM_XRENDER_X11) ||
461             ENGINE_COMPARE(ELM_OPENGL_X11) ||
462             ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
463             ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
464             ENGINE_COMPARE(ELM_OPENGL_SDL) ||
465             ENGINE_COMPARE(ELM_SOFTWARE_WIN32) ||
466             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
467             ENGINE_COMPARE(ELM_EWS))
468 #undef ENGINE_COMPARE
469           evas_cserve_disconnect();
470         edje_shutdown();
471         evas_shutdown();
472      }
473    return _elm_sub_init_count;
474 }
475
476 EAPI int
477 elm_quicklaunch_shutdown(void)
478 {
479    _elm_ql_init_count--;
480    if (_elm_ql_init_count > 0) return _elm_ql_init_count;
481    if (pfx) eina_prefix_free(pfx);
482    pfx = NULL;
483    eina_stringshare_del(_elm_data_dir);
484    _elm_data_dir = NULL;
485    eina_stringshare_del(_elm_lib_dir);
486    _elm_lib_dir = NULL;
487
488    free(_elm_appname);
489    _elm_appname = NULL;
490
491    _elm_config_shutdown();
492
493    ecore_event_handler_del(_elm_exit_handler);
494    _elm_exit_handler = NULL;
495
496    _elm_theme_shutdown();
497    _elm_unneed_efreet();
498    _elm_unneed_e_dbus();
499    _elm_unneed_ethumb();
500    _elm_unneed_web();
501    ecore_file_shutdown();
502
503 #ifdef HAVE_ELEMENTARY_EMAP
504    emap_shutdown();
505 #endif
506
507    ecore_shutdown();
508    eet_shutdown();
509
510    if ((_elm_log_dom > -1) && (_elm_log_dom != EINA_LOG_DOMAIN_GLOBAL))
511      {
512         eina_log_domain_unregister(_elm_log_dom);
513         _elm_log_dom = -1;
514      }
515
516    _elm_widget_type_clear();
517
518    eina_shutdown();
519    return _elm_ql_init_count;
520 }
521
522 EAPI void
523 elm_quicklaunch_seed(void)
524 {
525 #ifndef SEMI_BROKEN_QUICKLAUNCH
526    if (quicklaunch_on)
527      {
528         Evas_Object *win, *bg, *bt;
529
530         win = elm_win_add(NULL, "seed", ELM_WIN_BASIC);
531         bg = elm_bg_add(win);
532         elm_win_resize_object_add(win, bg);
533         evas_object_show(bg);
534         bt = elm_button_add(win);
535         elm_button_label_set(bt, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~-_=+\\|]}[{;:'\",<.>/?");
536         elm_win_resize_object_add(win, bt);
537         ecore_main_loop_iterate();
538         evas_object_del(win);
539         ecore_main_loop_iterate();
540 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
541         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
542             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
543             ENGINE_COMPARE(ELM_XRENDER_X11) ||
544             ENGINE_COMPARE(ELM_OPENGL_X11))
545 #undef ENGINE_COMPARE
546           {
547 # ifdef HAVE_ELEMENTARY_X
548              ecore_x_sync();
549 # endif
550           }
551         ecore_main_loop_iterate();
552      }
553 #endif
554 }
555
556 static void *qr_handle = NULL;
557 static int (*qr_main)(int    argc,
558                       char **argv) = NULL;
559
560 EAPI Eina_Bool
561 elm_quicklaunch_prepare(int argc __UNUSED__,
562                         char   **argv)
563 {
564 #ifdef HAVE_FORK
565    char *exe = elm_quicklaunch_exe_path_get(argv[0]);
566    if (!exe)
567      {
568         ERR("requested quicklaunch binary '%s' does not exist\n", argv[0]);
569         return EINA_FALSE;
570      }
571    else
572      {
573         char *exe2, *p;
574         char *exename;
575
576         exe2 = malloc(strlen(exe) + 1 + 10);
577         strcpy(exe2, exe);
578         p = strrchr(exe2, '/');
579         if (p) p++;
580         else p = exe2;
581         exename = alloca(strlen(p) + 1);
582         strcpy(exename, p);
583         *p = 0;
584         strcat(p, "../lib/");
585         strcat(p, exename);
586         strcat(p, ".so");
587         if (!access(exe2, R_OK | X_OK))
588           {
589              free(exe);
590              exe = exe2;
591           }
592         else
593           free(exe2);
594      }
595    qr_handle = dlopen(exe, RTLD_NOW | RTLD_GLOBAL);
596    if (!qr_handle)
597      {
598         fprintf(stderr, "dlerr: %s\n", dlerror());
599         WRN("dlopen('%s') failed: %s", exe, dlerror());
600         free(exe);
601         return EINA_FALSE;
602      }
603    INF("dlopen('%s') = %p", exe, qr_handle);
604    qr_main = dlsym(qr_handle, "elm_main");
605    INF("dlsym(%p, 'elm_main') = %p", qr_handle, qr_main);
606    if (!qr_main)
607      {
608         WRN("not quicklauncher capable: no elm_main in '%s'", exe);
609         dlclose(qr_handle);
610         qr_handle = NULL;
611         free(exe);
612         return EINA_FALSE;
613      }
614    free(exe);
615    return EINA_TRUE;
616 #else
617    return EINA_FALSE;
618    (void)argv;
619 #endif
620 }
621
622 #ifdef HAVE_FORK
623 static void
624 save_env(void)
625 {
626    int i, size;
627    extern char **environ;
628    char **oldenv, **p;
629
630    oldenv = environ;
631
632    for (i = 0, size = 0; environ[i]; i++)
633      size += strlen(environ[i]) + 1;
634
635    p = malloc((i + 1) * sizeof(char *));
636    if (!p) return;
637
638    environ = p;
639
640    for (i = 0; oldenv[i]; i++)
641      environ[i] = strdup(oldenv[i]);
642    environ[i] = NULL;
643 }
644
645 #endif
646
647 EAPI Eina_Bool
648 elm_quicklaunch_fork(int    argc,
649                      char **argv,
650                      char  *cwd,
651                      void (postfork_func) (void *data),
652                      void  *postfork_data)
653 {
654 #ifdef HAVE_FORK
655    pid_t child;
656    int ret;
657    int real_argc;
658    char **real_argv;
659
660    // FIXME:
661    // need to accept current environment from elementary_run
662    if (!qr_main)
663      {
664         int i;
665         char **args;
666
667         child = fork();
668         if (child > 0) return EINA_TRUE;
669         else if (child < 0)
670           {
671              perror("could not fork");
672              return EINA_FALSE;
673           }
674         setsid();
675         if (chdir(cwd) != 0)
676           perror("could not chdir");
677         args = alloca((argc + 1) * sizeof(char *));
678         for (i = 0; i < argc; i++) args[i] = argv[i];
679         args[argc] = NULL;
680         WRN("%s not quicklaunch capable, fallback...", argv[0]);
681         execvp(argv[0], args);
682         ERR("failed to execute '%s': %s", argv[0], strerror(errno));
683         exit(-1);
684      }
685    child = fork();
686    if (child > 0) return EINA_TRUE;
687    else if (child < 0)
688      {
689         perror("could not fork");
690         return EINA_FALSE;
691      }
692    if (postfork_func) postfork_func(postfork_data);
693
694    if (quicklaunch_on)
695      {
696 #ifdef SEMI_BROKEN_QUICKLAUNCH
697         ecore_app_args_set(argc, (const char **)argv);
698         evas_init();
699         edje_init();
700         _elm_config_sub_init();
701 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
702         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
703             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
704             ENGINE_COMPARE(ELM_XRENDER_X11) ||
705             ENGINE_COMPARE(ELM_OPENGL_X11))
706 #undef ENGINE_COMPARE
707           {
708 # ifdef HAVE_ELEMENTARY_X
709              ecore_x_init(NULL);
710 # endif
711           }
712         ecore_evas_init(); // FIXME: check errors
713         ecore_imf_init();
714         _elm_module_init();
715 #endif
716      }
717
718    setsid();
719    if (chdir(cwd) != 0)
720      perror("could not chdir");
721    // FIXME: this is very linux specific. it changes argv[0] of the process
722    // so ps etc. report what you'd expect. for other unixes and os's this
723    // may just not work
724    save_env();
725    if (argv)
726      {
727         char *lastarg, *p;
728
729         ecore_app_args_get(&real_argc, &real_argv);
730         lastarg = real_argv[real_argc - 1] + strlen(real_argv[real_argc - 1]);
731         for (p = real_argv[0]; p < lastarg; p++) *p = 0;
732         strcpy(real_argv[0], argv[0]);
733      }
734    ecore_app_args_set(argc, (const char **)argv);
735    ret = qr_main(argc, argv);
736    exit(ret);
737    return EINA_TRUE;
738 #else
739    return EINA_FALSE;
740    (void)argc;
741    (void)argv;
742    (void)cwd;
743    (void)postfork_func;
744    (void)postfork_data;
745 #endif
746 }
747
748 EAPI void
749 elm_quicklaunch_cleanup(void)
750 {
751 #ifdef HAVE_FORK
752    if (qr_handle)
753      {
754         dlclose(qr_handle);
755         qr_handle = NULL;
756         qr_main = NULL;
757      }
758 #endif
759 }
760
761 EAPI int
762 elm_quicklaunch_fallback(int    argc,
763                          char **argv)
764 {
765    int ret;
766    elm_quicklaunch_init(argc, argv);
767    elm_quicklaunch_sub_init(argc, argv);
768    elm_quicklaunch_prepare(argc, argv);
769    ret = qr_main(argc, argv);
770    exit(ret);
771    return ret;
772 }
773
774 EAPI char *
775 elm_quicklaunch_exe_path_get(const char *exe)
776 {
777    static char *path = NULL;
778    static Eina_List *pathlist = NULL;
779    const char *pathitr;
780    const Eina_List *l;
781    char buf[PATH_MAX];
782    if (exe[0] == '/') return strdup(exe);
783    if ((exe[0] == '.') && (exe[1] == '/')) return strdup(exe);
784    if ((exe[0] == '.') && (exe[1] == '.') && (exe[2] == '/')) return strdup(exe);
785    if (!path)
786      {
787         const char *p, *pp;
788         char *buf2;
789         path = getenv("PATH");
790         buf2 = alloca(strlen(path) + 1);
791         p = path;
792         pp = p;
793         for (;; )
794           {
795              if ((*p == ':') || (!*p))
796                {
797                   int len;
798
799                   len = p - pp;
800                   strncpy(buf2, pp, len);
801                   buf2[len] = 0;
802                   pathlist = eina_list_append(pathlist, eina_stringshare_add(buf2));
803                   if (!*p) break;
804                   p++;
805                   pp = p;
806                }
807              else
808                {
809                   if (!*p) break;
810                   p++;
811                }
812           }
813      }
814    EINA_LIST_FOREACH(pathlist, l, pathitr)
815      {
816         snprintf(buf, sizeof(buf), "%s/%s", pathitr, exe);
817         if (!access(buf, R_OK | X_OK)) return strdup(buf);
818      }
819    return NULL;
820 }
821
822 EAPI void
823 elm_run(void)
824 {
825    ecore_main_loop_begin();
826 }
827
828 EAPI void
829 elm_exit(void)
830 {
831    ecore_main_loop_quit();
832 }
833
834 EAPI Eina_Bool
835 elm_policy_set(unsigned int policy,
836                int          value)
837 {
838    Elm_Event_Policy_Changed *ev;
839
840    if (policy >= ELM_POLICY_LAST)
841      return EINA_FALSE;
842
843    if (value == _elm_policies[policy])
844      return EINA_TRUE;
845
846    /* TODO: validade policy? */
847
848    ev = malloc(sizeof(*ev));
849    ev->policy = policy;
850    ev->new_value = value;
851    ev->old_value = _elm_policies[policy];
852
853    _elm_policies[policy] = value;
854
855    ecore_event_add(ELM_EVENT_POLICY_CHANGED, ev, NULL, NULL);
856
857    return EINA_TRUE;
858 }
859
860 EAPI int
861 elm_policy_get(unsigned int policy)
862 {
863    if (policy >= ELM_POLICY_LAST)
864      return 0;
865    return _elm_policies[policy];
866 }
867
868 EAPI void
869 elm_language_set(const char *lang)
870 {
871    setlocale(LC_ALL, lang);
872    _elm_win_translate();
873 }
874
875 EAPI Eina_Bool
876 elm_object_mirrored_get(const Evas_Object *obj)
877 {
878    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
879    return elm_widget_mirrored_get(obj);
880 }
881
882 EAPI void
883 elm_object_mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
884 {
885    EINA_SAFETY_ON_NULL_RETURN(obj);
886    elm_widget_mirrored_set(obj, mirrored);
887 }
888
889 EAPI Eina_Bool
890 elm_object_mirrored_automatic_get(const Evas_Object *obj)
891 {
892    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
893    return elm_widget_mirrored_automatic_get(obj);
894 }
895
896 EAPI void
897 elm_object_mirrored_automatic_set(Evas_Object *obj, Eina_Bool automatic)
898 {
899    EINA_SAFETY_ON_NULL_RETURN(obj);
900    elm_widget_mirrored_automatic_set(obj, automatic);
901 }
902
903 /**
904  * @}
905  */
906
907 EAPI void
908 elm_object_scale_set(Evas_Object *obj,
909                      double       scale)
910 {
911    EINA_SAFETY_ON_NULL_RETURN(obj);
912    elm_widget_scale_set(obj, scale);
913 }
914
915 EAPI double
916 elm_object_scale_get(const Evas_Object *obj)
917 {
918    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0.0);
919    return elm_widget_scale_get(obj);
920 }
921
922 EAPI void
923 elm_object_text_part_set(Evas_Object *obj, const char *part, const char *label)
924 {
925    EINA_SAFETY_ON_NULL_RETURN(obj);
926    elm_widget_text_part_set(obj, part, label);
927 }
928
929 EAPI const char *
930 elm_object_text_part_get(const Evas_Object *obj, const char *part)
931 {
932    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
933    return elm_widget_text_part_get(obj, part);
934 }
935
936 EAPI void
937 elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text)
938 {
939    EINA_SAFETY_ON_NULL_RETURN(obj);
940    elm_widget_domain_translatable_text_part_set(obj, part, domain, text);
941 }
942
943 EAPI const char *
944 elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part)
945 {
946    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
947    return elm_widget_translatable_text_part_get(obj, part);
948 }
949
950 EAPI void
951 elm_object_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
952 {
953    EINA_SAFETY_ON_NULL_RETURN(obj);
954    elm_widget_content_part_set(obj, part, content);
955 }
956
957 EAPI Evas_Object *
958 elm_object_content_part_get(const Evas_Object *obj, const char *part)
959 {
960    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
961    return elm_widget_content_part_get(obj, part);
962 }
963
964 EAPI Evas_Object *
965 elm_object_content_part_unset(Evas_Object *obj, const char *part)
966 {
967    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
968    return elm_widget_content_part_unset(obj, part);
969 }
970
971 EAPI double
972 elm_scale_get(void)
973 {
974    return _elm_config->scale;
975 }
976
977 EAPI void
978 elm_scale_set(double scale)
979 {
980    if (_elm_config->scale == scale) return;
981    _elm_config->scale = scale;
982    _elm_rescale();
983 }
984
985 EAPI void
986 elm_scale_all_set(double scale)
987 {
988    elm_scale_set(scale);
989    _elm_config_all_update();
990 }
991
992 EAPI Eina_Bool
993 elm_password_show_last_get(void)
994 {
995    return _elm_config->password_show_last;
996 }
997
998 EAPI void
999 elm_password_show_last_set(Eina_Bool password_show_last)
1000 {
1001    if (_elm_config->password_show_last == password_show_last) return;
1002    _elm_config->password_show_last = password_show_last;
1003    edje_password_show_last_set(_elm_config->password_show_last);
1004 }
1005
1006 EAPI double
1007 elm_password_show_last_timeout_get(void)
1008 {
1009    return _elm_config->password_show_last_timeout;
1010 }
1011
1012 EAPI void
1013 elm_password_show_last_timeout_set(double password_show_last_timeout)
1014 {
1015    if (_elm_config->password_show_last_timeout == password_show_last_timeout) return;
1016    _elm_config->password_show_last_timeout = password_show_last_timeout;
1017    edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1018 }
1019
1020 EAPI void
1021 elm_object_style_set(Evas_Object *obj,
1022                      const char  *style)
1023 {
1024    EINA_SAFETY_ON_NULL_RETURN(obj);
1025    elm_widget_style_set(obj, style);
1026 }
1027
1028 EAPI const char *
1029 elm_object_style_get(const Evas_Object *obj)
1030 {
1031    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1032    return elm_widget_style_get(obj);
1033 }
1034
1035 EAPI void
1036 elm_object_disabled_set(Evas_Object *obj,
1037                         Eina_Bool    disabled)
1038 {
1039    EINA_SAFETY_ON_NULL_RETURN(obj);
1040    elm_widget_disabled_set(obj, disabled);
1041 }
1042
1043 EAPI Eina_Bool
1044 elm_object_disabled_get(const Evas_Object *obj)
1045 {
1046    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1047    return elm_widget_disabled_get(obj);
1048 }
1049
1050 EAPI Eina_Bool
1051 elm_config_save(void)
1052 {
1053    return _elm_config_save();
1054 }
1055
1056 EAPI void
1057 elm_config_reload(void)
1058 {
1059    _elm_config_reload();
1060 }
1061
1062 EAPI const char *
1063 elm_profile_current_get(void)
1064 {
1065    return _elm_config_current_profile_get();
1066 }
1067
1068 EAPI const char *
1069 elm_profile_dir_get(const char *profile,
1070                     Eina_Bool   is_user)
1071 {
1072    return _elm_config_profile_dir_get(profile, is_user);
1073 }
1074
1075 EAPI void
1076 elm_profile_dir_free(const char *p_dir)
1077 {
1078    free((void *)p_dir);
1079 }
1080
1081 EAPI Eina_List *
1082 elm_profile_list_get(void)
1083 {
1084    return _elm_config_profiles_list();
1085 }
1086
1087 EAPI void
1088 elm_profile_list_free(Eina_List *l)
1089 {
1090    const char *dir;
1091
1092    EINA_LIST_FREE(l, dir)
1093      eina_stringshare_del(dir);
1094 }
1095
1096 EAPI void
1097 elm_profile_set(const char *profile)
1098 {
1099    EINA_SAFETY_ON_NULL_RETURN(profile);
1100    _elm_config_profile_set(profile);
1101 }
1102
1103 EAPI void
1104 elm_profile_all_set(const char *profile)
1105 {
1106    _elm_config_profile_set(profile);
1107    _elm_config_all_update();
1108 }
1109
1110 EAPI const char *
1111 elm_engine_current_get(void)
1112 {
1113    return _elm_config->engine;
1114 }
1115
1116 EAPI void
1117 elm_engine_set(const char *engine)
1118 {
1119    EINA_SAFETY_ON_NULL_RETURN(engine);
1120
1121    _elm_config_engine_set(engine);
1122 }
1123
1124 EAPI const Eina_List *
1125 elm_text_classes_list_get(void)
1126 {
1127    return _elm_config_text_classes_get();
1128 }
1129
1130 EAPI void
1131 elm_text_classes_list_free(const Eina_List *list)
1132 {
1133    _elm_config_text_classes_free((Eina_List *)list);
1134 }
1135
1136 EAPI const Eina_List *
1137 elm_font_overlay_list_get(void)
1138 {
1139    return _elm_config_font_overlays_list();
1140 }
1141
1142 EAPI void
1143 elm_font_overlay_set(const char    *text_class,
1144                      const char    *font,
1145                      Evas_Font_Size size)
1146 {
1147    _elm_config_font_overlay_set(text_class, font, size);
1148 }
1149
1150 EAPI void
1151 elm_font_overlay_unset(const char *text_class)
1152 {
1153    _elm_config_font_overlay_remove(text_class);
1154 }
1155
1156 EAPI void
1157 elm_font_overlay_apply(void)
1158 {
1159    _elm_config_font_overlay_apply();
1160 }
1161
1162 EAPI void
1163 elm_font_overlay_all_apply(void)
1164 {
1165    elm_font_overlay_apply();
1166    _elm_config_all_update();
1167 }
1168
1169 EAPI Elm_Font_Properties *
1170 elm_font_properties_get(const char *font)
1171 {
1172    EINA_SAFETY_ON_NULL_RETURN_VAL(font, NULL);
1173    return _elm_font_properties_get(NULL, font);
1174 }
1175
1176 EAPI void
1177 elm_font_properties_free(Elm_Font_Properties *efp)
1178 {
1179    const char *str;
1180
1181    EINA_SAFETY_ON_NULL_RETURN(efp);
1182    EINA_LIST_FREE(efp->styles, str)
1183      if (str) eina_stringshare_del(str);
1184    if (efp->name) eina_stringshare_del(efp->name);
1185    free(efp);
1186 }
1187
1188 EAPI const char *
1189 elm_font_fontconfig_name_get(const char *name,
1190                              const char *style)
1191 {
1192    char buf[256];
1193
1194    EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
1195    if (!style || style[0] == 0) return eina_stringshare_add(name);
1196    snprintf(buf, 256, "%s" ELM_FONT_TOKEN_STYLE "%s", name, style);
1197    return eina_stringshare_add(buf);
1198 }
1199
1200 EAPI void
1201 elm_font_fontconfig_name_free(const char *name)
1202 {
1203    eina_stringshare_del(name);
1204 }
1205
1206 EAPI Eina_Hash *
1207 elm_font_available_hash_add(Eina_List *list)
1208 {
1209    Eina_Hash *font_hash;
1210    Eina_List *l;
1211    void *key;
1212
1213    font_hash = NULL;
1214
1215    /* populate with default font families */
1216    font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Regular");
1217    font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Bold");
1218    font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Oblique");
1219    font_hash = _elm_font_available_hash_add(font_hash,
1220                                             "Sans:style=Bold Oblique");
1221
1222    font_hash = _elm_font_available_hash_add(font_hash, "Serif:style=Regular");
1223    font_hash = _elm_font_available_hash_add(font_hash, "Serif:style=Bold");
1224    font_hash = _elm_font_available_hash_add(font_hash, "Serif:style=Oblique");
1225    font_hash = _elm_font_available_hash_add(font_hash,
1226                                             "Serif:style=Bold Oblique");
1227
1228    font_hash = _elm_font_available_hash_add(font_hash,
1229                                             "Monospace:style=Regular");
1230    font_hash = _elm_font_available_hash_add(font_hash,
1231                                             "Monospace:style=Bold");
1232    font_hash = _elm_font_available_hash_add(font_hash,
1233                                             "Monospace:style=Oblique");
1234    font_hash = _elm_font_available_hash_add(font_hash,
1235                                             "Monospace:style=Bold Oblique");
1236
1237    EINA_LIST_FOREACH(list, l, key)
1238      font_hash = _elm_font_available_hash_add(font_hash, key);
1239
1240    return font_hash;
1241 }
1242
1243 EAPI void
1244 elm_font_available_hash_del(Eina_Hash *hash)
1245 {
1246    _elm_font_available_hash_del(hash);
1247 }
1248
1249 EAPI Evas_Coord
1250 elm_finger_size_get(void)
1251 {
1252    return _elm_config->finger_size;
1253 }
1254
1255 EAPI void
1256 elm_finger_size_set(Evas_Coord size)
1257 {
1258    if (_elm_config->finger_size == size) return;
1259    _elm_config->finger_size = size;
1260    _elm_rescale();
1261 }
1262
1263 EAPI void
1264 elm_finger_size_all_set(Evas_Coord size)
1265 {
1266    elm_finger_size_set(size);
1267    _elm_config_all_update();
1268 }
1269
1270 EAPI void
1271 elm_coords_finger_size_adjust(int         times_w,
1272                               Evas_Coord *w,
1273                               int         times_h,
1274                               Evas_Coord *h)
1275 {
1276    if ((w) && (*w < (_elm_config->finger_size * times_w)))
1277      *w = _elm_config->finger_size * times_w;
1278    if ((h) && (*h < (_elm_config->finger_size * times_h)))
1279      *h = _elm_config->finger_size * times_h;
1280 }
1281
1282 EAPI void
1283 elm_all_flush(void)
1284 {
1285    const Eina_List *l;
1286    Evas_Object *obj;
1287
1288    edje_file_cache_flush();
1289    edje_collection_cache_flush();
1290    eet_clearcache();
1291    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1292      {
1293         Evas *e = evas_object_evas_get(obj);
1294         evas_image_cache_flush(e);
1295         evas_font_cache_flush(e);
1296         evas_render_dump(e);
1297      }
1298 }
1299
1300 EAPI int
1301 elm_cache_flush_interval_get(void)
1302 {
1303    return _elm_config->cache_flush_poll_interval;
1304 }
1305
1306 EAPI void
1307 elm_cache_flush_interval_set(int size)
1308 {
1309    if (_elm_config->cache_flush_poll_interval == size) return;
1310    _elm_config->cache_flush_poll_interval = size;
1311
1312    _elm_recache();
1313 }
1314
1315 EAPI void
1316 elm_cache_flush_interval_all_set(int size)
1317 {
1318    elm_cache_flush_interval_set(size);
1319    _elm_config_all_update();
1320 }
1321
1322 EAPI Eina_Bool
1323 elm_cache_flush_enabled_get(void)
1324 {
1325    return _elm_config->cache_flush_enable;
1326 }
1327
1328 EAPI void
1329 elm_cache_flush_enabled_set(Eina_Bool enabled)
1330 {
1331    enabled = !!enabled;
1332    if (_elm_config->cache_flush_enable == enabled) return;
1333    _elm_config->cache_flush_enable = enabled;
1334
1335    _elm_recache();
1336 }
1337
1338 EAPI void
1339 elm_cache_flush_enabled_all_set(Eina_Bool enabled)
1340 {
1341    elm_cache_flush_enabled_set(enabled);
1342    _elm_config_all_update();
1343 }
1344
1345 EAPI int
1346 elm_font_cache_get(void)
1347 {
1348    return _elm_config->font_cache;
1349 }
1350
1351 EAPI void
1352 elm_font_cache_set(int size)
1353 {
1354    if (_elm_config->font_cache == size) return;
1355    _elm_config->font_cache = size;
1356
1357    _elm_recache();
1358 }
1359
1360 EAPI void
1361 elm_font_cache_all_set(int size)
1362 {
1363    elm_font_cache_set(size);
1364    _elm_config_all_update();
1365 }
1366
1367 EAPI int
1368 elm_image_cache_get(void)
1369 {
1370    return _elm_config->image_cache;
1371 }
1372
1373 EAPI void
1374 elm_image_cache_set(int size)
1375 {
1376    if (_elm_config->image_cache == size) return;
1377    _elm_config->image_cache = size;
1378
1379    _elm_recache();
1380 }
1381
1382 EAPI void
1383 elm_image_cache_all_set(int size)
1384 {
1385    elm_image_cache_set(size);
1386    _elm_config_all_update();
1387 }
1388
1389 EAPI int
1390 elm_edje_file_cache_get(void)
1391 {
1392    return _elm_config->edje_cache;
1393 }
1394
1395 EAPI void
1396 elm_edje_file_cache_set(int size)
1397 {
1398    if (_elm_config->edje_cache == size) return;
1399    _elm_config->edje_cache = size;
1400
1401    _elm_recache();
1402 }
1403
1404 EAPI void
1405 elm_edje_file_cache_all_set(int size)
1406 {
1407    elm_edje_file_cache_set(size);
1408    _elm_config_all_update();
1409 }
1410
1411 EAPI int
1412 elm_edje_collection_cache_get(void)
1413 {
1414    return _elm_config->edje_collection_cache;
1415 }
1416
1417 EAPI void
1418 elm_edje_collection_cache_set(int size)
1419 {
1420    if (_elm_config->edje_collection_cache == size) return;
1421    _elm_config->edje_collection_cache = size;
1422
1423    _elm_recache();
1424 }
1425
1426 EAPI void
1427 elm_edje_collection_cache_all_set(int size)
1428 {
1429    elm_edje_collection_cache_set(size);
1430    _elm_config_all_update();
1431 }
1432
1433 EAPI Eina_Bool
1434 elm_object_focus_get(const Evas_Object *obj)
1435 {
1436    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1437    return elm_widget_focus_get(obj);
1438 }
1439
1440 EAPI void
1441 elm_object_focus_set(Evas_Object *obj,
1442                      Eina_Bool    focus)
1443 {
1444    EINA_SAFETY_ON_NULL_RETURN(obj);
1445    if (focus)
1446      {
1447         if (elm_widget_focus_get(obj)) return;
1448         elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1449      }
1450    else
1451      {
1452         if (!elm_widget_can_focus_get(obj)) return;
1453         elm_widget_focused_object_clear(obj);
1454      }
1455 }
1456
1457 EAPI void
1458 elm_object_focus(Evas_Object *obj)
1459 {
1460    EINA_SAFETY_ON_NULL_RETURN(obj);
1461    elm_object_focus_set(obj, EINA_TRUE);
1462 }
1463
1464 EAPI void
1465 elm_object_unfocus(Evas_Object *obj)
1466 {
1467    EINA_SAFETY_ON_NULL_RETURN(obj);
1468    elm_object_focus_set(obj, EINA_FALSE);
1469 }
1470
1471 EAPI void
1472 elm_object_focus_allow_set(Evas_Object *obj,
1473                            Eina_Bool    enable)
1474 {
1475    EINA_SAFETY_ON_NULL_RETURN(obj);
1476    elm_widget_can_focus_set(obj, enable);
1477 }
1478
1479 EAPI Eina_Bool
1480 elm_object_focus_allow_get(const Evas_Object *obj)
1481 {
1482    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1483    return (elm_widget_can_focus_get(obj)) || (elm_widget_child_can_focus_get(obj));
1484 }
1485
1486 EAPI void
1487 elm_object_focus_custom_chain_set(Evas_Object *obj,
1488                                   Eina_List   *objs)
1489 {
1490    EINA_SAFETY_ON_NULL_RETURN(obj);
1491    elm_widget_focus_custom_chain_set(obj, objs);
1492 }
1493
1494 EAPI void
1495 elm_object_focus_custom_chain_unset(Evas_Object *obj)
1496 {
1497    EINA_SAFETY_ON_NULL_RETURN(obj);
1498    elm_widget_focus_custom_chain_unset(obj);
1499 }
1500
1501 EAPI const Eina_List *
1502 elm_object_focus_custom_chain_get(const Evas_Object *obj)
1503 {
1504    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1505    return elm_widget_focus_custom_chain_get(obj);
1506 }
1507
1508 EAPI void
1509 elm_object_focus_custom_chain_append(Evas_Object *obj,
1510                                      Evas_Object *child,
1511                                      Evas_Object *relative_child)
1512 {
1513    EINA_SAFETY_ON_NULL_RETURN(obj);
1514    EINA_SAFETY_ON_NULL_RETURN(child);
1515    elm_widget_focus_custom_chain_append(obj, child, relative_child);
1516 }
1517
1518 EAPI void
1519 elm_object_focus_custom_chain_prepend(Evas_Object *obj,
1520                                       Evas_Object *child,
1521                                       Evas_Object *relative_child)
1522 {
1523    EINA_SAFETY_ON_NULL_RETURN(obj);
1524    EINA_SAFETY_ON_NULL_RETURN(child);
1525    elm_widget_focus_custom_chain_prepend(obj, child, relative_child);
1526 }
1527
1528 EAPI void
1529 elm_object_focus_cycle(Evas_Object        *obj,
1530                        Elm_Focus_Direction dir)
1531 {
1532    EINA_SAFETY_ON_NULL_RETURN(obj);
1533    elm_widget_focus_cycle(obj, dir);
1534 }
1535
1536 EAPI void
1537 elm_object_focus_direction_go(Evas_Object *obj,
1538                               int          x,
1539                               int          y)
1540 {
1541    EINA_SAFETY_ON_NULL_RETURN(obj);
1542    elm_widget_focus_direction_go(obj, x, y);
1543 }
1544
1545 EAPI void
1546 elm_object_tree_unfocusable_set(Evas_Object *obj,
1547                                 Eina_Bool    tree_unfocusable)
1548 {
1549    EINA_SAFETY_ON_NULL_RETURN(obj);
1550    elm_widget_tree_unfocusable_set(obj, tree_unfocusable);
1551 }
1552
1553 EAPI Eina_Bool
1554 elm_object_tree_unfocusable_get(const Evas_Object *obj)
1555 {
1556    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1557    return elm_widget_tree_unfocusable_get(obj);
1558 }
1559
1560 EAPI Eina_Bool
1561 elm_focus_highlight_enabled_get(void)
1562 {
1563    return _elm_config->focus_highlight_enable;
1564 }
1565
1566 EAPI void
1567 elm_focus_highlight_enabled_set(Eina_Bool enable)
1568 {
1569    _elm_config->focus_highlight_enable = !!enable;
1570 }
1571
1572 EAPI Eina_Bool
1573 elm_focus_highlight_animate_get(void)
1574 {
1575    return _elm_config->focus_highlight_animate;
1576 }
1577
1578 EAPI void
1579 elm_focus_highlight_animate_set(Eina_Bool animate)
1580 {
1581    _elm_config->focus_highlight_animate = !!animate;
1582 }
1583
1584 EAPI Eina_Bool
1585 elm_scroll_bounce_enabled_get(void)
1586 {
1587    return _elm_config->thumbscroll_bounce_enable;
1588 }
1589
1590 EAPI void
1591 elm_scroll_bounce_enabled_set(Eina_Bool enabled)
1592 {
1593    _elm_config->thumbscroll_bounce_enable = enabled;
1594 }
1595
1596 EAPI void
1597 elm_scroll_bounce_enabled_all_set(Eina_Bool enabled)
1598 {
1599    elm_scroll_bounce_enabled_set(enabled);
1600    _elm_config_all_update();
1601 }
1602
1603 EAPI double
1604 elm_scroll_bounce_friction_get(void)
1605 {
1606    return _elm_config->thumbscroll_bounce_friction;
1607 }
1608
1609 EAPI void
1610 elm_scroll_bounce_friction_set(double friction)
1611 {
1612    _elm_config->thumbscroll_bounce_friction = friction;
1613 }
1614
1615 EAPI void
1616 elm_scroll_bounce_friction_all_set(double friction)
1617 {
1618    elm_scroll_bounce_friction_set(friction);
1619    _elm_config_all_update();
1620 }
1621
1622 EAPI double
1623 elm_scroll_page_scroll_friction_get(void)
1624 {
1625    return _elm_config->page_scroll_friction;
1626 }
1627
1628 EAPI void
1629 elm_scroll_page_scroll_friction_set(double friction)
1630 {
1631    _elm_config->page_scroll_friction = friction;
1632 }
1633
1634 EAPI void
1635 elm_scroll_page_scroll_friction_all_set(double friction)
1636 {
1637    elm_scroll_page_scroll_friction_set(friction);
1638    _elm_config_all_update();
1639 }
1640
1641 EAPI double
1642 elm_scroll_bring_in_scroll_friction_get(void)
1643 {
1644    return _elm_config->bring_in_scroll_friction;
1645 }
1646
1647 EAPI void
1648 elm_scroll_bring_in_scroll_friction_set(double friction)
1649 {
1650    _elm_config->bring_in_scroll_friction = friction;
1651 }
1652
1653 EAPI void
1654 elm_scroll_bring_in_scroll_friction_all_set(double friction)
1655 {
1656    elm_scroll_bring_in_scroll_friction_set(friction);
1657    _elm_config_all_update();
1658 }
1659
1660 EAPI double
1661 elm_scroll_zoom_friction_get(void)
1662 {
1663    return _elm_config->zoom_friction;
1664 }
1665
1666 EAPI void
1667 elm_scroll_zoom_friction_set(double friction)
1668 {
1669    _elm_config->zoom_friction = friction;
1670 }
1671
1672 EAPI void
1673 elm_scroll_zoom_friction_all_set(double friction)
1674 {
1675    elm_scroll_zoom_friction_set(friction);
1676    _elm_config_all_update();
1677 }
1678
1679 EAPI Eina_Bool
1680 elm_scroll_thumbscroll_enabled_get(void)
1681 {
1682    return _elm_config->thumbscroll_enable;
1683 }
1684
1685 EAPI void
1686 elm_scroll_thumbscroll_enabled_set(Eina_Bool enabled)
1687 {
1688    _elm_config->thumbscroll_enable = enabled;
1689 }
1690
1691 EAPI void
1692 elm_scroll_thumbscroll_enabled_all_set(Eina_Bool enabled)
1693 {
1694    elm_scroll_thumbscroll_enabled_set(enabled);
1695    _elm_config_all_update();
1696 }
1697
1698 EAPI unsigned int
1699 elm_scroll_thumbscroll_threshold_get(void)
1700 {
1701    return _elm_config->thumbscroll_threshold;
1702 }
1703
1704 EAPI void
1705 elm_scroll_thumbscroll_threshold_set(unsigned int threshold)
1706 {
1707    _elm_config->thumbscroll_threshold = threshold;
1708 }
1709
1710 EAPI void
1711 elm_scroll_thumbscroll_threshold_all_set(unsigned int threshold)
1712 {
1713    elm_scroll_thumbscroll_threshold_set(threshold);
1714    _elm_config_all_update();
1715 }
1716
1717 EAPI double
1718 elm_scroll_thumbscroll_momentum_threshold_get(void)
1719 {
1720    return _elm_config->thumbscroll_momentum_threshold;
1721 }
1722
1723 EAPI void
1724 elm_scroll_thumbscroll_momentum_threshold_set(double threshold)
1725 {
1726    _elm_config->thumbscroll_momentum_threshold = threshold;
1727 }
1728
1729 EAPI void
1730 elm_scroll_thumbscroll_momentum_threshold_all_set(double threshold)
1731 {
1732    elm_scroll_thumbscroll_momentum_threshold_set(threshold);
1733    _elm_config_all_update();
1734 }
1735
1736 EAPI double
1737 elm_scroll_thumbscroll_friction_get(void)
1738 {
1739    return _elm_config->thumbscroll_friction;
1740 }
1741
1742 EAPI void
1743 elm_scroll_thumbscroll_friction_set(double friction)
1744 {
1745    _elm_config->thumbscroll_friction = friction;
1746 }
1747
1748 EAPI void
1749 elm_scroll_thumbscroll_friction_all_set(double friction)
1750 {
1751    elm_scroll_thumbscroll_friction_set(friction);
1752    _elm_config_all_update();
1753 }
1754
1755 EAPI double
1756 elm_scroll_thumbscroll_border_friction_get(void)
1757 {
1758    return _elm_config->thumbscroll_border_friction;
1759 }
1760
1761 EAPI void
1762 elm_scroll_thumbscroll_border_friction_set(double friction)
1763 {
1764    if (friction < 0.0) friction = 0.0;
1765    if (friction > 1.0) friction = 1.0;
1766    _elm_config->thumbscroll_friction = friction;
1767 }
1768
1769 EAPI void
1770 elm_scroll_thumbscroll_border_friction_all_set(double friction)
1771 {
1772    elm_scroll_thumbscroll_border_friction_set(friction);
1773    _elm_config_all_update();
1774 }
1775
1776 EAPI double
1777 elm_scroll_thumbscroll_sensitivity_friction_get(void)
1778 {
1779    return _elm_config->thumbscroll_sensitivity_friction;
1780 }
1781
1782 EAPI void
1783 elm_scroll_thumbscroll_sensitivity_friction_set(double friction)
1784 {
1785    if (friction < 0.1) friction = 0.1;
1786    if (friction > 1.0) friction = 1.0;
1787    _elm_config->thumbscroll_friction = friction;
1788 }
1789
1790 EAPI void
1791 elm_scroll_thumbscroll_sensitivity_friction_all_set(double friction)
1792 {
1793    elm_scroll_thumbscroll_sensitivity_friction_set(friction);
1794    _elm_config_all_update();
1795 }
1796
1797 EAPI void
1798 elm_object_scroll_hold_push(Evas_Object *obj)
1799 {
1800    EINA_SAFETY_ON_NULL_RETURN(obj);
1801    elm_widget_scroll_hold_push(obj);
1802 }
1803
1804 EAPI void
1805 elm_object_scroll_hold_pop(Evas_Object *obj)
1806 {
1807    EINA_SAFETY_ON_NULL_RETURN(obj);
1808    elm_widget_scroll_hold_pop(obj);
1809 }
1810
1811 EAPI void
1812 elm_object_scroll_freeze_push(Evas_Object *obj)
1813 {
1814    EINA_SAFETY_ON_NULL_RETURN(obj);
1815    elm_widget_scroll_freeze_push(obj);
1816 }
1817
1818 EAPI void
1819 elm_object_scroll_lock_x_set(Evas_Object *obj,
1820                              Eina_Bool    lock)
1821 {
1822    EINA_SAFETY_ON_NULL_RETURN(obj);
1823    elm_widget_drag_lock_x_set(obj, lock);
1824 }
1825
1826 EAPI void
1827 elm_object_scroll_lock_y_set(Evas_Object *obj,
1828                              Eina_Bool    lock)
1829 {
1830    EINA_SAFETY_ON_NULL_RETURN(obj);
1831    elm_widget_drag_lock_y_set(obj, lock);
1832 }
1833
1834 EAPI Eina_Bool
1835 elm_object_scroll_lock_x_get(const Evas_Object *obj)
1836 {
1837    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1838    return elm_widget_drag_lock_x_get(obj);
1839 }
1840
1841 EAPI Eina_Bool
1842 elm_object_scroll_lock_y_get(const Evas_Object *obj)
1843 {
1844    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1845    return elm_widget_drag_lock_y_get(obj);
1846 }
1847
1848 EAPI void
1849 elm_object_scroll_freeze_pop(Evas_Object *obj)
1850 {
1851    EINA_SAFETY_ON_NULL_RETURN(obj);
1852    elm_widget_scroll_freeze_pop(obj);
1853 }
1854
1855 EAPI Eina_Bool
1856 elm_object_widget_check(const Evas_Object *obj)
1857 {
1858    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1859    return elm_widget_is(obj);
1860 }
1861
1862 EAPI Evas_Object *
1863 elm_object_parent_widget_get(const Evas_Object *obj)
1864 {
1865    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1866    return elm_widget_parent_widget_get(obj);
1867 }
1868
1869 EAPI Evas_Object *
1870 elm_object_top_widget_get(const Evas_Object *obj)
1871 {
1872    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1873    return elm_widget_top_get(obj);
1874 }
1875
1876 EAPI const char *
1877 elm_object_widget_type_get(const Evas_Object *obj)
1878 {
1879    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1880    return elm_widget_type_get(obj);
1881 }
1882
1883 EAPI void
1884 elm_object_signal_emit(Evas_Object *obj,
1885                        const char  *emission,
1886                        const char  *source)
1887 {
1888    EINA_SAFETY_ON_NULL_RETURN(obj);
1889    elm_widget_signal_emit(obj, emission, source);
1890 }
1891
1892 EAPI void
1893 elm_object_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
1894 {
1895     EINA_SAFETY_ON_NULL_RETURN(obj);
1896     EINA_SAFETY_ON_NULL_RETURN(func);
1897     elm_widget_signal_callback_add(obj, emission, source, func, data);
1898 }
1899
1900 EAPI void *
1901 elm_object_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func)
1902 {
1903     EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1904     EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1905     return elm_widget_signal_callback_del(obj, emission, source, func);
1906 }
1907
1908 EAPI void
1909 elm_object_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1910 {
1911    EINA_SAFETY_ON_NULL_RETURN(obj);
1912    EINA_SAFETY_ON_NULL_RETURN(func);
1913    elm_widget_event_callback_add(obj, func, data);
1914 }
1915
1916 EAPI void *
1917 elm_object_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1918 {
1919    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1920    EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1921    return elm_widget_event_callback_del(obj, func, data);
1922 }
1923
1924 EAPI void
1925 elm_object_tree_dump(const Evas_Object *top)
1926 {
1927 #ifdef ELM_DEBUG
1928    elm_widget_tree_dump(top);
1929 #else
1930    return;
1931    (void)top;
1932 #endif
1933 }
1934
1935 EAPI void
1936 elm_object_tree_dot_dump(const Evas_Object *top,
1937                          const char        *file)
1938 {
1939 #ifdef ELM_DEBUG
1940    FILE *f = fopen(file, "wb");
1941    elm_widget_tree_dot_dump(top, f);
1942    fclose(f);
1943 #else
1944    return;
1945    (void)top;
1946    (void)file;
1947 #endif
1948 }
1949
1950 EAPI void
1951 elm_longpress_timeout_set(double longpress_timeout)
1952 {
1953    _elm_config->longpress_timeout = longpress_timeout;
1954 }
1955
1956 EAPI double
1957 elm_longpress_timeout_get(void)
1958 {
1959    return _elm_config->longpress_timeout;
1960 }
1961
1962 EAPI Evas_Object *
1963 elm_object_item_object_get(const Elm_Object_Item *it)
1964 {
1965    return ((Elm_Widget_Item *) it)->widget;
1966 }
1967
1968 EAPI void
1969 elm_object_item_content_part_set(Elm_Object_Item *it,
1970                                  const char *part,
1971                                  Evas_Object *content)
1972 {
1973    _elm_widget_item_content_part_set((Elm_Widget_Item *) it, part, content);
1974 }
1975
1976 EAPI Evas_Object *
1977 elm_object_item_content_part_get(const Elm_Object_Item *it,
1978                                  const char *part)
1979 {
1980    return _elm_widget_item_content_part_get((Elm_Widget_Item *) it, part);
1981 }
1982
1983 EAPI Evas_Object *
1984 elm_object_item_content_part_unset(Elm_Object_Item *it, const char *part)
1985 {
1986    return _elm_widget_item_content_part_unset((Elm_Widget_Item *) it, part);
1987 }
1988
1989 EAPI void
1990 elm_object_item_text_part_set(Elm_Object_Item *it,
1991                               const char *part,
1992                               const char *label)
1993 {
1994    _elm_widget_item_text_part_set((Elm_Widget_Item *) it, part, label);
1995 }
1996
1997 EAPI const char *
1998 elm_object_item_text_part_get(const Elm_Object_Item *it, const char *part)
1999 {
2000    return _elm_widget_item_text_part_get((Elm_Widget_Item *) it, part);
2001 }
2002
2003 EAPI void
2004 elm_object_access_info_set(Evas_Object *obj, const char *txt)
2005 {
2006    elm_widget_access_info_set(obj, txt);
2007 }
2008
2009 EAPI void
2010 elm_object_item_access_info_set(Elm_Object_Item *it, const char *txt)
2011 {
2012    _elm_widget_item_access_info_set((Elm_Widget_Item *) it, txt);
2013 }
2014
2015 EAPI void *
2016 elm_object_item_data_get(const Elm_Object_Item *it)
2017 {
2018    return elm_widget_item_data_get(it);
2019 }
2020
2021 EAPI void
2022 elm_object_item_data_set(Elm_Object_Item *it, void *data)
2023 {
2024    elm_widget_item_data_set(it, data);
2025 }
2026
2027 EAPI void
2028 elm_object_item_signal_emit(Elm_Object_Item *it, const char *emission, const char *source)
2029 {
2030    _elm_widget_item_signal_emit((Elm_Widget_Item *) it, emission, source);
2031 }