2 # include "elementary_config.h"
9 #include <dlfcn.h> /* dlopen,dlclose,etc */
11 #ifdef HAVE_CRT_EXTERNS_H
12 # include <crt_externs.h>
19 #include <Elementary.h>
22 #define SEMI_BROKEN_QUICKLAUNCH 1
24 static Elm_Version _version = { VMAJ, VMIN, VMIC, VREV };
25 EAPI Elm_Version *elm_version = &_version;
30 * This group includes functions of elm_main.c
35 _elm_dangerous_call_check(const char *call)
40 snprintf(buf, sizeof(buf), "%i.%i.%i.%i", VMAJ, VMIN, VMIC, VREV);
41 eval = getenv("ELM_NO_FINGER_WAGGLING");
42 if ((eval) && (!strcmp(eval, buf)))
44 printf("ELEMENTARY FINGER WAGGLE!!!!!!!!!!\n"
47 "PLEASE see the API documentation for this function. This call\n"
48 "should almost never be used. Only in very special cases.\n"
50 "To remove this warning please set the environment variable:\n"
51 " ELM_NO_FINGER_WAGGLING\n"
52 "To the value of the Elementary version + revision number. e.g.:\n"
61 * @defgroup Start Getting Started
64 * To write an Elementary app, you can get started with the following:
67 * #include <Elementary.h>
68 * #ifndef ELM_LIB_QUICKLAUNCH
70 * elm_main(int argc, char **argv)
72 * // create window(s) here and do any application init
73 * elm_run(); // run main loop
74 * elm_shutdown(); // after mainloop finishes running, shutdown
75 * return 0; // exit 0 for exit code
81 * To take full advantage of the quicklaunch architecture for launching
82 * processes as quickly as possible (saving time at startup time like
83 * connecting to X11, loading and linking shared libraries) you may want to
84 * use the following configure.in/configure.ac and Makefile.am and autogen.sh
85 * script to generate your files. It is assumed your application uses the
86 * main.c file for its code.
88 * configure.in/configure.ac:
91 AC_INIT(myapp, 0.0.0, myname@mydomain.com)
93 AC_CONFIG_SRCDIR(configure.in)
95 AM_INIT_AUTOMAKE(1.6 dist-bzip2)
96 AM_CONFIG_HEADER(config.h)
106 define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl
107 define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
110 PKG_CHECK_MODULES([ELEMENTARY], elementary)
118 AUTOMAKE_OPTIONS = 1.4 foreign
119 MAINTAINERCLEANFILES = Makefile.in
121 INCLUDES = -I$(top_srcdir) @ELEMENTARY_CFLAGS@
124 myapp_LTLIBRARIES = myapp.la
128 myapp_la_SOURCES = main.c
129 myapp_la_LIBADD = @ELEMENTARY_LIBS@
131 myapp_la_LDFLAGS = -module -avoid-version -no-undefined
133 myapp_SOURCES = main.c
134 myapp_LDADD = @ELEMENTARY_LIBS@
135 myapp_CFLAGS = -DELM_LIB_QUICKLAUNCH=1
142 rm -rf autom4te.cache
143 rm -f aclocal.m4 ltmain.sh
148 echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
149 echo "Running autoheader..." ; autoheader || exit 1
150 echo "Running autoconf..." ; autoconf || exit 1
151 echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
152 echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
154 if [ -z "$NOCONFIGURE" ]; then
159 * To gnerate all the things needed to bootstrap just run:
165 * This will generate Makefile.in's, the confgure script and everything else.
166 * After this it works like all normal autotools projects:
173 * Note sudo was assumed to get root permissions, as this would install in
174 * /usr/local which is system-owned. Ue any way you like to gain root, or
175 * specify a different prefix with configure:
178 ./confiugre --prefix=$HOME/mysoftware
181 * Also remember that autotools buys you some useful commands like:
186 * This uninstalls the software after it was installed with "make install".
187 * It is very useful to clear up what you built if you wish to clean the
194 * This firstly checks if your build tree is "clean" and ready for
195 * distribution. It also builds a tarball (myapp-0.0.0.tar.gz) that is
196 * ready to upload and distribute to the world, that contains the generated
197 * Makefile.in's and configure script. The users do not need to run
198 * autogen.sh - just configure and on. They don't need autotools installed.
199 * This tarball also builds cleanly, has all the sources it needs to build
200 * included (that is sources for your application, not libraries it depends
201 * on like Elementary). It builds cleanly in a buildroot and does not
202 * contain any files that are temporarily generated like binaries and other
203 * build-gnerated files, so the tarball is clean, and no need to worry
204 * about cleaning up your tree before packaging.
210 * This cleans up all build files (binaries, objects etc.) from the tree.
216 * This cleans out all files from the build and from configure's output too.
219 make maintainer-clean
222 * This deletes all the files autogen.sh will produce so the tree is clean
223 * to be put into a revision-control system (like CVS, SVN or GIT for example).
225 * The above will build a library - libmyapp.so and install in the target
226 * library directory (default is /usr/local/lib). You will also get a
227 * myapp.a and myapp.la - these are useless and can be deleted. Libtool likes
228 * to generate these all the time. You will also get a binary in the target
229 * binary directory (default is /usr/local/bin). This is a "debug binary".
230 * This will run and dlopen() the myapp.so and then jump to it's elm_main
231 * function. This allows for easy debugging with GDB and Valgrind. When you
232 * are ready to go to production do the following:
234 * 1. delete the myapp binary. i.e. rm /usr/local/bin/myapp
236 * 2. symlink the myapp binary to elementary_run (supplied by elementary).
237 * i.e. ln -s elmentary_run /usr/local/bin/myapp
239 * 3. run elementary_quicklaunch as part of your graphical login session and
242 * This will man elementary_quicklaunch does pre-initialization before the
243 * application needs to be run, saving the effort at the time the application
244 * is needed, thus speeding up the time it takes to appear.
246 * If you don't want to use the quicklaunch infrastructure (which is
247 * optional), you can execute the old fashioned way by just running the
248 * myapp binary loader than will load the myapp.so for you, or you can
249 * remove the split-file binary and put it into one binary as things always
250 * have been with the following configure.in/configure.ac and Makfile.am
253 * configure.in/configure.ac:
256 AC_INIT(myapp, 0.0.0, myname@mydomain.com)
258 AC_CONFIG_SRCDIR(configure.in)
260 AM_INIT_AUTOMAKE(1.6 dist-bzip2)
261 AM_CONFIG_HEADER(config.h)
270 PKG_CHECK_MODULES([ELEMENTARY], elementary)
278 AUTOMAKE_OPTIONS = 1.4 foreign
279 MAINTAINERCLEANFILES = Makefile.in
281 INCLUDES = -I$(top_srcdir) @ELEMENTARY_CFLAGS@
285 myapp_SOURCES = main.c
286 myapp_LDADD = @ELEMENTARY_LIBS@
290 * Notice that they are the same as before, just with libtool and library
291 * building sections removed. Both ways work for building elementary
292 * applications. It is up to you to decide what is best for you. If you just
293 * follow the template above, you can do it both ways and can decide at build
294 * time. The more advanced of you may suggest making it a configure option.
295 * That is perfectly valid, but has been left out here for simplicity, as our
296 * aim to have an Elementary (and EFL) tutorial, not an autoconf & automake
301 static Eina_Bool _elm_signal_exit(void *data, int ev_type, void *ev);
303 char *_elm_appname = NULL;
304 const char *_elm_data_dir = NULL;
305 const char *_elm_lib_dir = NULL;
306 int _elm_log_dom = -1;
308 EAPI int ELM_EVENT_POLICY_CHANGED = 0;
310 static int _elm_init_count = 0;
311 static int _elm_sub_init_count = 0;
312 static int _elm_ql_init_count = 0;
313 static int _elm_policies[ELM_POLICY_LAST];
314 static Ecore_Event_Handler *_elm_exit_handler = NULL;
315 static Eina_Bool quicklaunch_on = 0;
318 _elm_signal_exit(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__)
321 return ECORE_CALLBACK_PASS_ON;
327 edje_scale_set(_elm_config->scale);
331 static Eina_List *widtypes = NULL;
334 _elm_widtype_register(const char **ptr)
336 widtypes = eina_list_append(widtypes, (void *)ptr);
340 _elm_widtype_clear(void)
344 EINA_LIST_FREE(widtypes, ptr)
346 eina_stringshare_del(*ptr);
352 * @defgroup General General
357 * Inititalise Elementary
359 * @return The init counter value.
361 * This call is exported only for use by the ELM_MAIN() macro. There is no
362 * need to use this if you use this macro (which is highly advisable).
366 elm_init(int argc, char **argv)
369 if (_elm_init_count > 1) return _elm_init_count;
370 elm_quicklaunch_init(argc, argv);
371 elm_quicklaunch_sub_init(argc, argv);
372 return _elm_init_count;
376 * Shut down Elementary
378 * This should be called at the end of your application just before it ceases
379 * to do any more processing. This will clean up any permanent resources your
380 * application may have allocated via Elementary that would otherwise persist
381 * on an exit without this call.
388 if (_elm_init_count > 0) return _elm_init_count;
389 elm_quicklaunch_sub_shutdown();
390 elm_quicklaunch_shutdown();
391 return _elm_init_count;
395 static Eina_Bool _elm_need_e_dbus = EINA_FALSE;
398 elm_need_e_dbus(void)
401 if (_elm_need_e_dbus) return;
402 _elm_need_e_dbus = 1;
409 _elm_unneed_e_dbus(void)
412 if (_elm_need_e_dbus)
414 _elm_need_e_dbus = 0;
422 static Eina_Bool _elm_need_efreet = EINA_FALSE;
425 elm_need_efreet(void)
428 if (_elm_need_efreet) return;
429 _elm_need_efreet = 1;
437 list = efreet_icon_extra_list_get();
440 e_user_dir_concat_static(buf, "icons");
441 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
442 e_prefix_data_concat_static(buf, "data/icons");
443 *list = eina_list_prepend(*list, (void *)eina_stringshare_add(buf));
451 _elm_unneed_efreet(void)
454 if (_elm_need_efreet)
456 _elm_need_efreet = 0;
457 efreet_trash_shutdown();
458 efreet_mime_shutdown();
465 elm_quicklaunch_mode_set(Eina_Bool ql_on)
467 quicklaunch_on = ql_on;
471 elm_quicklaunch_init(int argc, char **argv)
473 char buf[PATH_MAX], *s;
475 _elm_ql_init_count++;
476 if (_elm_ql_init_count > 1) return _elm_ql_init_count;
478 _elm_log_dom = eina_log_domain_register("elementary", EINA_COLOR_LIGHTBLUE);
481 EINA_LOG_ERR("could not register elementary log domain.");
482 _elm_log_dom = EINA_LOG_DOMAIN_GLOBAL;
487 ecore_app_args_set(argc, (const char **)argv);
489 memset(_elm_policies, 0, sizeof(_elm_policies));
490 if (ELM_EVENT_POLICY_CHANGED == 0)
491 ELM_EVENT_POLICY_CHANGED = ecore_event_type_new();
495 _elm_exit_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, NULL);
497 if (argv) _elm_appname = strdup(ecore_file_file_get(argv[0]));
501 s = getenv("ELM_DATA_DIR");
502 _elm_data_dir = eina_stringshare_add(s);
506 s = getenv("ELM_PREFIX");
509 snprintf(buf, sizeof(buf), "%s/share/elementary", s);
510 _elm_data_dir = eina_stringshare_add(buf);
515 s = getenv("ELM_LIB_DIR");
516 _elm_lib_dir = eina_stringshare_add(s);
520 s = getenv("ELM_PREFIX");
523 snprintf(buf, sizeof(buf), "%s/lib", s);
524 _elm_lib_dir = eina_stringshare_add(buf);
528 if ((!_elm_data_dir) || (!_elm_lib_dir))
530 Dl_info elementary_dl;
531 // libelementary.so/../../share/elementary/
532 if (dladdr(elm_init, &elementary_dl))
536 dir = ecore_file_dir_get(elementary_dl.dli_fname);
541 if (ecore_file_is_dir(dir))
542 _elm_lib_dir = eina_stringshare_add(dir);
546 dir2 = ecore_file_dir_get(dir);
549 snprintf(buf, sizeof(buf), "%s/share/elementary", dir2);
550 if (ecore_file_is_dir(buf))
551 _elm_data_dir = eina_stringshare_add(buf);
561 _elm_data_dir = eina_stringshare_add(PACKAGE_DATA_DIR);
563 _elm_data_dir = eina_stringshare_add("/");
565 _elm_lib_dir = eina_stringshare_add(PACKAGE_LIB_DIR);
567 _elm_lib_dir = eina_stringshare_add("/");
570 return _elm_ql_init_count;
574 elm_quicklaunch_sub_init(int argc, char **argv)
576 _elm_sub_init_count++;
577 if (_elm_sub_init_count > 1) return _elm_sub_init_count;
580 #ifdef SEMI_BROKEN_QUICKLAUNCH
581 return _elm_sub_init_count;
586 ecore_app_args_set(argc, (const char **)argv);
590 _elm_config_sub_init();
591 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
592 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
593 (_elm_config->engine == ELM_XRENDER_X11) ||
594 (_elm_config->engine == ELM_OPENGL_X11))
596 #ifdef HAVE_ELEMENTARY_X
600 ecore_evas_init(); // FIXME: check errors
604 return _elm_sub_init_count;
608 elm_quicklaunch_sub_shutdown(void)
610 _elm_sub_init_count--;
611 if (_elm_sub_init_count > 0) return _elm_sub_init_count;
614 #ifdef SEMI_BROKEN_QUICKLAUNCH
615 return _elm_sub_init_count;
621 _elm_module_shutdown();
622 ecore_imf_shutdown();
623 ecore_evas_shutdown();
624 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
625 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
626 (_elm_config->engine == ELM_XRENDER_X11) ||
627 (_elm_config->engine == ELM_OPENGL_X11))
629 #ifdef HAVE_ELEMENTARY_X
630 ecore_x_disconnect();
633 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
634 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
635 (_elm_config->engine == ELM_XRENDER_X11) ||
636 (_elm_config->engine == ELM_OPENGL_X11) ||
637 (_elm_config->engine == ELM_SOFTWARE_SDL) ||
638 (_elm_config->engine == ELM_SOFTWARE_16_SDL) ||
639 (_elm_config->engine == ELM_OPENGL_SDL) ||
640 (_elm_config->engine == ELM_SOFTWARE_WIN32) ||
641 (_elm_config->engine == ELM_SOFTWARE_16_WINCE))
642 evas_cserve_disconnect();
646 return _elm_sub_init_count;
650 elm_quicklaunch_shutdown(void)
652 _elm_ql_init_count--;
653 if (_elm_ql_init_count > 0) return _elm_ql_init_count;
654 eina_stringshare_del(_elm_data_dir);
655 _elm_data_dir = NULL;
656 eina_stringshare_del(_elm_lib_dir);
662 _elm_config_shutdown();
664 ecore_event_handler_del(_elm_exit_handler);
665 _elm_exit_handler = NULL;
667 _elm_theme_shutdown();
668 _elm_unneed_efreet();
669 _elm_unneed_e_dbus();
670 _elm_unneed_ethumb();
671 ecore_file_shutdown();
675 if ((_elm_log_dom > -1) && (_elm_log_dom != EINA_LOG_DOMAIN_GLOBAL))
677 eina_log_domain_unregister(_elm_log_dom);
681 _elm_widtype_clear();
684 return _elm_ql_init_count;
688 elm_quicklaunch_seed(void)
690 #ifndef SEMI_BROKEN_QUICKLAUNCH
693 Evas_Object *win, *bg, *bt;
695 win = elm_win_add(NULL, "seed", ELM_WIN_BASIC);
696 bg = elm_bg_add(win);
697 elm_win_resize_object_add(win, bg);
698 evas_object_show(bg);
699 bt = elm_button_add(win);
700 elm_button_label_set(bt, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~-_=+\\|]}[{;:'\",<.>/?");
701 elm_win_resize_object_add(win, bt);
702 ecore_main_loop_iterate();
703 evas_object_del(win);
704 ecore_main_loop_iterate();
705 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
706 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
707 (_elm_config->engine == ELM_XRENDER_X11) ||
708 (_elm_config->engine == ELM_OPENGL_X11))
710 # ifdef HAVE_ELEMENTARY_X
714 ecore_main_loop_iterate();
719 static void *qr_handle = NULL;
720 static int (*qr_main) (int argc, char **argv) = NULL;
723 elm_quicklaunch_prepare(int argc __UNUSED__, char **argv)
726 char *exe = elm_quicklaunch_exe_path_get(argv[0]);
729 ERR("requested quicklaunch binary '%s' does not exist\n", argv[0]);
737 exe2 = malloc(strlen(exe) + 1 + 10);
739 p = strrchr(exe2, '/');
742 exename = alloca(strlen(p) + 1);
745 strcat(p, "../lib/");
748 if (access(exe2, R_OK | X_OK) == 0)
756 qr_handle = dlopen(exe, RTLD_NOW | RTLD_GLOBAL);
759 fprintf(stderr, "dlerr: %s\n", dlerror());
760 WRN("dlopen('%s') failed: %s", exe, dlerror());
764 INF("dlopen('%s') = %p", exe, qr_handle);
766 qr_main = dlsym(qr_handle, "elm_main");
767 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qr_main);
770 WRN("not quicklauncher capable: no elm_main in '%s'", exe);
786 extern char **environ;
791 for (i = 0, size = 0; environ[i]; i++)
792 size += strlen(environ[i]) + 1;
794 p = malloc((i + 1) * sizeof(char *));
799 for (i = 0; oldenv[i]; i++)
800 environ[i] = strdup(oldenv[i]);
806 elm_quicklaunch_fork(int argc, char **argv, char *cwd, void (postfork_func) (void *data), void *postfork_data)
815 // need to accept current environment from elementary_run
822 if (child > 0) return EINA_TRUE;
825 perror("could not fork");
830 perror("could not chdir");
831 args = alloca((argc + 1) * sizeof(char *));
832 for (i = 0; i < argc; i++) args[i] = argv[i];
834 WRN("%s not quicklaunch capable, fallback...", argv[0]);
835 execvp(argv[0], args);
836 ERR("failed to execute '%s': %s", argv[0], strerror(errno));
840 if (child > 0) return EINA_TRUE;
843 perror("could not fork");
846 if (postfork_func) postfork_func(postfork_data);
850 #ifdef SEMI_BROKEN_QUICKLAUNCH
851 ecore_app_args_set(argc, (const char **)argv);
854 _elm_config_sub_init();
855 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
856 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
857 (_elm_config->engine == ELM_XRENDER_X11) ||
858 (_elm_config->engine == ELM_OPENGL_X11))
860 # ifdef HAVE_ELEMENTARY_X
864 ecore_evas_init(); // FIXME: check errors
872 perror("could not chdir");
873 // FIXME: this is very linux specific. it changes argv[0] of the process
874 // so ps etc. report what you'd expect. for other unixes and os's this
881 ecore_app_args_get(&real_argc, &real_argv);
882 lastarg = real_argv[real_argc - 1] + strlen(real_argv[real_argc - 1]);
883 for (p = real_argv[0]; p < lastarg; p++) *p = 0;
884 strcpy(real_argv[0], argv[0]);
886 ecore_app_args_set(argc, (const char **)argv);
887 ret = qr_main(argc, argv);
896 elm_quicklaunch_cleanup(void)
909 elm_quicklaunch_fallback(int argc, char **argv)
912 elm_quicklaunch_init(argc, argv);
913 elm_quicklaunch_sub_init(argc, argv);
914 elm_quicklaunch_prepare(argc, argv);
915 ret = qr_main(argc, argv);
921 elm_quicklaunch_exe_path_get(const char *exe)
923 static char *path = NULL;
924 static Eina_List *pathlist = NULL;
928 if (exe[0] == '/') return strdup(exe);
929 if ((exe[0] == '.') && (exe[1] == '/')) return strdup(exe);
930 if ((exe[0] == '.') && (exe[1] == '.') && (exe[2] == '/')) return strdup(exe);
935 path = getenv("PATH");
936 buf2 = alloca(strlen(path) + 1);
941 if ((*p == ':') || (*p == 0))
946 strncpy(buf2, pp, len);
948 pathlist = eina_list_append(pathlist, eina_stringshare_add(buf2));
960 EINA_LIST_FOREACH(pathlist, l, pathitr)
962 snprintf(buf, sizeof(buf), "%s/%s", pathitr, exe);
963 if (access(buf, R_OK | X_OK) == 0) return strdup(buf);
971 * This call should be called just after all initialization is complete. This
972 * function will not return until elm_exit() is called. It will keep looping
973 * running the main event/processing loop for Elementary.
979 ecore_main_loop_begin();
985 * If this call is called, it will flag the main loop to cease processing and
986 * return back to its parent function.
992 ecore_main_loop_quit();
997 * Set new policy value.
999 * This will emit the ecore event ELM_EVENT_POLICY_CHANGED in the main
1000 * loop giving the event information Elm_Event_Policy_Changed with
1001 * policy identifier, new and old values.
1003 * @param policy policy identifier as in Elm_Policy.
1004 * @param value policy value, depends on identifiers, usually there is
1005 * an enumeration with the same prefix as the policy name, for
1006 * example: ELM_POLICY_QUIT and Elm_Policy_Quit
1007 * (ELM_POLICY_QUIT_NONE, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED).
1009 * @return @c EINA_TRUE on success or @c EINA_FALSE on error (right
1010 * now just invalid policy identifier, but in future policy
1011 * value might be enforced).
1014 elm_policy_set(unsigned int policy, int value)
1016 Elm_Event_Policy_Changed *ev;
1018 if (policy >= ELM_POLICY_LAST)
1021 if (value == _elm_policies[policy])
1024 /* TODO: validade policy? */
1026 ev = malloc(sizeof(*ev));
1027 ev->policy = policy;
1028 ev->new_value = value;
1029 ev->old_value = _elm_policies[policy];
1031 _elm_policies[policy] = value;
1033 ecore_event_add(ELM_EVENT_POLICY_CHANGED, ev, NULL, NULL);
1039 * Gets the policy value set for given identifier.
1041 * @param policy policy identifier as in Elm_Policy.
1043 * @return policy value. Will be 0 if policy identifier is invalid.
1046 elm_policy_get(unsigned int policy)
1048 if (policy >= ELM_POLICY_LAST)
1050 return _elm_policies[policy];
1054 * Flush all caches & dump all data that can be to lean down to use less memory
1062 EINA_LIST_FOREACH(_elm_win_list, l, obj)
1064 Evas *e = evas_object_evas_get(obj);
1065 edje_file_cache_flush();
1066 edje_collection_cache_flush();
1068 evas_image_cache_flush(e);
1069 evas_font_cache_flush(e);
1070 evas_render_dump(e);
1075 * @defgroup Scaling Selective Widget Scaling
1078 * Different widgets can be scaled independently. These functions allow you to
1079 * manipulate this scaling on a per-widget basis. The object and all its
1080 * children get their scaling factors multiplied by the scale factor set.
1081 * This is multiplicative, in that if a child also has a scale size set it is
1082 * in turn multiplied by its parent's scale size. 1.0 means “don't scale”,
1083 * 2.0 is double size, 0.5 is half etc.
1087 * Set the scaling factor
1089 * @param obj The object
1090 * @param scale Scale factor (from 0.0 up, with 1.0 == no scaling)
1094 elm_object_scale_set(Evas_Object *obj, double scale)
1096 elm_widget_scale_set(obj, scale);
1100 * Get the scaling factor
1102 * @param obj The object
1103 * @return The scaling factor set by elm_object_scale_set()
1107 elm_object_scale_get(const Evas_Object *obj)
1109 return elm_widget_scale_get(obj);
1113 * @defgroup Styles Styles
1116 * Widgets can have different styles of look. These generic API's set
1117 * styles of widgets, if they support them (and if the theme(s) do).
1123 * This sets the name of the style
1124 * @param obj The object
1125 * @param style The style name to use
1129 elm_object_style_set(Evas_Object *obj, const char *style)
1131 elm_widget_style_set(obj, style);
1137 * This gets the style being used for that widget. Note that the string
1138 * pointer is only valid as longas the object is valid and the style doesn't
1141 * @param obj The object
1142 * @return The style name
1146 elm_object_style_get(const Evas_Object *obj)
1148 return elm_widget_style_get(obj);
1152 * Set the disable state
1154 * This sets the disable state for the widget.
1156 * @param obj The object
1157 * @param disabled The state
1161 elm_object_disabled_set(Evas_Object *obj, Eina_Bool disabled)
1163 elm_widget_disabled_set(obj, disabled);
1167 * Get the disable state
1169 * This gets the disable state for the widget.
1171 * @param obj The object
1172 * @return True, if the widget is disabled
1176 elm_object_disabled_get(const Evas_Object *obj)
1178 return elm_widget_disabled_get(obj);
1182 * Get the global scaling factor
1184 * This gets the globally configured scaling factor that is applied to all
1187 * @return The scaling factor
1193 return _elm_config->scale;
1197 * Set the global scaling factor
1199 * This sets the globally configured scaling factor that is applied to all
1202 * @param scale The scaling factor to set
1206 elm_scale_set(double scale)
1208 if (_elm_config->scale == scale) return;
1209 _elm_config->scale = scale;
1214 * Set the global scaling factor for all applications on the display
1216 * This sets the globally configured scaling factor that is applied to all
1217 * objects for all applications.
1218 * @param scale The scaling factor to set
1222 elm_scale_all_set(double scale)
1224 #ifdef HAVE_ELEMENTARY_X
1225 static Ecore_X_Atom atom = 0;
1226 unsigned int scale_i = (unsigned int)(scale * 1000.0);
1228 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_SCALE");
1229 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1235 * @defgroup Fingers Fingers
1238 * Elementary is designed to be finger-friendly for touchscreens, and so in
1239 * addition to scaling for display resolution, it can also scale based on
1240 * finger "resolution" (or size).
1244 * Get the configured finger size
1246 * This gets the globally configured finger size in pixels
1248 * @return The finger size
1252 elm_finger_size_get(void)
1254 return _elm_config->finger_size;
1258 * Set the configured finger size
1260 * This sets the globally configured finger size in pixels
1262 * @param size The finger size
1266 elm_finger_size_set(Evas_Coord size)
1268 if (_elm_config->finger_size == size) return;
1269 _elm_config->finger_size = size;
1274 * Set the configured finger size for all applications on the display
1276 * This sets the globally configured finger size in pixels for all applications
1279 * @param size The finger size
1283 elm_finger_size_all_set(Evas_Coord size)
1285 #ifdef HAVE_ELEMENTARY_X
1286 static Ecore_X_Atom atom = 0;
1287 unsigned int size_i = (unsigned int)size;
1289 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_FINGER_SIZE");
1290 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1296 elm_autocapitalization_allow_all_set(Eina_Bool on)
1298 #ifdef HAVE_ELEMENTARY_X
1299 static Ecore_X_Atom atom = 0;
1300 unsigned int on_i = (unsigned int)on;
1302 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_AUTOCAPITAL_ALLOW");
1303 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1309 elm_autoperiod_allow_all_set(Eina_Bool on)
1311 #ifdef HAVE_ELEMENTARY_X
1312 static Ecore_X_Atom atom = 0;
1313 unsigned int on_i = (unsigned int)on;
1315 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_AUTOPERIOD_ALLOW");
1316 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1323 * Adjust size of an element for finger usage
1325 * This takes width and height sizes (in pixels) as input and a size multiple
1326 * (which is how many fingers you want to place within the area), and adjusts
1327 * the size tobe large enough to accomodate finger. On return the w and h
1328 * sizes poiner do by these parameters will be modified.
1330 * @param times_w How many fingers should fit horizontally
1331 * @param w Pointer to the width size to adjust
1332 * @param times_h How many fingers should fit vertically
1333 * @param h Pointer to the height size to adjust
1337 elm_coords_finger_size_adjust(int times_w, Evas_Coord *w, int times_h, Evas_Coord *h)
1339 if ((w) && (*w < (_elm_config->finger_size * times_w)))
1340 *w = _elm_config->finger_size * times_w;
1341 if ((h) && (*h < (_elm_config->finger_size * times_h)))
1342 *h = _elm_config->finger_size * times_h;
1346 * @defgroup Focus Focus
1349 * Objects have focus. This is what determines where the keyboard input goes to
1350 * within the application window.
1354 * Get the focus of the object
1356 * This gets the focused property of the object.
1358 * @param obj The object
1359 * @return 1 if the object is focused, 0 if not.
1363 elm_object_focus_get(Evas_Object *obj)
1365 return elm_widget_focus_get(obj);
1369 * Set the focus to the object
1371 * This sets the focus target for keyboard input to be the object indicated.
1373 * @param obj The object
1377 elm_object_focus(Evas_Object *obj)
1379 if (!elm_widget_can_focus_get(obj)) return;
1380 elm_widget_focus_steal(obj);
1384 * Remove the focus from the object
1386 * This removes the focus target for keyboard input from be the object
1389 * @param obj The object
1393 elm_object_unfocus(Evas_Object *obj)
1395 if (!elm_widget_can_focus_get(obj)) return;
1396 elm_widget_focused_object_clear(obj);
1400 * Set the ability for the object to focus
1402 * This sets the ability for the object to be able to get keyboard focus or
1403 * not. By default all objects are able to be focused.
1405 * @param obj The object
1406 * @param enable 1 if the object can be focused, 0 if not
1410 elm_object_focus_allow_set(Evas_Object *obj, Eina_Bool enable)
1412 elm_widget_can_focus_set(obj, enable);
1416 * Get the ability for the object to focus
1418 * This gets the ability for the object to be able to get keyboard focus or
1419 * not. By default all objects are able to be focused.
1421 * @param obj The object
1422 * @return 1 if the object is allowed to be focused, 0 if not.
1426 elm_object_focus_allow_get(const Evas_Object *obj)
1428 return elm_widget_can_focus_get(obj);
1432 * @defgroup Scrollhints Scrollhints
1435 * Objects when inside a scroller can scroll, but this may not always be
1436 * desireable in certain situations. This allows an object to hint to itself
1437 * and parents to "not scroll" in one of 2 ways.
1439 * 1. To hold on scrolling. This means just flicking and dragging may no
1440 * longer scroll, but pressing/dragging near an edge of the scroller will
1441 * still scroll. This is automastically used by the entry object when
1443 * 2. To totally freeze scrolling. This means it stops. until popped/released.
1447 * Push the scroll hold by 1
1449 * This increments the scroll hold count by one. If it is more than 0 it will
1450 * take effect on the parents of the indicated object.
1452 * @param obj The object
1453 * @ingroup Scrollhints
1456 elm_object_scroll_hold_push(Evas_Object *obj)
1458 elm_widget_scroll_hold_push(obj);
1462 * Pop the scroll hold by 1
1464 * This decrements the scroll hold count by one. If it is more than 0 it will
1465 * take effect on the parents of the indicated object.
1467 * @param obj The object
1468 * @ingroup Scrollhints
1471 elm_object_scroll_hold_pop(Evas_Object *obj)
1473 elm_widget_scroll_hold_pop(obj);
1477 * Push the scroll freeze by 1
1479 * This increments the scroll freeze count by one. If it is more than 0 it will
1480 * take effect on the parents of the indicated object.
1482 * @param obj The object
1483 * @ingroup Scrollhints
1486 elm_object_scroll_freeze_push(Evas_Object *obj)
1488 elm_widget_scroll_freeze_push(obj);
1492 * Lock the scrolling of the given widget (and thus all parents)
1494 * This locks the given object from scrolling in the X axis (and implicitly
1495 * also locks all parent scrollers too from doing the same).
1497 * @param obj The object
1498 * @param lock The lock state (1 == locked, 0 == unlocked)
1499 * @ingroup Scrollhints
1502 elm_object_scroll_lock_x_set(Evas_Object *obj, Eina_Bool lock)
1504 elm_widget_drag_lock_x_set(obj, lock);
1508 * Lock the scrolling of the given widget (and thus all parents)
1510 * This locks the given object from scrolling in the Y axis (and implicitly
1511 * also locks all parent scrollers too from doing the same).
1513 * @param obj The object
1514 * @param lock The lock state (1 == locked, 0 == unlocked)
1515 * @ingroup Scrollhints
1518 elm_object_scroll_lock_y_set(Evas_Object *obj, Eina_Bool lock)
1520 elm_widget_drag_lock_y_set(obj, lock);
1524 * Get the scrolling lock of the given widget
1526 * This gets the lock for X axis scrolling.
1528 * @param obj The object
1529 * @ingroup Scrollhints
1532 elm_object_scroll_lock_x_get(const Evas_Object *obj)
1534 return elm_widget_drag_lock_x_get(obj);
1538 * Get the scrolling lock of the given widget
1540 * This gets the lock for X axis scrolling.
1542 * @param obj The object
1543 * @ingroup Scrollhints
1546 elm_object_scroll_lock_y_get(const Evas_Object *obj)
1548 return elm_widget_drag_lock_y_get(obj);
1552 * Pop the scroll freeze by 1
1554 * This decrements the scroll freeze count by one. If it is more than 0 it will
1555 * take effect on the parents of the indicated object.
1557 * @param obj The object
1558 * @ingroup Scrollhints
1561 elm_object_scroll_freeze_pop(Evas_Object *obj)
1563 elm_widget_scroll_freeze_pop(obj);
1568 * Check if the given Evas Object is an Elementary widget.
1570 * @param obj the object to query.
1571 * @return @c EINA_TRUE if it is an elementary widget variant,
1572 * @c EINA_FALSE otherwise
1575 elm_object_widget_check(const Evas_Object *obj)
1577 return elm_widget_is(obj);
1581 * Get the first parent of the given object that is an Elementary widget.
1583 * @param obj the object to query.
1584 * @return the parent object that is an Elementary widget, or @c NULL
1585 * if no parent is, or no parents at all.
1588 elm_object_parent_widget_get(const Evas_Object *obj)
1590 return elm_widget_parent_widget_get(obj);
1594 * Get the top level parent of an Elementary widget.
1596 * @param obj The object to query.
1597 * @return The top level Elementary widget, or @c NULL if parent cannot be
1601 elm_object_top_widget_get(const Evas_Object *obj)
1603 return elm_widget_top_get(obj);
1607 * Get the string that represents this Elementary widget.
1609 * @note Elementary is weird and exposes itself as a single
1610 * Evas_Object_Smart_Class of type "elm_widget", so
1611 * evas_object_type_get() always return that, making debug and
1612 * language bindings hard. This function tries to mitigate this
1613 * problem, but the solution is to change Elementary to use
1614 * proper inheritance.
1616 * @param obj the object to query.
1617 * @return Elementary widget name, or @c NULL if not a valid widget.
1620 elm_object_widget_type_get(const Evas_Object *obj)
1622 return elm_widget_type_get(obj);
1626 * Send a signal to the widget edje object.
1628 * This function sends a signal to the edje object of the obj. An edje program
1629 * can respond to a signal by specifying matching 'signal' and
1632 * @param obj The object
1633 * @param emission The signal's name.
1634 * @param source The signal's source.
1637 EAPI void elm_object_signal_emit(Evas_Object *obj, const char *emission, const char *source)
1639 elm_widget_signal_emit(obj, emission, source);
1643 * Add a callback for a signal emitted by widget edje object.
1645 * This function connects a callback function to a signal emitted by the
1646 * edje object of the obj.
1647 * Globs can occur in either the emission or source name.
1649 * @param obj The object
1650 * @param emission The signal's name.
1651 * @param source The signal's source.
1652 * @param func The callback function to be executed when the signal is
1654 * @param data A pointer to data to pass in to the callback function.
1657 EAPI void 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)
1659 elm_widget_signal_callback_add(obj, emission, source, func, data);
1663 * Remove a signal-triggered callback from an widget edje object.
1665 * This function removes a callback, previoulsy attached to a signal emitted
1666 * by the edje object of the obj.
1667 * The parameters emission, source and func must match exactly those passed to
1668 * a previous call to elm_object_signal_callback_add(). The data pointer that
1669 * was passed to this call will be returned.
1671 * @param obj The object
1672 * @param emission The signal's name.
1673 * @param source The signal's source.
1674 * @param func The callback function to be executed when the signal is
1676 * @return The data pointer
1679 EAPI void *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))
1681 return elm_widget_signal_callback_del(obj, emission, source, func);
1685 * Set the duration for occuring long press event.
1687 * @param lonpress_timeout Timeout for long press event
1688 * @ingroup Longpress
1691 elm_longpress_timeout_set(double longpress_timeout)
1693 _elm_config->longpress_timeout = longpress_timeout;
1697 * Get the duration for occuring long press event.
1699 * @return Timeout for long press event
1700 * @ingroup Longpress
1703 elm_longpress_timeout_get(void)
1705 return _elm_config->longpress_timeout;