From 111735b63dd08622a71a98fd0ecb087a642df423 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Tue, 29 Sep 2009 04:35:35 +0000 Subject: [PATCH] 1. add elm module internal code. will be used later for things like: * putting policy into modules * multitouch handling being able to be farmed off to modules * farming off things that are not compatible with license/code of elm into a 3rd party piece of code via a clean defined interface API 2. fix doc image - dont need it 3. fix toolbar bounce settings. was wrong SVN revision: 42793 --- legacy/elementary/configure.ac | 4 + legacy/elementary/doc/e.css | 2 - legacy/elementary/src/lib/Elementary.h.in | 5 - legacy/elementary/src/lib/Makefile.am | 2 + legacy/elementary/src/lib/elm_main.c | 55 ++++++--- legacy/elementary/src/lib/elm_module.c | 139 ++++++++++++++++++++++ legacy/elementary/src/lib/elm_priv.h | 26 ++++ legacy/elementary/src/lib/elm_toolbar.c | 2 +- 8 files changed, 212 insertions(+), 23 deletions(-) create mode 100644 legacy/elementary/src/lib/elm_module.c diff --git a/legacy/elementary/configure.ac b/legacy/elementary/configure.ac index 8578d28713..24cd9081aa 100644 --- a/legacy/elementary/configure.ac +++ b/legacy/elementary/configure.ac @@ -233,6 +233,10 @@ AC_SUBST(requirement_elm) EFL_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"]) +MODULE_ARCH="$host_os-$host_cpu-$release" +AC_SUBST(MODULE_ARCH) +AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture") + AC_OUTPUT([ Makefile elementary.pc diff --git a/legacy/elementary/doc/e.css b/legacy/elementary/doc/e.css index 788eab9cf3..2dd6b44798 100644 --- a/legacy/elementary/doc/e.css +++ b/legacy/elementary/doc/e.css @@ -126,8 +126,6 @@ td.nav_active { #header h1 { width: 63px; height: 63px; - background-image: url(e.png); - background-repeat: no-repeat; position: absolute; margin: 0px; } diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 78c9e7dd11..992ccc288b 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -908,7 +908,6 @@ extern "C" { //////////////////////////////////////////////////////////////////////////// // //// (bugs - high priority) -// * scale change for hover doesnt seem to do new size alloc nicely // * left/right arrow broken with password mode for entry + utf8 chars... // * bubble doesnt handle child size changes right // * table doesnt do homogenous properly @@ -920,11 +919,9 @@ extern "C" { // * when entries are in a scroller and change size, the scroller shows scrollbars. fix. same for selecting. for 1 line entries in a scroller should only have scroll arrow indicators. // //// (more widgets/features - medium priority) -// * multiple genlist item styles (multi-label, 1 icon + 2 line label, header etc.) // * carousel selector widget // * auto-size label/text that adapts text size to its allocated region // * [ scrollable dropdown combo box ] -// * [ notepad widget ] // * [ toggle with 2x labelled button for 2 states ] // * [ poker spinner with numbers + labels ] // * [ wrapping text button bar ] @@ -934,8 +931,6 @@ extern "C" { // * "dialogbutton" widget (bigger button for bottom of wins) // * dialog window widget // * phone-number widget (hilight country dial prefixes, add flags, photos of contacts that match etc.) -// * imageview widget (for large not iconic images) -// * tiled image + zoom widget (tiled map viewer) // * dialpad widget - need one with a phone dialpad // * file selector widget - needs look and functionality improvement :) // * generic "tacho" widget (set min/max labels - and up to 3 intermediate labels etc.) diff --git a/legacy/elementary/src/lib/Makefile.am b/legacy/elementary/src/lib/Makefile.am index 90acb32894..4f43dcb1a3 100644 --- a/legacy/elementary/src/lib/Makefile.am +++ b/legacy/elementary/src/lib/Makefile.am @@ -8,6 +8,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ -I$(top_builddir)/src/lib \ -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ @ELEMENTARY_CFLAGS@ \ @ELEMENTARY_X_CFLAGS@ \ @ELEMENTARY_FB_CFLAGS@ \ @@ -28,6 +29,7 @@ libelementary_la_SOURCES = \ elm_priv.h \ elm_main.c \ elm_theme.c \ +elm_module.c \ \ elm_win.c \ elm_widget.c \ diff --git a/legacy/elementary/src/lib/elm_main.c b/legacy/elementary/src/lib/elm_main.c index 0281a0d503..837f05928c 100644 --- a/legacy/elementary/src/lib/elm_main.c +++ b/legacy/elementary/src/lib/elm_main.c @@ -264,6 +264,7 @@ static void _elm_rescale(void); char *_elm_appname = NULL; Elm_Config *_elm_config = NULL; const char *_elm_data_dir = NULL; +const char *_elm_lib_dir = NULL; int _elm_log_dom = -1; static Ecore_Event_Handler *_elm_exit_handler = NULL; @@ -442,6 +443,7 @@ elm_quicklaunch_init(int argc, char **argv) evas_init(); edje_init(); ecore_evas_init(); // FIXME: check errors + _elm_module_init(); _elm_exit_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, NULL); @@ -461,8 +463,22 @@ elm_quicklaunch_init(int argc, char **argv) _elm_data_dir = eina_stringshare_add(buf); } } + if (!_elm_lib_dir) + { + s = getenv("ELM_LIB_DIR"); + _elm_lib_dir = eina_stringshare_add(s); + } + if (!_elm_lib_dir) + { + s = getenv("ELM_PREFIX"); + if (s) + { + snprintf(buf, sizeof(buf), "%s/lib", s); + _elm_lib_dir = eina_stringshare_add(buf); + } + } #ifdef HAVE_DLADDR - if (!_elm_data_dir) + if ((!_elm_data_dir) || (!_elm_lib_dir)) { Dl_info elementary_dl; // libelementary.so/../../share/elementary/ @@ -473,27 +489,35 @@ elm_quicklaunch_init(int argc, char **argv) dir = ecore_file_dir_get(elementary_dl.dli_fname); if (dir) { - dir2 = ecore_file_dir_get(dir); - if (dir2) - { - snprintf(buf, sizeof(buf), "%s/share/elementary", dir2); - if (ecore_file_is_dir(buf)) - _elm_data_dir = eina_stringshare_add(buf); - free(dir2); - } + if (!_elm_lib_dir) + { + if (ecore_file_is_dir(dir)) + _elm_lib_dir = eina_stringshare_add(dir); + } + if (!_elm_data_dir) + { + dir2 = ecore_file_dir_get(dir); + if (dir2) + { + snprintf(buf, sizeof(buf), "%s/share/elementary", dir2); + if (ecore_file_is_dir(buf)) + _elm_data_dir = eina_stringshare_add(buf); + free(dir2); + } + } free(dir); } } } #endif if (!_elm_data_dir) - { - _elm_data_dir = eina_stringshare_add(PACKAGE_DATA_DIR); - } + _elm_data_dir = eina_stringshare_add(PACKAGE_DATA_DIR); if (!_elm_data_dir) - { - _elm_data_dir = eina_stringshare_add("/"); - } + _elm_data_dir = eina_stringshare_add("/"); + if (!_elm_lib_dir) + _elm_lib_dir = eina_stringshare_add(PACKAGE_LIB_DIR); + if (!_elm_lib_dir) + _elm_lib_dir = eina_stringshare_add("/"); // FIXME: actually load config _elm_config = ELM_NEW(Elm_Config); @@ -724,6 +748,7 @@ elm_quicklaunch_shutdown(void) free(_elm_appname); _elm_unneed_efreet(); _elm_unneed_e_dbus(); + _elm_module_shutdown(); ecore_evas_shutdown(); edje_shutdown(); evas_shutdown(); diff --git a/legacy/elementary/src/lib/elm_module.c b/legacy/elementary/src/lib/elm_module.c new file mode 100644 index 0000000000..a8dc4b86dc --- /dev/null +++ b/legacy/elementary/src/lib/elm_module.c @@ -0,0 +1,139 @@ +#include +#include "elm_priv.h" + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#include /* dlopen,dlclose,etc */ + +static Eina_Hash *modules = NULL; + +void +_elm_module_init(void) +{ + modules = eina_hash_string_small_new(NULL); +} + +void +_elm_module_shutdown(void) +{ + // FIXME: unload all modules + eina_hash_free(modules); + modules = NULL; +} + +Elm_Module * +_elm_module_add(const char *name) +{ + Elm_Module *m; + char buf[PATH_MAX]; + + m = eina_hash_find(modules, name); + if (m) + { + m->references++; + return m; + } + m = calloc(1, sizeof(Elm_Module)); + if (!m) return NULL; + m->version = 1; + if (name[0] != '/') + { + const char *home = getenv("HOME"); + + if (home) + { + snprintf(buf, sizeof(buf), "%s/.elementary/modules/%s/%s/module.so", home, name, MODULE_ARCH); + m->handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); + if (m->handle) + { + m->init_func = dlsym(m->handle, "elm_modapi_init"); + if (m->init_func) + { + m->shutdown_func = dlsym(m->handle, "elm_modapi_shutdown"); + m->so_path = eina_stringshare_add(buf); + m->name = eina_stringshare_add(name); + snprintf(buf, sizeof(buf), "%s/.elementary/modules/%s/%s", home, name, MODULE_ARCH); + m->bin_dir = eina_stringshare_add(buf); + snprintf(buf, sizeof(buf), "%s/.elementary/modules/%s", home, name); + m->data_dir = eina_stringshare_add(buf); + } + else + { + dlclose(m->handle); + free(m); + return NULL; + } + } + } + if (!m->handle) + { + snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s/module.so", _elm_lib_dir, name, MODULE_ARCH); + m->handle = dlopen(buf, RTLD_NOW | RTLD_GLOBAL); + if (m->handle) + { + m->init_func = dlsym(m->handle, "elm_modapi_init"); + if (m->init_func) + { + m->shutdown_func = dlsym(m->handle, "elm_modapi_shutdown"); + m->so_path = eina_stringshare_add(buf); + m->name = eina_stringshare_add(name); + snprintf(buf, sizeof(buf), "%s/elementary/modules/%s/%s", _elm_lib_dir, name, MODULE_ARCH); + m->bin_dir = eina_stringshare_add(buf); + snprintf(buf, sizeof(buf), "%s/elementary/modules/%s", _elm_lib_dir, name, MODULE_ARCH); + m->data_dir = eina_stringshare_add(buf); + } + else + { + dlclose(m->handle); + free(m); + return NULL; + } + } + } + } + if (!m->handle) + { + free(m); + return NULL; + } + if (!m->init_func(m)) + { + dlclose(m->handle); + eina_stringshare_del(m->name); + eina_stringshare_del(m->so_path); + eina_stringshare_del(m->data_dir); + eina_stringshare_del(m->bin_dir); + free(m); + return NULL; + } + m->references = 1; + eina_hash_direct_add(modules, m->name, m); + return m; +} + +void +_elm_module_del(Elm_Module *m) +{ + m->references--; + if (m->references > 0) return; + if (m->shutdown_func) m->shutdown_func(m); + eina_hash_del(modules, m->name, m); + dlclose(m->handle); + eina_stringshare_del(m->name); + eina_stringshare_del(m->so_path); + eina_stringshare_del(m->data_dir); + eina_stringshare_del(m->bin_dir); + free(m); +} + +const void * +_elm_module_symbol_get(Elm_Module *m, const char *name) +{ + return dlsym(m->handle, name); +} diff --git a/legacy/elementary/src/lib/elm_priv.h b/legacy/elementary/src/lib/elm_priv.h index 3cde53dce0..a07cb97a36 100644 --- a/legacy/elementary/src/lib/elm_priv.h +++ b/legacy/elementary/src/lib/elm_priv.h @@ -19,7 +19,9 @@ #include "els_icon.h" // FIXME: totally disorganised. clean this up! +// // Why EAPI in a private header ? +// EAPI is temporaty - that widget api will change, but makign it EAPI right now to indicate its bound for externalness typedef enum _Elm_Engine { @@ -57,6 +59,22 @@ struct _Elm_Config double fps; }; +typedef struct _Elm_Module Elm_Module; + +struct _Elm_Module +{ + int version; + const char *name; + const char *so_path; + const char *data_dir; + const char *bin_dir; + void *handle; + void *data; + int (*init_func) (Elm_Module *m); + int (*shutdown_func) (Elm_Module *m); + int references; +}; + #define ELM_NEW(t) calloc(1, sizeof(t)) void _elm_win_shutdown(void); @@ -66,6 +84,12 @@ int _elm_theme_set(Evas_Object *o, const char *clas, const char *group, const ch int _elm_theme_icon_set(Evas_Object *o, const char *group, const char *style); int _elm_theme_parse(const char *theme); +void _elm_module_init(void); +void _elm_module_shutdown(void); +Elm_Module *_elm_module_add(const char *name); +void _elm_module_del(Elm_Module *m); +const void *_elm_module_symbol_get(Elm_Module *m, const char *name); + /* FIXME: should this be public? for now - private (but public symbols) */ EAPI Evas_Object *elm_widget_add(Evas *evas); EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); @@ -116,10 +140,12 @@ EAPI const char *elm_widget_type_get(const Evas_Object *obj); EAPI Eina_List *_stringlist_get(const char *str); EAPI void _stringlist_free(Eina_List *list); + extern char *_elm_appname; extern Elm_Config *_elm_config; extern const char *_elm_data_dir; +extern const char *_elm_lib_dir; extern int _elm_log_dom; #define CRITICAL(...) EINA_LOG_DOM_CRIT(_elm_log_dom, __VA_ARGS__) diff --git a/legacy/elementary/src/lib/elm_toolbar.c b/legacy/elementary/src/lib/elm_toolbar.c index 4833b9e5d8..66a8c2cf9b 100644 --- a/legacy/elementary/src/lib/elm_toolbar.c +++ b/legacy/elementary/src/lib/elm_toolbar.c @@ -228,7 +228,7 @@ elm_toolbar_add(Evas_Object *parent) elm_widget_can_focus_set(obj, 0); wd->scr = elm_smart_scroller_add(e); - elm_scroller_bounce_set(wd->scr, 1, 0); + elm_smart_scroller_bounce_allow_set(wd->scr, 1, 0); elm_smart_scroller_theme_set(wd->scr, "toolbar", "base", "default"); elm_widget_resize_object_set(obj, wd->scr); elm_smart_scroller_policy_set(wd->scr,