enlightenment-module-desksa.../src/e_mod_main.c

86 lines
1.9 KiB
C
Raw Normal View History

2013-10-03 06:34:52 -07:00
#include "e_mod_main.h"
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Desksanity"};
static E_Config_DD *conf_edd = NULL;
EINTERN Mod *mod = NULL;
EINTERN Config *ds_config = NULL;
static void
2013-10-10 05:14:08 -07:00
_e_mod_ds_config_load(void)
2013-10-03 06:34:52 -07:00
{
#undef T
#undef D
conf_edd = E_CONFIG_DD_NEW("Config", Config);
#define T Config
#define D conf_edd
E_CONFIG_VAL(D, T, config_version, UINT);
2014-07-30 09:27:56 -07:00
E_CONFIG_VAL(D, T, disable_ruler, UCHAR);
E_CONFIG_VAL(D, T, disable_maximize, UCHAR);
2013-10-03 06:34:52 -07:00
2014-07-30 09:27:56 -07:00
ds_config = e_config_domain_load("module.desksanity", conf_edd);
2013-10-03 06:34:52 -07:00
if (ds_config)
{
if (!e_util_module_config_check("Desksanity", ds_config->config_version, MOD_CONFIG_FILE_VERSION))
2014-07-30 09:27:56 -07:00
E_FREE(ds_config);
2013-10-03 06:34:52 -07:00
}
if (!ds_config)
2014-07-30 09:27:56 -07:00
ds_config = E_NEW(Config, 1);
ds_config->config_version = MOD_CONFIG_FILE_VERSION;
2013-10-03 06:34:52 -07:00
}
EAPI void *
e_modapi_init(E_Module *m)
{
2014-07-30 09:27:56 -07:00
char buf[PATH_MAX];
2013-10-03 06:34:52 -07:00
bindtextdomain(PACKAGE, LOCALEDIR);
bind_textdomain_codeset(PACKAGE, "UTF-8");
snprintf(buf, sizeof(buf), "%s/e-module-desksanity.edj", m->dir);
2014-02-11 16:31:02 -08:00
elm_theme_overlay_add(NULL, buf);
2013-10-03 06:34:52 -07:00
efx_init();
2014-07-30 09:27:56 -07:00
_e_mod_ds_config_load();
2013-10-03 06:34:52 -07:00
mod = E_NEW(Mod, 1);
mod->module = m;
2013-10-15 07:37:39 -07:00
mod->edje_file = eina_stringshare_add(buf);
2013-10-03 06:34:52 -07:00
2014-07-30 09:27:56 -07:00
ds_config_init();
2013-10-03 06:34:52 -07:00
ds_init();
2014-07-30 09:27:56 -07:00
if (!ds_config->disable_ruler)
mr_init();
if (!ds_config->disable_maximize)
maximize_init();
2013-10-03 06:34:52 -07:00
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m EINA_UNUSED)
{
2014-07-30 09:27:56 -07:00
if (!ds_config->disable_maximize)
maximize_shutdown();
if (!ds_config->disable_ruler)
mr_shutdown();
2013-10-03 06:34:52 -07:00
ds_shutdown();
2014-07-30 09:27:56 -07:00
ds_config_shutdown();
e_config_domain_save("module.desksanity", conf_edd, ds_config);
E_FREE(ds_config);
2013-10-03 06:34:52 -07:00
E_CONFIG_DD_FREE(conf_edd);
2014-07-30 09:01:25 -07:00
eina_stringshare_del(mod->edje_file);
2013-10-03 06:34:52 -07:00
E_FREE(mod);
//efx_shutdown(); broken...
2013-10-03 06:34:52 -07:00
return 1;
}
EAPI int
e_modapi_save(E_Module *m EINA_UNUSED)
{
2014-07-30 09:27:56 -07:00
e_config_domain_save("module.desksanity", conf_edd, ds_config);
2013-10-03 06:34:52 -07:00
return 1;
}