elm: change elm_object_content_part_set/get/unset to elm_object_part_content_set...
[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_OPENGL_COCOA) ||
466             ENGINE_COMPARE(ELM_SOFTWARE_WIN32) ||
467             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
468             ENGINE_COMPARE(ELM_EWS))
469 #undef ENGINE_COMPARE
470           evas_cserve_disconnect();
471         edje_shutdown();
472         evas_shutdown();
473      }
474    return _elm_sub_init_count;
475 }
476
477 EAPI int
478 elm_quicklaunch_shutdown(void)
479 {
480    _elm_ql_init_count--;
481    if (_elm_ql_init_count > 0) return _elm_ql_init_count;
482    if (pfx) eina_prefix_free(pfx);
483    pfx = NULL;
484    eina_stringshare_del(_elm_data_dir);
485    _elm_data_dir = NULL;
486    eina_stringshare_del(_elm_lib_dir);
487    _elm_lib_dir = NULL;
488
489    free(_elm_appname);
490    _elm_appname = NULL;
491
492    _elm_config_shutdown();
493
494    ecore_event_handler_del(_elm_exit_handler);
495    _elm_exit_handler = NULL;
496
497    _elm_theme_shutdown();
498    _elm_unneed_efreet();
499    _elm_unneed_e_dbus();
500    _elm_unneed_ethumb();
501    _elm_unneed_web();
502    ecore_file_shutdown();
503
504 #ifdef HAVE_ELEMENTARY_EMAP
505    emap_shutdown();
506 #endif
507
508    ecore_shutdown();
509    eet_shutdown();
510
511    if ((_elm_log_dom > -1) && (_elm_log_dom != EINA_LOG_DOMAIN_GLOBAL))
512      {
513         eina_log_domain_unregister(_elm_log_dom);
514         _elm_log_dom = -1;
515      }
516
517    _elm_widget_type_clear();
518
519    eina_shutdown();
520    return _elm_ql_init_count;
521 }
522
523 EAPI void
524 elm_quicklaunch_seed(void)
525 {
526 #ifndef SEMI_BROKEN_QUICKLAUNCH
527    if (quicklaunch_on)
528      {
529         Evas_Object *win, *bg, *bt;
530
531         win = elm_win_add(NULL, "seed", ELM_WIN_BASIC);
532         bg = elm_bg_add(win);
533         elm_win_resize_object_add(win, bg);
534         evas_object_show(bg);
535         bt = elm_button_add(win);
536         elm_button_label_set(bt, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~-_=+\\|]}[{;:'\",<.>/?");
537         elm_win_resize_object_add(win, bt);
538         ecore_main_loop_iterate();
539         evas_object_del(win);
540         ecore_main_loop_iterate();
541 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
542         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
543             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
544             ENGINE_COMPARE(ELM_XRENDER_X11) ||
545             ENGINE_COMPARE(ELM_OPENGL_X11))
546 #undef ENGINE_COMPARE
547           {
548 # ifdef HAVE_ELEMENTARY_X
549              ecore_x_sync();
550 # endif
551           }
552         ecore_main_loop_iterate();
553      }
554 #endif
555 }
556
557 #ifdef HAVE_FORK
558 static void *qr_handle = NULL;
559 #endif
560 static int (*qr_main)(int    argc,
561                       char **argv) = NULL;
562
563 EAPI Eina_Bool
564 elm_quicklaunch_prepare(int argc __UNUSED__,
565                         char   **argv)
566 {
567 #ifdef HAVE_FORK
568    char *exe = elm_quicklaunch_exe_path_get(argv[0]);
569    if (!exe)
570      {
571         ERR("requested quicklaunch binary '%s' does not exist\n", argv[0]);
572         return EINA_FALSE;
573      }
574    else
575      {
576         char *exe2, *p;
577         char *exename;
578
579         exe2 = malloc(strlen(exe) + 1 + 10);
580         strcpy(exe2, exe);
581         p = strrchr(exe2, '/');
582         if (p) p++;
583         else p = exe2;
584         exename = alloca(strlen(p) + 1);
585         strcpy(exename, p);
586         *p = 0;
587         strcat(p, "../lib/");
588         strcat(p, exename);
589         strcat(p, ".so");
590         if (!access(exe2, R_OK | X_OK))
591           {
592              free(exe);
593              exe = exe2;
594           }
595         else
596           free(exe2);
597      }
598    qr_handle = dlopen(exe, RTLD_NOW | RTLD_GLOBAL);
599    if (!qr_handle)
600      {
601         fprintf(stderr, "dlerr: %s\n", dlerror());
602         WRN("dlopen('%s') failed: %s", exe, dlerror());
603         free(exe);
604         return EINA_FALSE;
605      }
606    INF("dlopen('%s') = %p", exe, qr_handle);
607    qr_main = dlsym(qr_handle, "elm_main");
608    INF("dlsym(%p, 'elm_main') = %p", qr_handle, qr_main);
609    if (!qr_main)
610      {
611         WRN("not quicklauncher capable: no elm_main in '%s'", exe);
612         dlclose(qr_handle);
613         qr_handle = NULL;
614         free(exe);
615         return EINA_FALSE;
616      }
617    free(exe);
618    return EINA_TRUE;
619 #else
620    return EINA_FALSE;
621    (void)argv;
622 #endif
623 }
624
625 #ifdef HAVE_FORK
626 static void
627 save_env(void)
628 {
629    int i, size;
630    extern char **environ;
631    char **oldenv, **p;
632
633    oldenv = environ;
634
635    for (i = 0, size = 0; environ[i]; i++)
636      size += strlen(environ[i]) + 1;
637
638    p = malloc((i + 1) * sizeof(char *));
639    if (!p) return;
640
641    environ = p;
642
643    for (i = 0; oldenv[i]; i++)
644      environ[i] = strdup(oldenv[i]);
645    environ[i] = NULL;
646 }
647
648 #endif
649
650 EAPI Eina_Bool
651 elm_quicklaunch_fork(int    argc,
652                      char **argv,
653                      char  *cwd,
654                      void (postfork_func) (void *data),
655                      void  *postfork_data)
656 {
657 #ifdef HAVE_FORK
658    pid_t child;
659    int ret;
660    int real_argc;
661    char **real_argv;
662
663    // FIXME:
664    // need to accept current environment from elementary_run
665    if (!qr_main)
666      {
667         int i;
668         char **args;
669
670         child = fork();
671         if (child > 0) return EINA_TRUE;
672         else if (child < 0)
673           {
674              perror("could not fork");
675              return EINA_FALSE;
676           }
677         setsid();
678         if (chdir(cwd) != 0)
679           perror("could not chdir");
680         args = alloca((argc + 1) * sizeof(char *));
681         for (i = 0; i < argc; i++) args[i] = argv[i];
682         args[argc] = NULL;
683         WRN("%s not quicklaunch capable, fallback...", argv[0]);
684         execvp(argv[0], args);
685         ERR("failed to execute '%s': %s", argv[0], strerror(errno));
686         exit(-1);
687      }
688    child = fork();
689    if (child > 0) return EINA_TRUE;
690    else if (child < 0)
691      {
692         perror("could not fork");
693         return EINA_FALSE;
694      }
695    if (postfork_func) postfork_func(postfork_data);
696
697    if (quicklaunch_on)
698      {
699 #ifdef SEMI_BROKEN_QUICKLAUNCH
700         ecore_app_args_set(argc, (const char **)argv);
701         evas_init();
702         edje_init();
703         _elm_config_sub_init();
704 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
705         if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
706             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
707             ENGINE_COMPARE(ELM_XRENDER_X11) ||
708             ENGINE_COMPARE(ELM_OPENGL_X11))
709 #undef ENGINE_COMPARE
710           {
711 # ifdef HAVE_ELEMENTARY_X
712              ecore_x_init(NULL);
713 # endif
714           }
715         ecore_evas_init(); // FIXME: check errors
716         ecore_imf_init();
717         _elm_module_init();
718 #endif
719      }
720
721    setsid();
722    if (chdir(cwd) != 0)
723      perror("could not chdir");
724    // FIXME: this is very linux specific. it changes argv[0] of the process
725    // so ps etc. report what you'd expect. for other unixes and os's this
726    // may just not work
727    save_env();
728    if (argv)
729      {
730         char *lastarg, *p;
731
732         ecore_app_args_get(&real_argc, &real_argv);
733         lastarg = real_argv[real_argc - 1] + strlen(real_argv[real_argc - 1]);
734         for (p = real_argv[0]; p < lastarg; p++) *p = 0;
735         strcpy(real_argv[0], argv[0]);
736      }
737    ecore_app_args_set(argc, (const char **)argv);
738    ret = qr_main(argc, argv);
739    exit(ret);
740    return EINA_TRUE;
741 #else
742    return EINA_FALSE;
743    (void)argc;
744    (void)argv;
745    (void)cwd;
746    (void)postfork_func;
747    (void)postfork_data;
748 #endif
749 }
750
751 EAPI void
752 elm_quicklaunch_cleanup(void)
753 {
754 #ifdef HAVE_FORK
755    if (qr_handle)
756      {
757         dlclose(qr_handle);
758         qr_handle = NULL;
759         qr_main = NULL;
760      }
761 #endif
762 }
763
764 EAPI int
765 elm_quicklaunch_fallback(int    argc,
766                          char **argv)
767 {
768    int ret;
769    elm_quicklaunch_init(argc, argv);
770    elm_quicklaunch_sub_init(argc, argv);
771    elm_quicklaunch_prepare(argc, argv);
772    ret = qr_main(argc, argv);
773    exit(ret);
774    return ret;
775 }
776
777 EAPI char *
778 elm_quicklaunch_exe_path_get(const char *exe)
779 {
780    static char *path = NULL;
781    static Eina_List *pathlist = NULL;
782    const char *pathitr;
783    const Eina_List *l;
784    char buf[PATH_MAX];
785    if (exe[0] == '/') return strdup(exe);
786    if ((exe[0] == '.') && (exe[1] == '/')) return strdup(exe);
787    if ((exe[0] == '.') && (exe[1] == '.') && (exe[2] == '/')) return strdup(exe);
788    if (!path)
789      {
790         const char *p, *pp;
791         char *buf2;
792         path = getenv("PATH");
793         buf2 = alloca(strlen(path) + 1);
794         p = path;
795         pp = p;
796         for (;; )
797           {
798              if ((*p == ':') || (!*p))
799                {
800                   int len;
801
802                   len = p - pp;
803                   strncpy(buf2, pp, len);
804                   buf2[len] = 0;
805                   pathlist = eina_list_append(pathlist, eina_stringshare_add(buf2));
806                   if (!*p) break;
807                   p++;
808                   pp = p;
809                }
810              else
811                {
812                   if (!*p) break;
813                   p++;
814                }
815           }
816      }
817    EINA_LIST_FOREACH(pathlist, l, pathitr)
818      {
819         snprintf(buf, sizeof(buf), "%s/%s", pathitr, exe);
820         if (!access(buf, R_OK | X_OK)) return strdup(buf);
821      }
822    return NULL;
823 }
824
825 EAPI void
826 elm_run(void)
827 {
828    ecore_main_loop_begin();
829 }
830
831 EAPI void
832 elm_exit(void)
833 {
834    ecore_main_loop_quit();
835 }
836
837 EAPI Eina_Bool
838 elm_policy_set(unsigned int policy,
839                int          value)
840 {
841    Elm_Event_Policy_Changed *ev;
842
843    if (policy >= ELM_POLICY_LAST)
844      return EINA_FALSE;
845
846    if (value == _elm_policies[policy])
847      return EINA_TRUE;
848
849    /* TODO: validade policy? */
850
851    ev = malloc(sizeof(*ev));
852    ev->policy = policy;
853    ev->new_value = value;
854    ev->old_value = _elm_policies[policy];
855
856    _elm_policies[policy] = value;
857
858    ecore_event_add(ELM_EVENT_POLICY_CHANGED, ev, NULL, NULL);
859
860    return EINA_TRUE;
861 }
862
863 EAPI int
864 elm_policy_get(unsigned int policy)
865 {
866    if (policy >= ELM_POLICY_LAST)
867      return 0;
868    return _elm_policies[policy];
869 }
870
871 EAPI void
872 elm_language_set(const char *lang)
873 {
874    setlocale(LC_ALL, lang);
875    _elm_win_translate();
876 }
877
878 EAPI Eina_Bool
879 elm_object_mirrored_get(const Evas_Object *obj)
880 {
881    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
882    return elm_widget_mirrored_get(obj);
883 }
884
885 EAPI void
886 elm_object_mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
887 {
888    EINA_SAFETY_ON_NULL_RETURN(obj);
889    elm_widget_mirrored_set(obj, mirrored);
890 }
891
892 EAPI Eina_Bool
893 elm_object_mirrored_automatic_get(const Evas_Object *obj)
894 {
895    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
896    return elm_widget_mirrored_automatic_get(obj);
897 }
898
899 EAPI void
900 elm_object_mirrored_automatic_set(Evas_Object *obj, Eina_Bool automatic)
901 {
902    EINA_SAFETY_ON_NULL_RETURN(obj);
903    elm_widget_mirrored_automatic_set(obj, automatic);
904 }
905
906 /**
907  * @}
908  */
909
910 EAPI void
911 elm_object_scale_set(Evas_Object *obj,
912                      double       scale)
913 {
914    EINA_SAFETY_ON_NULL_RETURN(obj);
915    elm_widget_scale_set(obj, scale);
916 }
917
918 EAPI double
919 elm_object_scale_get(const Evas_Object *obj)
920 {
921    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, 0.0);
922    return elm_widget_scale_get(obj);
923 }
924
925 EAPI void
926 elm_object_text_part_set(Evas_Object *obj, const char *part, const char *label)
927 {
928    EINA_SAFETY_ON_NULL_RETURN(obj);
929    elm_widget_text_part_set(obj, part, label);
930 }
931
932 EAPI const char *
933 elm_object_text_part_get(const Evas_Object *obj, const char *part)
934 {
935    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
936    return elm_widget_text_part_get(obj, part);
937 }
938
939 EAPI void
940 elm_object_part_text_set(Evas_Object *obj, const char *part, const char *label)
941 {
942    EINA_SAFETY_ON_NULL_RETURN(obj);
943    elm_widget_text_part_set(obj, part, label);
944 }
945
946 EAPI const char *
947 elm_object_part_text_get(const Evas_Object *obj, const char *part)
948 {
949    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
950    return elm_widget_text_part_get(obj, part);
951 }
952
953 EAPI void
954 elm_object_domain_translatable_text_part_set(Evas_Object *obj, const char *part, const char *domain, const char *text)
955 {
956    EINA_SAFETY_ON_NULL_RETURN(obj);
957    elm_widget_domain_translatable_text_part_set(obj, part, domain, text);
958 }
959
960 EAPI const char *
961 elm_object_translatable_text_part_get(const Evas_Object *obj, const char *part)
962 {
963    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
964    return elm_widget_translatable_text_part_get(obj, part);
965 }
966
967 EAPI void
968 elm_object_part_content_set(Evas_Object *obj, const char *part, Evas_Object *content)
969 {
970    EINA_SAFETY_ON_NULL_RETURN(obj);
971    elm_widget_content_part_set(obj, part, content);
972 }
973
974 EAPI void
975 elm_object_content_part_set(Evas_Object *obj, const char *part, Evas_Object *content)
976 {
977    EINA_SAFETY_ON_NULL_RETURN(obj);
978    elm_widget_content_part_set(obj, part, content);
979 }
980
981
982 EAPI Evas_Object *
983 elm_object_part_content_get(const Evas_Object *obj, const char *part)
984 {
985    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
986    return elm_widget_content_part_get(obj, part);
987 }
988
989 EAPI Evas_Object *
990 elm_object_content_part_get(const Evas_Object *obj, const char *part)
991 {
992    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
993    return elm_widget_content_part_get(obj, part);
994 }
995
996 EAPI Evas_Object *
997 elm_object_part_content_unset(Evas_Object *obj, const char *part)
998 {
999    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1000    return elm_widget_content_part_unset(obj, part);
1001 }
1002
1003
1004 EAPI Evas_Object *
1005 elm_object_content_part_unset(Evas_Object *obj, const char *part)
1006 {
1007    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1008    return elm_widget_content_part_unset(obj, part);
1009 }
1010
1011 EAPI double
1012 elm_scale_get(void)
1013 {
1014    return _elm_config->scale;
1015 }
1016
1017 EAPI void
1018 elm_scale_set(double scale)
1019 {
1020    if (_elm_config->scale == scale) return;
1021    _elm_config->scale = scale;
1022    _elm_rescale();
1023 }
1024
1025 EAPI void
1026 elm_scale_all_set(double scale)
1027 {
1028    elm_scale_set(scale);
1029    _elm_config_all_update();
1030 }
1031
1032 EAPI Eina_Bool
1033 elm_password_show_last_get(void)
1034 {
1035    return _elm_config->password_show_last;
1036 }
1037
1038 EAPI void
1039 elm_password_show_last_set(Eina_Bool password_show_last)
1040 {
1041    if (_elm_config->password_show_last == password_show_last) return;
1042    _elm_config->password_show_last = password_show_last;
1043    edje_password_show_last_set(_elm_config->password_show_last);
1044 }
1045
1046 EAPI double
1047 elm_password_show_last_timeout_get(void)
1048 {
1049    return _elm_config->password_show_last_timeout;
1050 }
1051
1052 EAPI void
1053 elm_password_show_last_timeout_set(double password_show_last_timeout)
1054 {
1055    if (_elm_config->password_show_last_timeout == password_show_last_timeout) return;
1056    _elm_config->password_show_last_timeout = password_show_last_timeout;
1057    edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1058 }
1059
1060 EAPI void
1061 elm_object_style_set(Evas_Object *obj,
1062                      const char  *style)
1063 {
1064    EINA_SAFETY_ON_NULL_RETURN(obj);
1065    elm_widget_style_set(obj, style);
1066 }
1067
1068 EAPI const char *
1069 elm_object_style_get(const Evas_Object *obj)
1070 {
1071    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1072    return elm_widget_style_get(obj);
1073 }
1074
1075 EAPI void
1076 elm_object_disabled_set(Evas_Object *obj,
1077                         Eina_Bool    disabled)
1078 {
1079    EINA_SAFETY_ON_NULL_RETURN(obj);
1080    elm_widget_disabled_set(obj, disabled);
1081 }
1082
1083 EAPI Eina_Bool
1084 elm_object_disabled_get(const Evas_Object *obj)
1085 {
1086    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1087    return elm_widget_disabled_get(obj);
1088 }
1089
1090 EAPI Eina_Bool
1091 elm_config_save(void)
1092 {
1093    return _elm_config_save();
1094 }
1095
1096 EAPI void
1097 elm_config_reload(void)
1098 {
1099    _elm_config_reload();
1100 }
1101
1102 EAPI const char *
1103 elm_profile_current_get(void)
1104 {
1105    return _elm_config_current_profile_get();
1106 }
1107
1108 EAPI const char *
1109 elm_profile_dir_get(const char *profile,
1110                     Eina_Bool   is_user)
1111 {
1112    return _elm_config_profile_dir_get(profile, is_user);
1113 }
1114
1115 EAPI void
1116 elm_profile_dir_free(const char *p_dir)
1117 {
1118    free((void *)p_dir);
1119 }
1120
1121 EAPI Eina_List *
1122 elm_profile_list_get(void)
1123 {
1124    return _elm_config_profiles_list();
1125 }
1126
1127 EAPI void
1128 elm_profile_list_free(Eina_List *l)
1129 {
1130    const char *dir;
1131
1132    EINA_LIST_FREE(l, dir)
1133      eina_stringshare_del(dir);
1134 }
1135
1136 EAPI void
1137 elm_profile_set(const char *profile)
1138 {
1139    EINA_SAFETY_ON_NULL_RETURN(profile);
1140    _elm_config_profile_set(profile);
1141 }
1142
1143 EAPI void
1144 elm_profile_all_set(const char *profile)
1145 {
1146    _elm_config_profile_set(profile);
1147    _elm_config_all_update();
1148 }
1149
1150 EAPI const char *
1151 elm_engine_current_get(void)
1152 {
1153    return _elm_config->engine;
1154 }
1155
1156 EAPI void
1157 elm_engine_set(const char *engine)
1158 {
1159    EINA_SAFETY_ON_NULL_RETURN(engine);
1160
1161    _elm_config_engine_set(engine);
1162 }
1163
1164 EAPI const Eina_List *
1165 elm_text_classes_list_get(void)
1166 {
1167    return _elm_config_text_classes_get();
1168 }
1169
1170 EAPI void
1171 elm_text_classes_list_free(const Eina_List *list)
1172 {
1173    _elm_config_text_classes_free((Eina_List *)list);
1174 }
1175
1176 EAPI const Eina_List *
1177 elm_font_overlay_list_get(void)
1178 {
1179    return _elm_config_font_overlays_list();
1180 }
1181
1182 EAPI void
1183 elm_font_overlay_set(const char    *text_class,
1184                      const char    *font,
1185                      Evas_Font_Size size)
1186 {
1187    _elm_config_font_overlay_set(text_class, font, size);
1188 }
1189
1190 EAPI void
1191 elm_font_overlay_unset(const char *text_class)
1192 {
1193    _elm_config_font_overlay_remove(text_class);
1194 }
1195
1196 EAPI void
1197 elm_font_overlay_apply(void)
1198 {
1199    _elm_config_font_overlay_apply();
1200 }
1201
1202 EAPI void
1203 elm_font_overlay_all_apply(void)
1204 {
1205    elm_font_overlay_apply();
1206    _elm_config_all_update();
1207 }
1208
1209 EAPI Elm_Font_Properties *
1210 elm_font_properties_get(const char *font)
1211 {
1212    EINA_SAFETY_ON_NULL_RETURN_VAL(font, NULL);
1213    return _elm_font_properties_get(NULL, font);
1214 }
1215
1216 EAPI void
1217 elm_font_properties_free(Elm_Font_Properties *efp)
1218 {
1219    const char *str;
1220
1221    EINA_SAFETY_ON_NULL_RETURN(efp);
1222    EINA_LIST_FREE(efp->styles, str)
1223      if (str) eina_stringshare_del(str);
1224    if (efp->name) eina_stringshare_del(efp->name);
1225    free(efp);
1226 }
1227
1228 EAPI const char *
1229 elm_font_fontconfig_name_get(const char *name,
1230                              const char *style)
1231 {
1232    char buf[256];
1233
1234    EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
1235    if (!style || style[0] == 0) return eina_stringshare_add(name);
1236    snprintf(buf, 256, "%s" ELM_FONT_TOKEN_STYLE "%s", name, style);
1237    return eina_stringshare_add(buf);
1238 }
1239
1240 EAPI void
1241 elm_font_fontconfig_name_free(const char *name)
1242 {
1243    eina_stringshare_del(name);
1244 }
1245
1246 EAPI Eina_Hash *
1247 elm_font_available_hash_add(Eina_List *list)
1248 {
1249    Eina_Hash *font_hash;
1250    Eina_List *l;
1251    void *key;
1252
1253    font_hash = NULL;
1254
1255    /* populate with default font families */
1256    font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Regular");
1257    font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Bold");
1258    font_hash = _elm_font_available_hash_add(font_hash, "Sans:style=Oblique");
1259    font_hash = _elm_font_available_hash_add(font_hash,
1260                                             "Sans:style=Bold Oblique");
1261
1262    font_hash = _elm_font_available_hash_add(font_hash, "Serif:style=Regular");
1263    font_hash = _elm_font_available_hash_add(font_hash, "Serif:style=Bold");
1264    font_hash = _elm_font_available_hash_add(font_hash, "Serif:style=Oblique");
1265    font_hash = _elm_font_available_hash_add(font_hash,
1266                                             "Serif:style=Bold Oblique");
1267
1268    font_hash = _elm_font_available_hash_add(font_hash,
1269                                             "Monospace:style=Regular");
1270    font_hash = _elm_font_available_hash_add(font_hash,
1271                                             "Monospace:style=Bold");
1272    font_hash = _elm_font_available_hash_add(font_hash,
1273                                             "Monospace:style=Oblique");
1274    font_hash = _elm_font_available_hash_add(font_hash,
1275                                             "Monospace:style=Bold Oblique");
1276
1277    EINA_LIST_FOREACH(list, l, key)
1278      font_hash = _elm_font_available_hash_add(font_hash, key);
1279
1280    return font_hash;
1281 }
1282
1283 EAPI void
1284 elm_font_available_hash_del(Eina_Hash *hash)
1285 {
1286    _elm_font_available_hash_del(hash);
1287 }
1288
1289 EAPI Evas_Coord
1290 elm_finger_size_get(void)
1291 {
1292    return _elm_config->finger_size;
1293 }
1294
1295 EAPI void
1296 elm_finger_size_set(Evas_Coord size)
1297 {
1298    if (_elm_config->finger_size == size) return;
1299    _elm_config->finger_size = size;
1300    _elm_rescale();
1301 }
1302
1303 EAPI void
1304 elm_finger_size_all_set(Evas_Coord size)
1305 {
1306    elm_finger_size_set(size);
1307    _elm_config_all_update();
1308 }
1309
1310 EAPI void
1311 elm_coords_finger_size_adjust(int         times_w,
1312                               Evas_Coord *w,
1313                               int         times_h,
1314                               Evas_Coord *h)
1315 {
1316    if ((w) && (*w < (_elm_config->finger_size * times_w)))
1317      *w = _elm_config->finger_size * times_w;
1318    if ((h) && (*h < (_elm_config->finger_size * times_h)))
1319      *h = _elm_config->finger_size * times_h;
1320 }
1321
1322 EAPI void
1323 elm_all_flush(void)
1324 {
1325    const Eina_List *l;
1326    Evas_Object *obj;
1327
1328    edje_file_cache_flush();
1329    edje_collection_cache_flush();
1330    eet_clearcache();
1331    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1332      {
1333         Evas *e = evas_object_evas_get(obj);
1334         evas_image_cache_flush(e);
1335         evas_font_cache_flush(e);
1336         evas_render_dump(e);
1337      }
1338 }
1339
1340 EAPI int
1341 elm_cache_flush_interval_get(void)
1342 {
1343    return _elm_config->cache_flush_poll_interval;
1344 }
1345
1346 EAPI void
1347 elm_cache_flush_interval_set(int size)
1348 {
1349    if (_elm_config->cache_flush_poll_interval == size) return;
1350    _elm_config->cache_flush_poll_interval = size;
1351
1352    _elm_recache();
1353 }
1354
1355 EAPI void
1356 elm_cache_flush_interval_all_set(int size)
1357 {
1358    elm_cache_flush_interval_set(size);
1359    _elm_config_all_update();
1360 }
1361
1362 EAPI Eina_Bool
1363 elm_cache_flush_enabled_get(void)
1364 {
1365    return _elm_config->cache_flush_enable;
1366 }
1367
1368 EAPI void
1369 elm_cache_flush_enabled_set(Eina_Bool enabled)
1370 {
1371    enabled = !!enabled;
1372    if (_elm_config->cache_flush_enable == enabled) return;
1373    _elm_config->cache_flush_enable = enabled;
1374
1375    _elm_recache();
1376 }
1377
1378 EAPI void
1379 elm_cache_flush_enabled_all_set(Eina_Bool enabled)
1380 {
1381    elm_cache_flush_enabled_set(enabled);
1382    _elm_config_all_update();
1383 }
1384
1385 EAPI int
1386 elm_font_cache_get(void)
1387 {
1388    return _elm_config->font_cache;
1389 }
1390
1391 EAPI void
1392 elm_font_cache_set(int size)
1393 {
1394    if (_elm_config->font_cache == size) return;
1395    _elm_config->font_cache = size;
1396
1397    _elm_recache();
1398 }
1399
1400 EAPI void
1401 elm_font_cache_all_set(int size)
1402 {
1403    elm_font_cache_set(size);
1404    _elm_config_all_update();
1405 }
1406
1407 EAPI int
1408 elm_image_cache_get(void)
1409 {
1410    return _elm_config->image_cache;
1411 }
1412
1413 EAPI void
1414 elm_image_cache_set(int size)
1415 {
1416    if (_elm_config->image_cache == size) return;
1417    _elm_config->image_cache = size;
1418
1419    _elm_recache();
1420 }
1421
1422 EAPI void
1423 elm_image_cache_all_set(int size)
1424 {
1425    elm_image_cache_set(size);
1426    _elm_config_all_update();
1427 }
1428
1429 EAPI int
1430 elm_edje_file_cache_get(void)
1431 {
1432    return _elm_config->edje_cache;
1433 }
1434
1435 EAPI void
1436 elm_edje_file_cache_set(int size)
1437 {
1438    if (_elm_config->edje_cache == size) return;
1439    _elm_config->edje_cache = size;
1440
1441    _elm_recache();
1442 }
1443
1444 EAPI void
1445 elm_edje_file_cache_all_set(int size)
1446 {
1447    elm_edje_file_cache_set(size);
1448    _elm_config_all_update();
1449 }
1450
1451 EAPI int
1452 elm_edje_collection_cache_get(void)
1453 {
1454    return _elm_config->edje_collection_cache;
1455 }
1456
1457 EAPI void
1458 elm_edje_collection_cache_set(int size)
1459 {
1460    if (_elm_config->edje_collection_cache == size) return;
1461    _elm_config->edje_collection_cache = size;
1462
1463    _elm_recache();
1464 }
1465
1466 EAPI void
1467 elm_edje_collection_cache_all_set(int size)
1468 {
1469    elm_edje_collection_cache_set(size);
1470    _elm_config_all_update();
1471 }
1472
1473 EAPI Eina_Bool
1474 elm_object_focus_get(const Evas_Object *obj)
1475 {
1476    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1477    return elm_widget_focus_get(obj);
1478 }
1479
1480 EAPI void
1481 elm_object_focus_set(Evas_Object *obj,
1482                      Eina_Bool    focus)
1483 {
1484    EINA_SAFETY_ON_NULL_RETURN(obj);
1485    if (focus)
1486      {
1487         if (elm_widget_focus_get(obj)) return;
1488         elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1489      }
1490    else
1491      {
1492         if (!elm_widget_can_focus_get(obj)) return;
1493         elm_widget_focused_object_clear(obj);
1494      }
1495 }
1496
1497 EAPI void
1498 elm_object_focus(Evas_Object *obj)
1499 {
1500    EINA_SAFETY_ON_NULL_RETURN(obj);
1501    elm_object_focus_set(obj, EINA_TRUE);
1502 }
1503
1504 EAPI void
1505 elm_object_unfocus(Evas_Object *obj)
1506 {
1507    EINA_SAFETY_ON_NULL_RETURN(obj);
1508    elm_object_focus_set(obj, EINA_FALSE);
1509 }
1510
1511 EAPI void
1512 elm_object_focus_allow_set(Evas_Object *obj,
1513                            Eina_Bool    enable)
1514 {
1515    EINA_SAFETY_ON_NULL_RETURN(obj);
1516    elm_widget_can_focus_set(obj, enable);
1517 }
1518
1519 EAPI Eina_Bool
1520 elm_object_focus_allow_get(const Evas_Object *obj)
1521 {
1522    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1523    return (elm_widget_can_focus_get(obj)) || (elm_widget_child_can_focus_get(obj));
1524 }
1525
1526 EAPI void
1527 elm_object_focus_custom_chain_set(Evas_Object *obj,
1528                                   Eina_List   *objs)
1529 {
1530    EINA_SAFETY_ON_NULL_RETURN(obj);
1531    elm_widget_focus_custom_chain_set(obj, objs);
1532 }
1533
1534 EAPI void
1535 elm_object_focus_custom_chain_unset(Evas_Object *obj)
1536 {
1537    EINA_SAFETY_ON_NULL_RETURN(obj);
1538    elm_widget_focus_custom_chain_unset(obj);
1539 }
1540
1541 EAPI const Eina_List *
1542 elm_object_focus_custom_chain_get(const Evas_Object *obj)
1543 {
1544    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1545    return elm_widget_focus_custom_chain_get(obj);
1546 }
1547
1548 EAPI void
1549 elm_object_focus_custom_chain_append(Evas_Object *obj,
1550                                      Evas_Object *child,
1551                                      Evas_Object *relative_child)
1552 {
1553    EINA_SAFETY_ON_NULL_RETURN(obj);
1554    EINA_SAFETY_ON_NULL_RETURN(child);
1555    elm_widget_focus_custom_chain_append(obj, child, relative_child);
1556 }
1557
1558 EAPI void
1559 elm_object_focus_custom_chain_prepend(Evas_Object *obj,
1560                                       Evas_Object *child,
1561                                       Evas_Object *relative_child)
1562 {
1563    EINA_SAFETY_ON_NULL_RETURN(obj);
1564    EINA_SAFETY_ON_NULL_RETURN(child);
1565    elm_widget_focus_custom_chain_prepend(obj, child, relative_child);
1566 }
1567
1568 EAPI void
1569 elm_object_focus_cycle(Evas_Object        *obj,
1570                        Elm_Focus_Direction dir)
1571 {
1572    EINA_SAFETY_ON_NULL_RETURN(obj);
1573    elm_widget_focus_cycle(obj, dir);
1574 }
1575
1576 EAPI void
1577 elm_object_focus_direction_go(Evas_Object *obj,
1578                               int          x,
1579                               int          y)
1580 {
1581    EINA_SAFETY_ON_NULL_RETURN(obj);
1582    elm_widget_focus_direction_go(obj, x, y);
1583 }
1584
1585 EAPI void
1586 elm_object_tree_unfocusable_set(Evas_Object *obj,
1587                                 Eina_Bool    tree_unfocusable)
1588 {
1589    EINA_SAFETY_ON_NULL_RETURN(obj);
1590    elm_widget_tree_unfocusable_set(obj, tree_unfocusable);
1591 }
1592
1593 EAPI Eina_Bool
1594 elm_object_tree_unfocusable_get(const Evas_Object *obj)
1595 {
1596    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1597    return elm_widget_tree_unfocusable_get(obj);
1598 }
1599
1600 EAPI Eina_Bool
1601 elm_focus_highlight_enabled_get(void)
1602 {
1603    return _elm_config->focus_highlight_enable;
1604 }
1605
1606 EAPI void
1607 elm_focus_highlight_enabled_set(Eina_Bool enable)
1608 {
1609    _elm_config->focus_highlight_enable = !!enable;
1610 }
1611
1612 EAPI Eina_Bool
1613 elm_focus_highlight_animate_get(void)
1614 {
1615    return _elm_config->focus_highlight_animate;
1616 }
1617
1618 EAPI void
1619 elm_focus_highlight_animate_set(Eina_Bool animate)
1620 {
1621    _elm_config->focus_highlight_animate = !!animate;
1622 }
1623
1624 EAPI Eina_Bool
1625 elm_scroll_bounce_enabled_get(void)
1626 {
1627    return _elm_config->thumbscroll_bounce_enable;
1628 }
1629
1630 EAPI void
1631 elm_scroll_bounce_enabled_set(Eina_Bool enabled)
1632 {
1633    _elm_config->thumbscroll_bounce_enable = enabled;
1634 }
1635
1636 EAPI void
1637 elm_scroll_bounce_enabled_all_set(Eina_Bool enabled)
1638 {
1639    elm_scroll_bounce_enabled_set(enabled);
1640    _elm_config_all_update();
1641 }
1642
1643 EAPI double
1644 elm_scroll_bounce_friction_get(void)
1645 {
1646    return _elm_config->thumbscroll_bounce_friction;
1647 }
1648
1649 EAPI void
1650 elm_scroll_bounce_friction_set(double friction)
1651 {
1652    _elm_config->thumbscroll_bounce_friction = friction;
1653 }
1654
1655 EAPI void
1656 elm_scroll_bounce_friction_all_set(double friction)
1657 {
1658    elm_scroll_bounce_friction_set(friction);
1659    _elm_config_all_update();
1660 }
1661
1662 EAPI double
1663 elm_scroll_page_scroll_friction_get(void)
1664 {
1665    return _elm_config->page_scroll_friction;
1666 }
1667
1668 EAPI void
1669 elm_scroll_page_scroll_friction_set(double friction)
1670 {
1671    _elm_config->page_scroll_friction = friction;
1672 }
1673
1674 EAPI void
1675 elm_scroll_page_scroll_friction_all_set(double friction)
1676 {
1677    elm_scroll_page_scroll_friction_set(friction);
1678    _elm_config_all_update();
1679 }
1680
1681 EAPI double
1682 elm_scroll_bring_in_scroll_friction_get(void)
1683 {
1684    return _elm_config->bring_in_scroll_friction;
1685 }
1686
1687 EAPI void
1688 elm_scroll_bring_in_scroll_friction_set(double friction)
1689 {
1690    _elm_config->bring_in_scroll_friction = friction;
1691 }
1692
1693 EAPI void
1694 elm_scroll_bring_in_scroll_friction_all_set(double friction)
1695 {
1696    elm_scroll_bring_in_scroll_friction_set(friction);
1697    _elm_config_all_update();
1698 }
1699
1700 EAPI double
1701 elm_scroll_zoom_friction_get(void)
1702 {
1703    return _elm_config->zoom_friction;
1704 }
1705
1706 EAPI void
1707 elm_scroll_zoom_friction_set(double friction)
1708 {
1709    _elm_config->zoom_friction = friction;
1710 }
1711
1712 EAPI void
1713 elm_scroll_zoom_friction_all_set(double friction)
1714 {
1715    elm_scroll_zoom_friction_set(friction);
1716    _elm_config_all_update();
1717 }
1718
1719 EAPI Eina_Bool
1720 elm_scroll_thumbscroll_enabled_get(void)
1721 {
1722    return _elm_config->thumbscroll_enable;
1723 }
1724
1725 EAPI void
1726 elm_scroll_thumbscroll_enabled_set(Eina_Bool enabled)
1727 {
1728    _elm_config->thumbscroll_enable = enabled;
1729 }
1730
1731 EAPI void
1732 elm_scroll_thumbscroll_enabled_all_set(Eina_Bool enabled)
1733 {
1734    elm_scroll_thumbscroll_enabled_set(enabled);
1735    _elm_config_all_update();
1736 }
1737
1738 EAPI unsigned int
1739 elm_scroll_thumbscroll_threshold_get(void)
1740 {
1741    return _elm_config->thumbscroll_threshold;
1742 }
1743
1744 EAPI void
1745 elm_scroll_thumbscroll_threshold_set(unsigned int threshold)
1746 {
1747    _elm_config->thumbscroll_threshold = threshold;
1748 }
1749
1750 EAPI void
1751 elm_scroll_thumbscroll_threshold_all_set(unsigned int threshold)
1752 {
1753    elm_scroll_thumbscroll_threshold_set(threshold);
1754    _elm_config_all_update();
1755 }
1756
1757 EAPI double
1758 elm_scroll_thumbscroll_momentum_threshold_get(void)
1759 {
1760    return _elm_config->thumbscroll_momentum_threshold;
1761 }
1762
1763 EAPI void
1764 elm_scroll_thumbscroll_momentum_threshold_set(double threshold)
1765 {
1766    _elm_config->thumbscroll_momentum_threshold = threshold;
1767 }
1768
1769 EAPI void
1770 elm_scroll_thumbscroll_momentum_threshold_all_set(double threshold)
1771 {
1772    elm_scroll_thumbscroll_momentum_threshold_set(threshold);
1773    _elm_config_all_update();
1774 }
1775
1776 EAPI double
1777 elm_scroll_thumbscroll_friction_get(void)
1778 {
1779    return _elm_config->thumbscroll_friction;
1780 }
1781
1782 EAPI void
1783 elm_scroll_thumbscroll_friction_set(double friction)
1784 {
1785    _elm_config->thumbscroll_friction = friction;
1786 }
1787
1788 EAPI void
1789 elm_scroll_thumbscroll_friction_all_set(double friction)
1790 {
1791    elm_scroll_thumbscroll_friction_set(friction);
1792    _elm_config_all_update();
1793 }
1794
1795 EAPI double
1796 elm_scroll_thumbscroll_border_friction_get(void)
1797 {
1798    return _elm_config->thumbscroll_border_friction;
1799 }
1800
1801 EAPI void
1802 elm_scroll_thumbscroll_border_friction_set(double friction)
1803 {
1804    if (friction < 0.0) friction = 0.0;
1805    if (friction > 1.0) friction = 1.0;
1806    _elm_config->thumbscroll_friction = friction;
1807 }
1808
1809 EAPI void
1810 elm_scroll_thumbscroll_border_friction_all_set(double friction)
1811 {
1812    elm_scroll_thumbscroll_border_friction_set(friction);
1813    _elm_config_all_update();
1814 }
1815
1816 EAPI double
1817 elm_scroll_thumbscroll_sensitivity_friction_get(void)
1818 {
1819    return _elm_config->thumbscroll_sensitivity_friction;
1820 }
1821
1822 EAPI void
1823 elm_scroll_thumbscroll_sensitivity_friction_set(double friction)
1824 {
1825    if (friction < 0.1) friction = 0.1;
1826    if (friction > 1.0) friction = 1.0;
1827    _elm_config->thumbscroll_friction = friction;
1828 }
1829
1830 EAPI void
1831 elm_scroll_thumbscroll_sensitivity_friction_all_set(double friction)
1832 {
1833    elm_scroll_thumbscroll_sensitivity_friction_set(friction);
1834    _elm_config_all_update();
1835 }
1836
1837 EAPI void
1838 elm_object_scroll_hold_push(Evas_Object *obj)
1839 {
1840    EINA_SAFETY_ON_NULL_RETURN(obj);
1841    elm_widget_scroll_hold_push(obj);
1842 }
1843
1844 EAPI void
1845 elm_object_scroll_hold_pop(Evas_Object *obj)
1846 {
1847    EINA_SAFETY_ON_NULL_RETURN(obj);
1848    elm_widget_scroll_hold_pop(obj);
1849 }
1850
1851 EAPI void
1852 elm_object_scroll_freeze_push(Evas_Object *obj)
1853 {
1854    EINA_SAFETY_ON_NULL_RETURN(obj);
1855    elm_widget_scroll_freeze_push(obj);
1856 }
1857
1858 EAPI void
1859 elm_object_scroll_lock_x_set(Evas_Object *obj,
1860                              Eina_Bool    lock)
1861 {
1862    EINA_SAFETY_ON_NULL_RETURN(obj);
1863    elm_widget_drag_lock_x_set(obj, lock);
1864 }
1865
1866 EAPI void
1867 elm_object_scroll_lock_y_set(Evas_Object *obj,
1868                              Eina_Bool    lock)
1869 {
1870    EINA_SAFETY_ON_NULL_RETURN(obj);
1871    elm_widget_drag_lock_y_set(obj, lock);
1872 }
1873
1874 EAPI Eina_Bool
1875 elm_object_scroll_lock_x_get(const Evas_Object *obj)
1876 {
1877    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1878    return elm_widget_drag_lock_x_get(obj);
1879 }
1880
1881 EAPI Eina_Bool
1882 elm_object_scroll_lock_y_get(const Evas_Object *obj)
1883 {
1884    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1885    return elm_widget_drag_lock_y_get(obj);
1886 }
1887
1888 EAPI void
1889 elm_object_scroll_freeze_pop(Evas_Object *obj)
1890 {
1891    EINA_SAFETY_ON_NULL_RETURN(obj);
1892    elm_widget_scroll_freeze_pop(obj);
1893 }
1894
1895 EAPI Eina_Bool
1896 elm_object_widget_check(const Evas_Object *obj)
1897 {
1898    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
1899    return elm_widget_is(obj);
1900 }
1901
1902 EAPI Evas_Object *
1903 elm_object_parent_widget_get(const Evas_Object *obj)
1904 {
1905    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1906    return elm_widget_parent_widget_get(obj);
1907 }
1908
1909 EAPI Evas_Object *
1910 elm_object_top_widget_get(const Evas_Object *obj)
1911 {
1912    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1913    return elm_widget_top_get(obj);
1914 }
1915
1916 EAPI const char *
1917 elm_object_widget_type_get(const Evas_Object *obj)
1918 {
1919    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1920    return elm_widget_type_get(obj);
1921 }
1922
1923 EAPI void
1924 elm_object_signal_emit(Evas_Object *obj,
1925                        const char  *emission,
1926                        const char  *source)
1927 {
1928    EINA_SAFETY_ON_NULL_RETURN(obj);
1929    elm_widget_signal_emit(obj, emission, source);
1930 }
1931
1932 EAPI void
1933 elm_object_signal_callback_add(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func, void *data)
1934 {
1935     EINA_SAFETY_ON_NULL_RETURN(obj);
1936     EINA_SAFETY_ON_NULL_RETURN(func);
1937     elm_widget_signal_callback_add(obj, emission, source, func, data);
1938 }
1939
1940 EAPI void *
1941 elm_object_signal_callback_del(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func)
1942 {
1943     EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1944     EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1945     return elm_widget_signal_callback_del(obj, emission, source, func);
1946 }
1947
1948 EAPI void
1949 elm_object_event_callback_add(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1950 {
1951    EINA_SAFETY_ON_NULL_RETURN(obj);
1952    EINA_SAFETY_ON_NULL_RETURN(func);
1953    elm_widget_event_callback_add(obj, func, data);
1954 }
1955
1956 EAPI void *
1957 elm_object_event_callback_del(Evas_Object *obj, Elm_Event_Cb func, const void *data)
1958 {
1959    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
1960    EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
1961    return elm_widget_event_callback_del(obj, func, data);
1962 }
1963
1964 EAPI void
1965 elm_object_tree_dump(const Evas_Object *top)
1966 {
1967 #ifdef ELM_DEBUG
1968    elm_widget_tree_dump(top);
1969 #else
1970    return;
1971    (void)top;
1972 #endif
1973 }
1974
1975 EAPI void
1976 elm_object_tree_dot_dump(const Evas_Object *top,
1977                          const char        *file)
1978 {
1979 #ifdef ELM_DEBUG
1980    FILE *f = fopen(file, "wb");
1981    elm_widget_tree_dot_dump(top, f);
1982    fclose(f);
1983 #else
1984    return;
1985    (void)top;
1986    (void)file;
1987 #endif
1988 }
1989
1990 EAPI void
1991 elm_longpress_timeout_set(double longpress_timeout)
1992 {
1993    _elm_config->longpress_timeout = longpress_timeout;
1994 }
1995
1996 EAPI double
1997 elm_longpress_timeout_get(void)
1998 {
1999    return _elm_config->longpress_timeout;
2000 }
2001
2002 EAPI Evas_Object *
2003 elm_object_item_object_get(const Elm_Object_Item *it)
2004 {
2005    return ((Elm_Widget_Item *) it)->widget;
2006 }
2007
2008 EAPI void
2009 elm_object_item_content_part_set(Elm_Object_Item *it,
2010                                  const char *part,
2011                                  Evas_Object *content)
2012 {
2013    _elm_widget_item_content_part_set((Elm_Widget_Item *) it, part, content);
2014 }
2015
2016 EAPI Evas_Object *
2017 elm_object_item_content_part_get(const Elm_Object_Item *it,
2018                                  const char *part)
2019 {
2020    return _elm_widget_item_content_part_get((Elm_Widget_Item *) it, part);
2021 }
2022
2023 EAPI Evas_Object *
2024 elm_object_item_content_part_unset(Elm_Object_Item *it, const char *part)
2025 {
2026    return _elm_widget_item_content_part_unset((Elm_Widget_Item *) it, part);
2027 }
2028
2029 EAPI void
2030 elm_object_item_text_part_set(Elm_Object_Item *it,
2031                               const char *part,
2032                               const char *label)
2033 {
2034    _elm_widget_item_text_part_set((Elm_Widget_Item *) it, part, label);
2035 }
2036
2037 EAPI const char *
2038 elm_object_item_text_part_get(const Elm_Object_Item *it, const char *part)
2039 {
2040    return _elm_widget_item_text_part_get((Elm_Widget_Item *) it, part);
2041 }
2042
2043 EAPI void
2044 elm_object_access_info_set(Evas_Object *obj, const char *txt)
2045 {
2046    elm_widget_access_info_set(obj, txt);
2047 }
2048
2049 EAPI void
2050 elm_object_item_access_info_set(Elm_Object_Item *it, const char *txt)
2051 {
2052    _elm_widget_item_access_info_set((Elm_Widget_Item *) it, txt);
2053 }
2054
2055 EAPI void *
2056 elm_object_item_data_get(const Elm_Object_Item *it)
2057 {
2058    return elm_widget_item_data_get(it);
2059 }
2060
2061 EAPI void
2062 elm_object_item_data_set(Elm_Object_Item *it, void *data)
2063 {
2064    elm_widget_item_data_set(it, data);
2065 }
2066
2067 EAPI void
2068 elm_object_item_signal_emit(Elm_Object_Item *it, const char *emission, const char *source)
2069 {
2070    _elm_widget_item_signal_emit((Elm_Widget_Item *) it, emission, source);
2071 }
2072
2073 EAPI void elm_object_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
2074 {
2075    _elm_widget_item_disabled_set((Elm_Widget_Item *) it, disabled);
2076 }
2077
2078 EAPI Eina_Bool elm_object_item_disabled_get(const Elm_Object_Item *it)
2079 {
2080    return _elm_widget_item_disabled_get((Elm_Widget_Item *) it);
2081 }
2082