diff options
author | Tom Hacohen <tom@stosb.com> | 2013-04-29 14:48:27 +0100 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2013-05-13 11:09:06 +0100 |
commit | 5ff5d40c53e39d3803a70d10b511da2d70828c88 (patch) | |
tree | 5e6686da632a62ff1b570d1ec7f65bdab62735c5 | |
parent | 3e27b14f757f3bab608208e700d96bc301a22b13 (diff) | |
download | elementary-5ff5d40c53e39d3803a70d10b511da2d70828c88.tar.gz |
Added basic clouseau auto-start support.
If the ELM_CLOUSEAU env var is set to 1 elm auto-starts clouseau.
Next step would be integrating it into the elm config and making it
toggle-able on run-time.
-rw-r--r-- | src/lib/elm_main.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 1c1009a3b..1ee5e22f8 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -204,6 +204,55 @@ _prefix_shutdown(void) app_pfx = NULL; } +static struct { + Eina_Module *handle; + void (*init)(void); + void (*shutdown)(void); + Eina_Bool (*app_connect)(const char *appname); +} _clouseau_info; + +#define _CLOUSEAU_LOAD_SYMBOL(cls_struct, sym) \ + do \ + { \ + (cls_struct).sym = eina_module_symbol_get((cls_struct).handle, "clouseau_" #sym); \ + if (!(cls_struct).sym) \ + { \ + WRN("Failed loading symbol '%s' from the clouseau library.", "clouseau_" #sym); \ + eina_module_free((cls_struct).handle); \ + (cls_struct).handle = NULL; \ + return EINA_FALSE; \ + } \ + } \ + while (0) + +static Eina_Bool +_clouseau_module_load() +{ + const char *elm_clouseau_env = getenv("ELM_CLOUSEAU"); + Eina_Bool want_cls = EINA_FALSE; + if (elm_clouseau_env) + want_cls = atoi(elm_clouseau_env); + + if (!want_cls) + return EINA_FALSE; + + _clouseau_info.handle = eina_module_new( + PACKAGE_LIB_DIR "/libclouseau" LIBEXT); + if (!eina_module_load(_clouseau_info.handle)) + { + WRN("Failed loading the clouseau library."); + eina_module_free(_clouseau_info.handle); + _clouseau_info.handle = NULL; + return EINA_FALSE; + } + + _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, init); + _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, shutdown); + _CLOUSEAU_LOAD_SYMBOL(_clouseau_info, app_connect); + + return EINA_TRUE; +} + EAPI int elm_init(int argc, char **argv) @@ -213,6 +262,16 @@ elm_init(int argc, elm_quicklaunch_init(argc, argv); elm_quicklaunch_sub_init(argc, argv); _prefix_shutdown(); + + if (_clouseau_module_load()) + { + _clouseau_info.init(); + if(!_clouseau_info.app_connect(elm_app_name_get())) + { + ERR("Failed connecting to the clouseau server."); + } + } + return _elm_init_count; } @@ -228,6 +287,13 @@ elm_shutdown(void) if (_elm_init_count > 0) return _elm_init_count; _elm_win_shutdown(); while (_elm_win_deferred_free) ecore_main_loop_iterate(); + + if (_clouseau_info.shutdown) + { + _clouseau_info.shutdown(); + eina_module_free(_clouseau_info.handle); + _clouseau_info.handle = NULL; + } // wrningz :( // _prefix_shutdown(); if (app_name) |