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);
589 _elm_config_sub_init();
590 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
591 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
592 (_elm_config->engine == ELM_XRENDER_X11) ||
593 (_elm_config->engine == ELM_OPENGL_X11))
595 #ifdef HAVE_ELEMENTARY_X
599 ecore_evas_init(); // FIXME: check errors
603 return _elm_sub_init_count;
607 elm_quicklaunch_sub_shutdown(void)
609 _elm_sub_init_count--;
610 if (_elm_sub_init_count > 0) return _elm_sub_init_count;
613 #ifdef SEMI_BROKEN_QUICKLAUNCH
614 return _elm_sub_init_count;
620 _elm_module_shutdown();
621 ecore_imf_shutdown();
622 ecore_evas_shutdown();
623 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
624 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
625 (_elm_config->engine == ELM_XRENDER_X11) ||
626 (_elm_config->engine == ELM_OPENGL_X11))
628 #ifdef HAVE_ELEMENTARY_X
629 ecore_x_disconnect();
632 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
633 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
634 (_elm_config->engine == ELM_XRENDER_X11) ||
635 (_elm_config->engine == ELM_OPENGL_X11) ||
636 (_elm_config->engine == ELM_SOFTWARE_SDL) ||
637 (_elm_config->engine == ELM_SOFTWARE_16_SDL) ||
638 (_elm_config->engine == ELM_OPENGL_SDL) ||
639 (_elm_config->engine == ELM_SOFTWARE_WIN32) ||
640 (_elm_config->engine == ELM_SOFTWARE_16_WINCE))
641 evas_cserve_disconnect();
645 return _elm_sub_init_count;
649 elm_quicklaunch_shutdown(void)
651 _elm_ql_init_count--;
652 if (_elm_ql_init_count > 0) return _elm_ql_init_count;
653 eina_stringshare_del(_elm_data_dir);
654 _elm_data_dir = NULL;
655 eina_stringshare_del(_elm_lib_dir);
661 _elm_config_shutdown();
663 ecore_event_handler_del(_elm_exit_handler);
664 _elm_exit_handler = NULL;
666 _elm_theme_shutdown();
667 _elm_unneed_efreet();
668 _elm_unneed_e_dbus();
669 _elm_unneed_ethumb();
670 ecore_file_shutdown();
674 if ((_elm_log_dom > -1) && (_elm_log_dom != EINA_LOG_DOMAIN_GLOBAL))
676 eina_log_domain_unregister(_elm_log_dom);
680 _elm_widtype_clear();
683 return _elm_ql_init_count;
687 elm_quicklaunch_seed(void)
689 #ifndef SEMI_BROKEN_QUICKLAUNCH
692 Evas_Object *win, *bg, *bt;
694 win = elm_win_add(NULL, "seed", ELM_WIN_BASIC);
695 bg = elm_bg_add(win);
696 elm_win_resize_object_add(win, bg);
697 evas_object_show(bg);
698 bt = elm_button_add(win);
699 elm_button_label_set(bt, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789~-_=+\\|]}[{;:'\",<.>/?");
700 elm_win_resize_object_add(win, bt);
701 ecore_main_loop_iterate();
702 evas_object_del(win);
703 ecore_main_loop_iterate();
704 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
705 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
706 (_elm_config->engine == ELM_XRENDER_X11) ||
707 (_elm_config->engine == ELM_OPENGL_X11))
709 # ifdef HAVE_ELEMENTARY_X
713 ecore_main_loop_iterate();
718 static void *qr_handle = NULL;
719 static int (*qr_main) (int argc, char **argv) = NULL;
722 elm_quicklaunch_prepare(int argc __UNUSED__, char **argv)
725 char *exe = elm_quicklaunch_exe_path_get(argv[0]);
728 ERR("requested quicklaunch binary '%s' does not exist\n", argv[0]);
736 exe2 = malloc(strlen(exe) + 1 + 10);
738 p = strrchr(exe2, '/');
741 exename = alloca(strlen(p) + 1);
744 strcat(p, "../lib/");
747 if (access(exe2, R_OK | X_OK) == 0)
755 qr_handle = dlopen(exe, RTLD_NOW | RTLD_GLOBAL);
758 fprintf(stderr, "dlerr: %s\n", dlerror());
759 WRN("dlopen('%s') failed: %s", exe, dlerror());
763 INF("dlopen('%s') = %p", exe, qr_handle);
765 qr_main = dlsym(qr_handle, "elm_main");
766 INF("dlsym(%p, 'elm_main') = %p", qr_handle, qr_main);
769 WRN("not quicklauncher capable: no elm_main in '%s'", exe);
785 extern char **environ;
790 for (i = 0, size = 0; environ[i]; i++)
791 size += strlen(environ[i]) + 1;
793 p = malloc((i + 1) * sizeof(char *));
798 for (i = 0; oldenv[i]; i++)
799 environ[i] = strdup(oldenv[i]);
805 elm_quicklaunch_fork(int argc, char **argv, char *cwd, void (postfork_func) (void *data), void *postfork_data)
814 // need to accept current environment from elementary_run
821 if (child > 0) return EINA_TRUE;
824 perror("could not fork");
829 perror("could not chdir");
830 args = alloca((argc + 1) * sizeof(char *));
831 for (i = 0; i < argc; i++) args[i] = argv[i];
833 WRN("%s not quicklaunch capable, fallback...", argv[0]);
834 execvp(argv[0], args);
835 ERR("failed to execute '%s': %s", argv[0], strerror(errno));
839 if (child > 0) return EINA_TRUE;
842 perror("could not fork");
845 if (postfork_func) postfork_func(postfork_data);
849 #ifdef SEMI_BROKEN_QUICKLAUNCH
850 ecore_app_args_set(argc, (const char **)argv);
853 _elm_config_sub_init();
854 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
855 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
856 (_elm_config->engine == ELM_XRENDER_X11) ||
857 (_elm_config->engine == ELM_OPENGL_X11))
859 # ifdef HAVE_ELEMENTARY_X
863 ecore_evas_init(); // FIXME: check errors
871 perror("could not chdir");
872 // FIXME: this is very linux specific. it changes argv[0] of the process
873 // so ps etc. report what you'd expect. for other unixes and os's this
880 ecore_app_args_get(&real_argc, &real_argv);
881 lastarg = real_argv[real_argc - 1] + strlen(real_argv[real_argc - 1]);
882 for (p = real_argv[0]; p < lastarg; p++) *p = 0;
883 strcpy(real_argv[0], argv[0]);
885 ecore_app_args_set(argc, (const char **)argv);
886 ret = qr_main(argc, argv);
895 elm_quicklaunch_cleanup(void)
908 elm_quicklaunch_fallback(int argc, char **argv)
911 elm_quicklaunch_init(argc, argv);
912 elm_quicklaunch_sub_init(argc, argv);
913 elm_quicklaunch_prepare(argc, argv);
914 ret = qr_main(argc, argv);
920 elm_quicklaunch_exe_path_get(const char *exe)
922 static char *path = NULL;
923 static Eina_List *pathlist = NULL;
927 if (exe[0] == '/') return strdup(exe);
928 if ((exe[0] == '.') && (exe[1] == '/')) return strdup(exe);
929 if ((exe[0] == '.') && (exe[1] == '.') && (exe[2] == '/')) return strdup(exe);
934 path = getenv("PATH");
935 buf2 = alloca(strlen(path) + 1);
940 if ((*p == ':') || (*p == 0))
945 strncpy(buf2, pp, len);
947 pathlist = eina_list_append(pathlist, eina_stringshare_add(buf2));
959 EINA_LIST_FOREACH(pathlist, l, pathitr)
961 snprintf(buf, sizeof(buf), "%s/%s", pathitr, exe);
962 if (access(buf, R_OK | X_OK) == 0) return strdup(buf);
970 * This call should be called just after all initialization is complete. This
971 * function will not return until elm_exit() is called. It will keep looping
972 * running the main event/processing loop for Elementary.
978 ecore_main_loop_begin();
984 * If this call is called, it will flag the main loop to cease processing and
985 * return back to its parent function.
991 ecore_main_loop_quit();
996 * Set new policy value.
998 * This will emit the ecore event ELM_EVENT_POLICY_CHANGED in the main
999 * loop giving the event information Elm_Event_Policy_Changed with
1000 * policy identifier, new and old values.
1002 * @param policy policy identifier as in Elm_Policy.
1003 * @param value policy value, depends on identifiers, usually there is
1004 * an enumeration with the same prefix as the policy name, for
1005 * example: ELM_POLICY_QUIT and Elm_Policy_Quit
1006 * (ELM_POLICY_QUIT_NONE, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED).
1008 * @return @c EINA_TRUE on success or @c EINA_FALSE on error (right
1009 * now just invalid policy identifier, but in future policy
1010 * value might be enforced).
1013 elm_policy_set(unsigned int policy, int value)
1015 Elm_Event_Policy_Changed *ev;
1017 if (policy >= ELM_POLICY_LAST)
1020 if (value == _elm_policies[policy])
1023 /* TODO: validade policy? */
1025 ev = malloc(sizeof(*ev));
1026 ev->policy = policy;
1027 ev->new_value = value;
1028 ev->old_value = _elm_policies[policy];
1030 _elm_policies[policy] = value;
1032 ecore_event_add(ELM_EVENT_POLICY_CHANGED, ev, NULL, NULL);
1038 * Gets the policy value set for given identifier.
1040 * @param policy policy identifier as in Elm_Policy.
1042 * @return policy value. Will be 0 if policy identifier is invalid.
1045 elm_policy_get(unsigned int policy)
1047 if (policy >= ELM_POLICY_LAST)
1049 return _elm_policies[policy];
1053 * Flush all caches & dump all data that can be to lean down to use less memory
1061 EINA_LIST_FOREACH(_elm_win_list, l, obj)
1063 Evas *e = evas_object_evas_get(obj);
1064 edje_file_cache_flush();
1065 edje_collection_cache_flush();
1066 evas_image_cache_flush(e);
1067 evas_font_cache_flush(e);
1068 evas_render_dump(e);
1073 * @defgroup Scaling Selective Widget Scaling
1076 * Different widgets can be scaled independently. These functions allow you to
1077 * manipulate this scaling on a per-widget basis. The object and all its
1078 * children get their scaling factors multiplied by the scale factor set.
1079 * This is multiplicative, in that if a child also has a scale size set it is
1080 * in turn multiplied by its parent's scale size. 1.0 means “don't scale”,
1081 * 2.0 is double size, 0.5 is half etc.
1085 * Set the scaling factor
1087 * @param obj The object
1088 * @param scale Scale factor (from 0.0 up, with 1.0 == no scaling)
1092 elm_object_scale_set(Evas_Object *obj, double scale)
1094 elm_widget_scale_set(obj, scale);
1098 * Get the scaling factor
1100 * @param obj The object
1101 * @return The scaling factor set by elm_object_scale_set()
1105 elm_object_scale_get(const Evas_Object *obj)
1107 return elm_widget_scale_get(obj);
1111 * @defgroup Styles Styles
1114 * Widgets can have different styles of look. These generic API's set
1115 * styles of widgets, if they support them (and if the theme(s) do).
1121 * This sets the name of the style
1122 * @param obj The object
1123 * @param style The style name to use
1127 elm_object_style_set(Evas_Object *obj, const char *style)
1129 elm_widget_style_set(obj, style);
1135 * This gets the style being used for that widget. Note that the string
1136 * pointer is only valid as longas the object is valid and the style doesn't
1139 * @param obj The object
1140 * @return The style name
1144 elm_object_style_get(const Evas_Object *obj)
1146 return elm_widget_style_get(obj);
1150 * Set the disable state
1152 * This sets the disable state for the widget.
1154 * @param obj The object
1155 * @param disabled The state
1159 elm_object_disabled_set(Evas_Object *obj, Eina_Bool disabled)
1161 elm_widget_disabled_set(obj, disabled);
1165 * Get the disable state
1167 * This gets the disable state for the widget.
1169 * @param obj The object
1170 * @return True, if the widget is disabled
1174 elm_object_disabled_get(const Evas_Object *obj)
1176 return elm_widget_disabled_get(obj);
1180 * Get the global scaling factor
1182 * This gets the globally configured scaling factor that is applied to all
1185 * @return The scaling factor
1191 return _elm_config->scale;
1195 * Set the global scaling factor
1197 * This sets the globally configured scaling factor that is applied to all
1200 * @param scale The scaling factor to set
1204 elm_scale_set(double scale)
1206 if (_elm_config->scale == scale) return;
1207 _elm_config->scale = scale;
1212 * Set the global scaling factor for all applications on the display
1214 * This sets the globally configured scaling factor that is applied to all
1215 * objects for all applications.
1216 * @param scale The scaling factor to set
1220 elm_scale_all_set(double scale)
1222 #ifdef HAVE_ELEMENTARY_X
1223 static Ecore_X_Atom atom = 0;
1224 unsigned int scale_i = (unsigned int)(scale * 1000.0);
1226 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_SCALE");
1227 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1233 * @defgroup Fingers Fingers
1236 * Elementary is designed to be finger-friendly for touchscreens, and so in
1237 * addition to scaling for display resolution, it can also scale based on
1238 * finger "resolution" (or size).
1242 * Get the configured finger size
1244 * This gets the globally configured finger size in pixels
1246 * @return The finger size
1250 elm_finger_size_get(void)
1252 return _elm_config->finger_size;
1256 * Set the configured finger size
1258 * This sets the globally configured finger size in pixels
1260 * @param size The finger size
1264 elm_finger_size_set(Evas_Coord size)
1266 if (_elm_config->finger_size == size) return;
1267 _elm_config->finger_size = size;
1272 * Set the configured finger size for all applications on the display
1274 * This sets the globally configured finger size in pixels for all applications
1277 * @param size The finger size
1281 elm_finger_size_all_set(Evas_Coord size)
1283 #ifdef HAVE_ELEMENTARY_X
1284 static Ecore_X_Atom atom = 0;
1285 unsigned int size_i = (unsigned int)size;
1287 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_FINGER_SIZE");
1288 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1294 elm_autocapitalization_allow_all_set(Eina_Bool on)
1296 #ifdef HAVE_ELEMENTARY_X
1297 static Ecore_X_Atom atom = 0;
1298 unsigned int on_i = (unsigned int)on;
1300 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_AUTOCAPITAL_ALLOW");
1301 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1307 elm_autoperiod_allow_all_set(Eina_Bool on)
1309 #ifdef HAVE_ELEMENTARY_X
1310 static Ecore_X_Atom atom = 0;
1311 unsigned int on_i = (unsigned int)on;
1313 if (!atom) atom = ecore_x_atom_get("ENLIGHTENMENT_AUTOPERIOD_ALLOW");
1314 ecore_x_window_prop_card32_set(ecore_x_window_root_first_get(),
1321 * Adjust size of an element for finger usage
1323 * This takes width and height sizes (in pixels) as input and a size multiple
1324 * (which is how many fingers you want to place within the area), and adjusts
1325 * the size tobe large enough to accomodate finger. On return the w and h
1326 * sizes poiner do by these parameters will be modified.
1328 * @param times_w How many fingers should fit horizontally
1329 * @param w Pointer to the width size to adjust
1330 * @param times_h How many fingers should fit vertically
1331 * @param h Pointer to the height size to adjust
1335 elm_coords_finger_size_adjust(int times_w, Evas_Coord *w, int times_h, Evas_Coord *h)
1337 if ((w) && (*w < (_elm_config->finger_size * times_w)))
1338 *w = _elm_config->finger_size * times_w;
1339 if ((h) && (*h < (_elm_config->finger_size * times_h)))
1340 *h = _elm_config->finger_size * times_h;
1344 * @defgroup Focus Focus
1347 * Objects have focus. This is what determines where the keyboard input goes to
1348 * within the application window.
1352 * Get the focus of the object
1354 * This gets the focused property of the object.
1356 * @param obj The object
1357 * @return 1 if the object is focused, 0 if not.
1361 elm_object_focus_get(Evas_Object *obj)
1363 return elm_widget_focus_get(obj);
1367 * Set the focus to the object
1369 * This sets the focus target for keyboard input to be the object indicated.
1371 * @param obj The object
1375 elm_object_focus(Evas_Object *obj)
1377 if (!elm_widget_can_focus_get(obj)) return;
1378 elm_widget_focus_steal(obj);
1382 * Remove the focus from the object
1384 * This removes the focus target for keyboard input from be the object
1387 * @param obj The object
1391 elm_object_unfocus(Evas_Object *obj)
1393 if (!elm_widget_can_focus_get(obj)) return;
1394 elm_widget_focused_object_clear(obj);
1398 * Set the ability for the object to focus
1400 * This sets the ability for the object to be able to get keyboard focus or
1401 * not. By default all objects are able to be focused.
1403 * @param obj The object
1404 * @param enable 1 if the object can be focused, 0 if not
1408 elm_object_focus_allow_set(Evas_Object *obj, Eina_Bool enable)
1410 elm_widget_can_focus_set(obj, enable);
1414 * Get the ability for the object to focus
1416 * This gets the ability for the object to be able to get keyboard focus or
1417 * not. By default all objects are able to be focused.
1419 * @param obj The object
1420 * @return 1 if the object is allowed to be focused, 0 if not.
1424 elm_object_focus_allow_get(const Evas_Object *obj)
1426 return elm_widget_can_focus_get(obj);
1430 * @defgroup Scrollhints Scrollhints
1433 * Objects when inside a scroller can scroll, but this may not always be
1434 * desireable in certain situations. This allows an object to hint to itself
1435 * and parents to "not scroll" in one of 2 ways.
1437 * 1. To hold on scrolling. This means just flicking and dragging may no
1438 * longer scroll, but pressing/dragging near an edge of the scroller will
1439 * still scroll. This is automastically used by the entry object when
1441 * 2. To totally freeze scrolling. This means it stops. until popped/released.
1445 * Push the scroll hold by 1
1447 * This increments the scroll hold count by one. If it is more than 0 it will
1448 * take effect on the parents of the indicated object.
1450 * @param obj The object
1451 * @ingroup Scrollhints
1454 elm_object_scroll_hold_push(Evas_Object *obj)
1456 elm_widget_scroll_hold_push(obj);
1460 * Pop the scroll hold by 1
1462 * This decrements the scroll hold count by one. If it is more than 0 it will
1463 * take effect on the parents of the indicated object.
1465 * @param obj The object
1466 * @ingroup Scrollhints
1469 elm_object_scroll_hold_pop(Evas_Object *obj)
1471 elm_widget_scroll_hold_pop(obj);
1475 * Push the scroll freeze by 1
1477 * This increments the scroll freeze count by one. If it is more than 0 it will
1478 * take effect on the parents of the indicated object.
1480 * @param obj The object
1481 * @ingroup Scrollhints
1484 elm_object_scroll_freeze_push(Evas_Object *obj)
1486 elm_widget_scroll_freeze_push(obj);
1490 * Lock the scrolling of the given widget (and thus all parents)
1492 * This locks the given object from scrolling in the X axis (and implicitly
1493 * also locks all parent scrollers too from doing the same).
1495 * @param obj The object
1496 * @param lock The lock state (1 == locked, 0 == unlocked)
1497 * @ingroup Scrollhints
1500 elm_object_scroll_lock_x_set(Evas_Object *obj, Eina_Bool lock)
1502 elm_widget_drag_lock_x_set(obj, lock);
1506 * Lock the scrolling of the given widget (and thus all parents)
1508 * This locks the given object from scrolling in the Y axis (and implicitly
1509 * also locks all parent scrollers too from doing the same).
1511 * @param obj The object
1512 * @param lock The lock state (1 == locked, 0 == unlocked)
1513 * @ingroup Scrollhints
1516 elm_object_scroll_lock_y_set(Evas_Object *obj, Eina_Bool lock)
1518 elm_widget_drag_lock_y_set(obj, lock);
1522 * Get the scrolling lock of the given widget
1524 * This gets the lock for X axis scrolling.
1526 * @param obj The object
1527 * @ingroup Scrollhints
1530 elm_object_scroll_lock_x_get(const Evas_Object *obj)
1532 return elm_widget_drag_lock_x_get(obj);
1536 * Get the scrolling lock of the given widget
1538 * This gets the lock for X axis scrolling.
1540 * @param obj The object
1541 * @ingroup Scrollhints
1544 elm_object_scroll_lock_y_get(const Evas_Object *obj)
1546 return elm_widget_drag_lock_y_get(obj);
1550 * Pop the scroll freeze by 1
1552 * This decrements the scroll freeze count by one. If it is more than 0 it will
1553 * take effect on the parents of the indicated object.
1555 * @param obj The object
1556 * @ingroup Scrollhints
1559 elm_object_scroll_freeze_pop(Evas_Object *obj)
1561 elm_widget_scroll_freeze_pop(obj);
1566 * Check if the given Evas Object is an Elementary widget.
1568 * @param obj the object to query.
1569 * @return @c EINA_TRUE if it is an elementary widget variant,
1570 * @c EINA_FALSE otherwise
1573 elm_object_widget_check(const Evas_Object *obj)
1575 return elm_widget_is(obj);
1579 * Get the first parent of the given object that is an Elementary widget.
1581 * @param obj the object to query.
1582 * @return the parent object that is an Elementary widget, or @c NULL
1583 * if no parent is, or no parents at all.
1586 elm_object_parent_widget_get(const Evas_Object *obj)
1588 return elm_widget_parent_widget_get(obj);
1592 * Get the top level parent of an Elementary widget.
1594 * @param obj The object to query.
1595 * @return The top level Elementary widget, or @c NULL if parent cannot be
1599 elm_object_top_widget_get(const Evas_Object *obj)
1601 return elm_widget_top_get(obj);
1605 * Get the string that represents this Elementary widget.
1607 * @note Elementary is weird and exposes itself as a single
1608 * Evas_Object_Smart_Class of type "elm_widget", so
1609 * evas_object_type_get() always return that, making debug and
1610 * language bindings hard. This function tries to mitigate this
1611 * problem, but the solution is to change Elementary to use
1612 * proper inheritance.
1614 * @param obj the object to query.
1615 * @return Elementary widget name, or @c NULL if not a valid widget.
1618 elm_object_widget_type_get(const Evas_Object *obj)
1620 return elm_widget_type_get(obj);
1624 * Send a signal to the widget edje object.
1626 * This function sends a signal to the edje object of the obj. An edje program
1627 * can respond to a signal by specifying matching 'signal' and
1630 * @param obj The object
1631 * @param emission The signal's name.
1632 * @param source The signal's source.
1635 EAPI void elm_object_signal_emit(Evas_Object *obj, const char *emission, const char *source)
1637 elm_widget_signal_emit(obj, emission, source);
1641 * Add a callback for a signal emitted by widget edje object.
1643 * This function connects a callback function to a signal emitted by the
1644 * edje object of the obj.
1645 * Globs can occur in either the emission or source name.
1647 * @param obj The object
1648 * @param emission The signal's name.
1649 * @param source The signal's source.
1650 * @param func The callback function to be executed when the signal is
1652 * @param data A pointer to data to pass in to the callback function.
1655 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)
1657 elm_widget_signal_callback_add(obj, emission, source, func, data);
1661 * Remove a signal-triggered callback from an widget edje object.
1663 * This function removes a callback, previoulsy attached to a signal emitted
1664 * by the edje object of the obj.
1665 * The parameters emission, source and func must match exactly those passed to
1666 * a previous call to elm_object_signal_callback_add(). The data pointer that
1667 * was passed to this call will be returned.
1669 * @param obj The object
1670 * @param emission The signal's name.
1671 * @param source The signal's source.
1672 * @param func The callback function to be executed when the signal is
1674 * @return The data pointer
1677 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))
1679 return elm_widget_signal_callback_del(obj, emission, source, func);