2005-02-07 05:51:09 -08:00
|
|
|
/*
|
|
|
|
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
|
|
|
*/
|
2004-11-24 19:37:45 -08:00
|
|
|
#include "e.h"
|
2005-09-14 13:19:44 -07:00
|
|
|
#include "config.h"
|
2004-11-24 19:37:45 -08:00
|
|
|
|
2005-10-06 11:49:53 -07:00
|
|
|
#ifdef HAVE_VALGRIND
|
|
|
|
# include <memcheck.h>
|
|
|
|
#endif
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* TODO List:
|
|
|
|
*
|
|
|
|
* * add module types/classes
|
2005-02-08 10:07:00 -08:00
|
|
|
* * add list of exclusions that a module cant work with
|
2004-11-24 19:37:45 -08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _Module_Menu_Data Module_Menu_Data;
|
|
|
|
|
|
|
|
struct _Module_Menu_Data
|
|
|
|
{
|
|
|
|
Evas_List *submenus;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* local subsystem functions */
|
|
|
|
static void _e_module_free(E_Module *m);
|
|
|
|
static E_Menu *_e_module_control_menu_new(E_Module *mod);
|
|
|
|
static void _e_module_menu_free(void *obj);
|
|
|
|
static void _e_module_control_menu_about(void *data, E_Menu *m, E_Menu_Item *mi);
|
|
|
|
static void _e_module_control_menu_enabled(void *data, E_Menu *m, E_Menu_Item *mi);
|
2005-09-24 06:42:05 -07:00
|
|
|
static void _e_module_dialog_disable_show(char *title, char *body, E_Module *m);
|
|
|
|
static void _e_module_cb_dialog_disable(void *data, E_Dialog *dia);
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
/* local subsystem globals */
|
|
|
|
static Evas_List *_e_modules = NULL;
|
|
|
|
|
|
|
|
/* externally accessible functions */
|
|
|
|
int
|
|
|
|
e_module_init(void)
|
|
|
|
{
|
2005-05-03 03:06:42 -07:00
|
|
|
Evas_List *pl = NULL, *l;
|
2004-12-05 01:34:59 -08:00
|
|
|
|
2005-05-03 03:06:42 -07:00
|
|
|
for (l = e_config->modules; l;)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2004-12-05 01:34:59 -08:00
|
|
|
E_Config_Module *em;
|
2004-11-24 19:37:45 -08:00
|
|
|
E_Module *m;
|
|
|
|
|
2004-12-05 01:34:59 -08:00
|
|
|
em = l->data;
|
2005-05-03 03:06:42 -07:00
|
|
|
pl = l;
|
|
|
|
l = l->next;
|
2005-11-23 04:55:55 -08:00
|
|
|
m = NULL;
|
|
|
|
if (em->name) m = e_module_new(em->name);
|
2005-05-04 02:59:02 -07:00
|
|
|
if (m)
|
|
|
|
{
|
|
|
|
if (em->enabled) e_module_enable(m);
|
|
|
|
}
|
2005-05-03 03:06:42 -07:00
|
|
|
else
|
|
|
|
{
|
2005-12-04 04:03:59 -08:00
|
|
|
if (em->name) evas_stringshare_del(em->name);
|
2005-09-05 08:24:07 -07:00
|
|
|
E_FREE(em);
|
2005-05-03 03:06:42 -07:00
|
|
|
e_config->modules = evas_list_remove_list(e_config->modules, pl);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_module_shutdown(void)
|
|
|
|
{
|
2005-02-16 03:30:32 -08:00
|
|
|
Evas_List *l, *tmp;
|
2005-10-06 11:49:53 -07:00
|
|
|
|
|
|
|
#ifdef HAVE_VALGRIND
|
|
|
|
/* do a leak check now before we dlclose() all those plugins, cause
|
|
|
|
* that means we won't get a decent backtrace to leaks in there
|
|
|
|
*/
|
|
|
|
VALGRIND_DO_LEAK_CHECK
|
|
|
|
#endif
|
|
|
|
|
2005-02-16 03:30:32 -08:00
|
|
|
for (l = _e_modules; l;)
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
2005-02-16 03:30:32 -08:00
|
|
|
tmp = l;
|
|
|
|
l = l->next;
|
|
|
|
e_object_del(E_OBJECT(tmp->data));
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_Module *
|
|
|
|
e_module_new(char *name)
|
|
|
|
{
|
|
|
|
E_Module *m;
|
|
|
|
char buf[4096];
|
2005-09-24 06:42:05 -07:00
|
|
|
char body[4096], title[1024];
|
2005-02-07 19:51:08 -08:00
|
|
|
char *modpath, *s;
|
2004-12-05 01:34:59 -08:00
|
|
|
Evas_List *l;
|
|
|
|
int in_list = 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
if (!name) return NULL;
|
2005-01-21 22:58:34 -08:00
|
|
|
m = E_OBJECT_ALLOC(E_Module, E_MODULE_TYPE, _e_module_free);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (name[0] != '/')
|
|
|
|
{
|
2005-02-07 07:39:16 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s/module.so", name, MODULE_ARCH);
|
2005-05-19 20:09:44 -07:00
|
|
|
modpath = e_path_find(path_modules, buf);
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
else
|
2005-12-04 04:03:59 -08:00
|
|
|
modpath = evas_stringshare_add(name);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (!modpath)
|
|
|
|
{
|
2005-09-24 06:42:05 -07:00
|
|
|
snprintf(body, sizeof(body), _("There was an error loading module named: %s<br>"
|
|
|
|
"No module named %s could be found in the<br>"
|
|
|
|
"module search directories.<br>"),
|
|
|
|
name, buf);
|
|
|
|
_e_module_dialog_disable_show(_("Error loading Module"), body, m);
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-08-24 14:25:06 -07:00
|
|
|
m->handle = dlopen(modpath, RTLD_NOW | RTLD_GLOBAL);
|
2004-11-24 19:37:45 -08:00
|
|
|
if (!m->handle)
|
|
|
|
{
|
2005-09-24 06:42:05 -07:00
|
|
|
snprintf(body, sizeof(body), _("There was an error loading module named: %s<br>"
|
|
|
|
"The full path to this module is:<br>"
|
|
|
|
"%s<br>"
|
|
|
|
"The error reported was:<br>"
|
|
|
|
"%s<br>"),
|
|
|
|
name, buf, dlerror());
|
|
|
|
_e_module_dialog_disable_show(_("Error loading Module"), body, m);
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-09-24 06:42:05 -07:00
|
|
|
m->api = dlsym(m->handle, "e_modapi");
|
2005-04-11 20:34:31 -07:00
|
|
|
m->func.init = dlsym(m->handle, "e_modapi_init");
|
|
|
|
m->func.shutdown = dlsym(m->handle, "e_modapi_shutdown");
|
|
|
|
m->func.save = dlsym(m->handle, "e_modapi_save");
|
|
|
|
m->func.info = dlsym(m->handle, "e_modapi_info");
|
|
|
|
m->func.about = dlsym(m->handle, "e_modapi_about");
|
2004-11-24 19:37:45 -08:00
|
|
|
if ((!m->func.init) ||
|
|
|
|
(!m->func.shutdown) ||
|
|
|
|
(!m->func.save) ||
|
|
|
|
(!m->func.info) ||
|
2005-09-23 10:13:47 -07:00
|
|
|
(!m->func.about) ||
|
|
|
|
(!m->api)
|
2004-11-24 19:37:45 -08:00
|
|
|
)
|
|
|
|
{
|
2005-09-24 06:42:05 -07:00
|
|
|
snprintf(body, sizeof(body), _("There was an error loading module named: %s<br>"
|
|
|
|
"The full path to this module is:<br>"
|
|
|
|
"%s<br>"
|
|
|
|
"The error reported was:<br>"
|
|
|
|
"%s<br>"),
|
|
|
|
name, buf, dlerror());
|
|
|
|
_e_module_dialog_disable_show(_("Error loading Module"), body, m);
|
|
|
|
m->api = NULL;
|
|
|
|
m->func.init = NULL;
|
|
|
|
m->func.shutdown = NULL;
|
|
|
|
m->func.save = NULL;
|
|
|
|
m->func.info = NULL;
|
|
|
|
m->func.about = NULL;
|
2004-11-24 19:37:45 -08:00
|
|
|
dlclose(m->handle);
|
2005-09-24 06:42:05 -07:00
|
|
|
m->handle = NULL;
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
2005-09-23 10:13:47 -07:00
|
|
|
if (m->api->version < E_MODULE_API_VERSION)
|
|
|
|
{
|
2005-09-24 06:42:05 -07:00
|
|
|
snprintf(body, sizeof(body), _("Module API Error<br>Error initializing Module: %s<br>"
|
|
|
|
"It requires a minimum module API version of: %i.<br>"
|
|
|
|
"The module API advertized by Enlightenment is: %i.<br>"),
|
|
|
|
_(m->api->name), E_MODULE_API_VERSION, m->api->version);
|
2005-09-23 10:13:47 -07:00
|
|
|
|
2005-09-23 10:54:43 -07:00
|
|
|
snprintf(title, sizeof(title), _("Enlightenment %s Module"), _(m->api->name));
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
_e_module_dialog_disable_show(title, body, m);
|
2005-09-29 07:11:03 -07:00
|
|
|
m->api = NULL;
|
|
|
|
m->func.init = NULL;
|
|
|
|
m->func.shutdown = NULL;
|
|
|
|
m->func.save = NULL;
|
|
|
|
m->func.info = NULL;
|
|
|
|
m->func.about = NULL;
|
2005-09-23 10:13:47 -07:00
|
|
|
dlclose(m->handle);
|
2005-09-24 06:42:05 -07:00
|
|
|
m->handle = NULL;
|
|
|
|
m->error = 1;
|
|
|
|
goto init_done;
|
2005-09-23 10:13:47 -07:00
|
|
|
}
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
init_done:
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
_e_modules = evas_list_append(_e_modules, m);
|
2005-12-03 07:39:25 -08:00
|
|
|
m->name = evas_stringshare_add(name);
|
2005-12-04 04:03:59 -08:00
|
|
|
if (modpath)
|
2005-02-07 19:51:08 -08:00
|
|
|
{
|
2005-12-04 04:03:59 -08:00
|
|
|
s = ecore_file_get_dir(modpath);
|
|
|
|
if (s)
|
|
|
|
{
|
|
|
|
char *s2;
|
|
|
|
|
|
|
|
s2 = ecore_file_get_dir(s);
|
|
|
|
free(s);
|
|
|
|
if (s2)
|
|
|
|
{
|
|
|
|
m->dir = evas_stringshare_add(s2);
|
|
|
|
free(s2);
|
|
|
|
}
|
|
|
|
}
|
2005-02-07 19:51:08 -08:00
|
|
|
}
|
2005-09-24 06:42:05 -07:00
|
|
|
if (m->func.info)
|
|
|
|
m->func.info(m);
|
2004-12-05 01:34:59 -08:00
|
|
|
for (l = e_config->modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Config_Module *em;
|
|
|
|
|
|
|
|
em = l->data;
|
|
|
|
if (!strcmp(em->name, m->name))
|
|
|
|
{
|
|
|
|
in_list = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!in_list)
|
|
|
|
{
|
|
|
|
E_Config_Module *em;
|
|
|
|
|
|
|
|
em = E_NEW(E_Config_Module, 1);
|
2005-12-04 04:03:59 -08:00
|
|
|
em->name = evas_stringshare_add(m->name);
|
2004-12-05 01:34:59 -08:00
|
|
|
em->enabled = 0;
|
|
|
|
e_config->modules = evas_list_append(e_config->modules, em);
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|
2005-12-04 04:03:59 -08:00
|
|
|
if (modpath) evas_stringshare_del(modpath);
|
2004-11-24 19:37:45 -08:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_module_save(E_Module *m)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((!m->enabled) || (m->error)) return 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
return m->func.save(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
e_module_dir_get(E_Module *m)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(m, NULL);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2004-11-24 19:37:45 -08:00
|
|
|
return m->dir;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_module_enable(E_Module *m)
|
|
|
|
{
|
2004-12-05 01:34:59 -08:00
|
|
|
Evas_List *l;
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((m->enabled) || (m->error)) return 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
m->data = m->func.init(m);
|
2005-10-31 18:41:58 -08:00
|
|
|
if (m->data)
|
2004-12-05 01:34:59 -08:00
|
|
|
{
|
2005-10-31 18:41:58 -08:00
|
|
|
m->enabled = 1;
|
|
|
|
for (l = e_config->modules; l; l = l->next)
|
2004-12-05 01:34:59 -08:00
|
|
|
{
|
2005-10-31 18:41:58 -08:00
|
|
|
E_Config_Module *em;
|
|
|
|
|
|
|
|
em = l->data;
|
2005-10-31 18:44:08 -08:00
|
|
|
if (!e_util_strcmp(em->name, m->name))
|
2005-10-31 18:41:58 -08:00
|
|
|
{
|
|
|
|
em->enabled = 1;
|
|
|
|
e_config_save_queue();
|
|
|
|
break;
|
|
|
|
}
|
2004-12-05 01:34:59 -08:00
|
|
|
}
|
2005-10-31 18:41:58 -08:00
|
|
|
return 1;
|
2004-12-05 01:34:59 -08:00
|
|
|
}
|
2005-10-31 18:41:58 -08:00
|
|
|
return 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_module_disable(E_Module *m)
|
|
|
|
{
|
2004-12-05 01:34:59 -08:00
|
|
|
Evas_List *l;
|
2004-11-24 19:37:45 -08:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((!m->enabled) || (m->error)) return 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
ret = m->func.shutdown(m);
|
|
|
|
m->data = NULL;
|
|
|
|
m->enabled = 0;
|
2004-12-05 01:34:59 -08:00
|
|
|
for (l = e_config->modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Config_Module *em;
|
|
|
|
|
|
|
|
em = l->data;
|
2005-10-31 18:44:08 -08:00
|
|
|
if (!e_util_strcmp(em->name, m->name))
|
2004-12-05 01:34:59 -08:00
|
|
|
{
|
|
|
|
em->enabled = 0;
|
|
|
|
e_config_save_queue();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-11-24 19:37:45 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_module_enabled_get(E_Module *m)
|
|
|
|
{
|
|
|
|
E_OBJECT_CHECK_RETURN(m, 0);
|
2005-01-21 22:58:34 -08:00
|
|
|
E_OBJECT_TYPE_CHECK_RETURN(m, E_MODULE_TYPE, 0);
|
2004-11-24 19:37:45 -08:00
|
|
|
return m->enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
e_module_save_all(void)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
for (l = _e_modules; l; l = l->next) e_object_ref(E_OBJECT(l->data));
|
|
|
|
for (l = _e_modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Module *m;
|
|
|
|
|
|
|
|
m = l->data;
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((m->enabled) && (!m->error))
|
2004-11-24 19:37:45 -08:00
|
|
|
{
|
|
|
|
if (!m->func.save(m)) ret = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (l = _e_modules; l; l = l->next) e_object_unref(E_OBJECT(l->data));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_Module *
|
|
|
|
e_module_find(char *name)
|
|
|
|
{
|
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
if (!name) return NULL;
|
|
|
|
for (l = _e_modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Module *m;
|
|
|
|
|
|
|
|
m = l->data;
|
|
|
|
if (!strcmp(name, m->name)) return m;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Evas_List *
|
|
|
|
e_module_list(void)
|
|
|
|
{
|
|
|
|
return _e_modules;
|
|
|
|
}
|
|
|
|
|
|
|
|
E_Menu *
|
|
|
|
e_module_menu_new(void)
|
|
|
|
{
|
|
|
|
E_Menu *m, *subm;
|
|
|
|
E_Menu_Item *mi;
|
|
|
|
Evas_List *l;
|
|
|
|
Module_Menu_Data *dat;
|
2005-07-26 05:25:19 -07:00
|
|
|
int mod_count = 0;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
dat = calloc(1, sizeof(Module_Menu_Data));
|
|
|
|
m = e_menu_new();
|
|
|
|
e_object_data_set(E_OBJECT(m), dat);
|
|
|
|
e_object_free_attach_func_set(E_OBJECT(m), _e_module_menu_free);
|
|
|
|
for (l = _e_modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Module *mod;
|
|
|
|
|
|
|
|
mod = l->data;
|
|
|
|
mi = e_menu_item_new(m);
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((mod->api) && (mod->api->name)) e_menu_item_label_set(mi, mod->api->name);
|
2004-11-24 19:37:45 -08:00
|
|
|
else e_menu_item_label_set(mi, mod->name);
|
|
|
|
if (mod->edje_icon_file)
|
|
|
|
{
|
|
|
|
if (mod->edje_icon_key)
|
|
|
|
e_menu_item_icon_edje_set(mi, mod->edje_icon_file, mod->edje_icon_key);
|
|
|
|
else
|
|
|
|
e_menu_item_icon_edje_set(mi, mod->edje_icon_file, "icon");
|
|
|
|
}
|
|
|
|
else if (mod->icon_file)
|
|
|
|
e_menu_item_icon_file_set(mi, mod->icon_file);
|
|
|
|
subm = _e_module_control_menu_new(mod);
|
2005-09-24 06:42:05 -07:00
|
|
|
if (subm)
|
|
|
|
{
|
|
|
|
e_menu_item_submenu_set(mi, subm);
|
|
|
|
dat->submenus = evas_list_append(dat->submenus, subm);
|
|
|
|
}
|
2005-07-26 05:25:19 -07:00
|
|
|
++mod_count;
|
|
|
|
}
|
|
|
|
if (mod_count == 0)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(m);
|
|
|
|
e_menu_item_label_set(mi, _("(No Loaded Modules)"));
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
void
|
|
|
|
e_module_dialog_show(char *title, char *body)
|
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
|
|
|
|
|
|
|
dia = e_dialog_new(e_container_current_get(e_manager_current_get()));
|
|
|
|
if (!dia) return;
|
|
|
|
|
|
|
|
e_dialog_title_set(dia, title);
|
2005-10-05 09:44:41 -07:00
|
|
|
e_dialog_icon_set(dia, "enlightenment/modules", 64);
|
2005-09-24 06:42:05 -07:00
|
|
|
e_dialog_text_set(dia, body);
|
2005-10-05 09:44:41 -07:00
|
|
|
e_dialog_button_add(dia, _("OK"), NULL, NULL, NULL);
|
|
|
|
e_dialog_button_focus_num(dia, 0);
|
2005-09-24 06:42:05 -07:00
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
|
|
|
|
2004-11-24 19:37:45 -08:00
|
|
|
/* local subsystem functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_module_free(E_Module *m)
|
|
|
|
{
|
2004-12-05 01:34:59 -08:00
|
|
|
Evas_List *l;
|
|
|
|
|
|
|
|
for (l = e_config->modules; l; l = l->next)
|
|
|
|
{
|
|
|
|
E_Config_Module *em;
|
|
|
|
|
|
|
|
em = l->data;
|
|
|
|
if (!strcmp(em->name, m->name))
|
|
|
|
{
|
|
|
|
e_config->modules = evas_list_remove(e_config->modules, em);
|
2005-12-04 04:03:59 -08:00
|
|
|
if (em->name) evas_stringshare_del(em->name);
|
2004-12-05 01:34:59 -08:00
|
|
|
E_FREE(em);
|
2005-02-13 02:47:57 -08:00
|
|
|
/* FIXME
|
|
|
|
* This is crap, a job is added, but doesn't run because
|
2005-02-10 04:29:25 -08:00
|
|
|
* main loop has quit!
|
2004-12-05 01:34:59 -08:00
|
|
|
e_config_save_queue();
|
2005-02-10 04:29:25 -08:00
|
|
|
*/
|
2004-12-05 01:34:59 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
if ((m->enabled) && (!m->error))
|
2005-02-10 04:29:25 -08:00
|
|
|
{
|
|
|
|
m->func.save(m);
|
|
|
|
m->func.shutdown(m);
|
|
|
|
}
|
2005-12-03 07:39:25 -08:00
|
|
|
if (m->name) evas_stringshare_del(m->name);
|
2005-12-04 04:03:59 -08:00
|
|
|
if (m->dir) evas_stringshare_del(m->dir);
|
2005-09-24 06:42:05 -07:00
|
|
|
if (m->handle) dlclose(m->handle);
|
2004-11-24 19:37:45 -08:00
|
|
|
_e_modules = evas_list_remove(_e_modules, m);
|
|
|
|
if (m->icon_file) free(m->icon_file);
|
|
|
|
if (m->edje_icon_file) free(m->edje_icon_file);
|
|
|
|
if (m->edje_icon_key) free(m->edje_icon_key);
|
|
|
|
free(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
static E_Menu *
|
|
|
|
_e_module_control_menu_new(E_Module *mod)
|
|
|
|
{
|
2004-12-22 22:38:27 -08:00
|
|
|
E_Menu *m;
|
2004-11-24 19:37:45 -08:00
|
|
|
E_Menu_Item *mi;
|
2005-09-24 06:42:05 -07:00
|
|
|
|
|
|
|
if (mod->error) return NULL;
|
2004-11-24 19:37:45 -08:00
|
|
|
|
|
|
|
m = e_menu_new();
|
|
|
|
|
|
|
|
mi = e_menu_item_new(m);
|
2005-04-11 13:25:52 -07:00
|
|
|
e_menu_item_label_set(mi, _("About..."));
|
2004-11-24 19:37:45 -08:00
|
|
|
e_menu_item_callback_set(mi, _e_module_control_menu_about, mod);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(m);
|
2005-04-11 13:25:52 -07:00
|
|
|
e_menu_item_label_set(mi, _("Enabled"));
|
2004-11-24 19:37:45 -08:00
|
|
|
e_menu_item_check_set(mi, 1);
|
|
|
|
if (mod->enabled) e_menu_item_toggle_set(mi, 1);
|
|
|
|
e_menu_item_callback_set(mi, _e_module_control_menu_enabled, mod);
|
|
|
|
|
|
|
|
if (mod->config_menu)
|
|
|
|
{
|
|
|
|
mi = e_menu_item_new(m);
|
|
|
|
e_menu_item_separator_set(mi, 1);
|
|
|
|
|
|
|
|
mi = e_menu_item_new(m);
|
2005-04-11 13:25:52 -07:00
|
|
|
e_menu_item_label_set(mi, _("Configuration"));
|
2004-11-24 19:37:45 -08:00
|
|
|
e_menu_item_submenu_set(mi, mod->config_menu);
|
|
|
|
}
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_module_menu_free(void *obj)
|
|
|
|
{
|
|
|
|
Module_Menu_Data *dat;
|
|
|
|
|
|
|
|
dat = e_object_data_get(E_OBJECT(obj));
|
|
|
|
while (dat->submenus)
|
|
|
|
{
|
|
|
|
E_Menu *subm;
|
|
|
|
|
|
|
|
subm = dat->submenus->data;
|
|
|
|
dat->submenus = evas_list_remove_list(dat->submenus, dat->submenus);
|
2005-02-15 03:46:54 -08:00
|
|
|
e_object_del(E_OBJECT(subm));
|
2004-11-24 19:37:45 -08:00
|
|
|
}
|
|
|
|
free(dat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_module_control_menu_about(void *data, E_Menu *m, E_Menu_Item *mi)
|
|
|
|
{
|
|
|
|
E_Module *mod;
|
|
|
|
|
|
|
|
mod = data;
|
|
|
|
mod->func.about(mod);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_e_module_control_menu_enabled(void *data, E_Menu *m, E_Menu_Item *mi)
|
|
|
|
{
|
|
|
|
E_Module *mod;
|
|
|
|
int enabled;
|
|
|
|
|
|
|
|
mod = data;
|
|
|
|
enabled = e_menu_item_toggle_get(mi);
|
|
|
|
if ((mod->enabled) && (!enabled))
|
|
|
|
{
|
|
|
|
e_module_save(mod);
|
|
|
|
e_module_disable(mod);
|
|
|
|
}
|
|
|
|
else if ((!mod->enabled) && (enabled))
|
|
|
|
{
|
|
|
|
e_module_enable(mod);
|
|
|
|
}
|
|
|
|
e_menu_item_toggle_set(mi, e_module_enabled_get(mod));
|
|
|
|
}
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
static void
|
|
|
|
_e_module_dialog_disable_show(char *title, char *body, E_Module *m)
|
2005-09-22 11:17:18 -07:00
|
|
|
{
|
|
|
|
E_Dialog *dia;
|
2005-09-24 06:42:05 -07:00
|
|
|
char buf[4096];
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
dia = e_dialog_new(e_container_current_get(e_manager_current_get()));
|
2005-09-22 11:17:18 -07:00
|
|
|
if (!dia) return;
|
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s<br>%s", body,
|
|
|
|
_("Would you like to unload this module?<br>"));
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
e_dialog_title_set(dia, title);
|
|
|
|
e_dialog_icon_set(dia, "enlightenment/e", 64);
|
|
|
|
e_dialog_text_set(dia, buf);
|
|
|
|
e_dialog_button_add(dia, _("Yes"), NULL, _e_module_cb_dialog_disable, m);
|
|
|
|
e_dialog_button_add(dia, _("No"), NULL, NULL, NULL);
|
|
|
|
e_win_centered_set(dia->win, 1);
|
|
|
|
e_dialog_show(dia);
|
|
|
|
}
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
static void
|
|
|
|
_e_module_cb_dialog_disable(void *data, E_Dialog *dia)
|
|
|
|
{
|
|
|
|
E_Module *m;
|
2005-09-22 11:17:18 -07:00
|
|
|
|
2005-09-24 06:42:05 -07:00
|
|
|
m = data;
|
|
|
|
e_module_disable(m);
|
|
|
|
e_object_del(E_OBJECT(m));
|
|
|
|
e_object_del(E_OBJECT(dia));
|
|
|
|
e_config_save_queue();
|
|
|
|
}
|