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