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