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