forked from enlightenment/enlightenment
parent
a355da7bf8
commit
c76328248e
|
@ -1,16 +1,231 @@
|
||||||
#include "e.h"
|
#include "e.h"
|
||||||
|
|
||||||
|
static void _e_configure_menu_module_item_cb(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||||
|
static void _e_configure_menu_add(void *data, E_Menu *m);
|
||||||
static void _e_configure_efreet_desktop_cleanup(void);
|
static void _e_configure_efreet_desktop_cleanup(void);
|
||||||
static void _e_configure_efreet_desktop_update(void);
|
static void _e_configure_efreet_desktop_update(void);
|
||||||
static Eina_Bool _e_configure_cb_efreet_desktop_cache_update(void *data, int type, void *event);
|
static Eina_Bool _e_configure_cb_efreet_desktop_cache_update(void *data, int type, void *event);
|
||||||
static void _e_configure_registry_item_full_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon, E_Config_Dialog *(*func) (E_Container *con, const char *params), void (*generic_func) (E_Container *con, const char *params), Efreet_Desktop *desktop);
|
static void _e_configure_registry_item_full_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon, E_Config_Dialog *(*func) (E_Container *con, const char *params), void (*generic_func) (E_Container *con, const char *params), Efreet_Desktop *desktop);
|
||||||
|
|
||||||
|
static void _configure_job(void *data);
|
||||||
|
static Eina_Bool _configure_init_timer(void *data);
|
||||||
|
|
||||||
EAPI Eina_List *e_configure_registry = NULL;
|
EAPI Eina_List *e_configure_registry = NULL;
|
||||||
|
|
||||||
static Eina_List *handlers = NULL;
|
static Eina_List *handlers = NULL;
|
||||||
static E_Int_Menu_Augmentation *maug = NULL;
|
static E_Int_Menu_Augmentation *maug = NULL;
|
||||||
static Ecore_Job *update_job = NULL;
|
static Ecore_Job *update_job = NULL;
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
void (*func) (const void *data, E_Container *con, const char *params, Efreet_Desktop *desktop);
|
||||||
|
const char *data;
|
||||||
|
} custom_desktop_exec = { NULL, NULL };
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_init(void)
|
||||||
|
{
|
||||||
|
e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, "preferences-extensions");
|
||||||
|
e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "preferences-plugin", e_int_config_modules);
|
||||||
|
|
||||||
|
maug = e_int_menus_menu_augmentation_add_sorted
|
||||||
|
("config/1", _("Modules"), _e_configure_menu_add, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
handlers = eina_list_append
|
||||||
|
(handlers, ecore_event_handler_add
|
||||||
|
(EFREET_EVENT_DESKTOP_CACHE_UPDATE, _e_configure_cb_efreet_desktop_cache_update, NULL));
|
||||||
|
if (update_job)
|
||||||
|
{
|
||||||
|
ecore_job_del(update_job);
|
||||||
|
update_job = NULL;
|
||||||
|
}
|
||||||
|
ecore_timer_add(0.0, _configure_init_timer, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_registry_call(const char *path, E_Container *con, const char *params)
|
||||||
|
{
|
||||||
|
E_Configure_Cat *ecat;
|
||||||
|
Eina_List *l;
|
||||||
|
char *cat;
|
||||||
|
const char *item;
|
||||||
|
|
||||||
|
/* path is "category/item" */
|
||||||
|
cat = ecore_file_dir_get(path);
|
||||||
|
if (!cat) return;
|
||||||
|
item = ecore_file_file_get(path);
|
||||||
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
||||||
|
if (!strcmp(cat, ecat->cat))
|
||||||
|
{
|
||||||
|
E_Configure_It *eci;
|
||||||
|
Eina_List *ll;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(ecat->items, ll, eci)
|
||||||
|
if (!strcmp(item, eci->item))
|
||||||
|
{
|
||||||
|
if (eci->func) eci->func(con, params);
|
||||||
|
else if (eci->generic_func) eci->generic_func(con, params);
|
||||||
|
else if (eci->desktop)
|
||||||
|
{
|
||||||
|
if (custom_desktop_exec.func)
|
||||||
|
custom_desktop_exec.func(custom_desktop_exec.data,
|
||||||
|
con, params, eci->desktop);
|
||||||
|
else
|
||||||
|
e_exec(e_util_zone_current_get(con->manager),
|
||||||
|
eci->desktop, NULL, NULL, "config");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(cat);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_registry_item_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon, E_Config_Dialog *(*func) (E_Container *con, const char *params))
|
||||||
|
{
|
||||||
|
_e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_registry_generic_item_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon, void (*generic_func) (E_Container *con, const char *params))
|
||||||
|
{
|
||||||
|
_e_configure_registry_item_full_add(path, pri, label, icon_file, icon, NULL, generic_func, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_registry_item_del(const char *path)
|
||||||
|
{
|
||||||
|
E_Configure_Cat *ecat;
|
||||||
|
Eina_List *l;
|
||||||
|
const char *item;
|
||||||
|
char *cat;
|
||||||
|
|
||||||
|
/* path is "category/item" */
|
||||||
|
cat = ecore_file_dir_get(path);
|
||||||
|
if (!cat) return;
|
||||||
|
item = ecore_file_file_get(path);
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
||||||
|
if (!strcmp(cat, ecat->cat))
|
||||||
|
{
|
||||||
|
E_Configure_It *eci;
|
||||||
|
Eina_List *ll;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(ecat->items, ll, eci)
|
||||||
|
if (!strcmp(item, eci->item))
|
||||||
|
{
|
||||||
|
ecat->items = eina_list_remove_list(ecat->items, ll);
|
||||||
|
|
||||||
|
eina_stringshare_del(eci->item);
|
||||||
|
eina_stringshare_del(eci->label);
|
||||||
|
eina_stringshare_del(eci->icon);
|
||||||
|
if (eci->icon_file) eina_stringshare_del(eci->icon_file);
|
||||||
|
if (eci->desktop) efreet_desktop_free(eci->desktop);
|
||||||
|
free(eci);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(cat);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_registry_category_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon)
|
||||||
|
{
|
||||||
|
E_Configure_Cat *ecat2;
|
||||||
|
E_Configure_Cat *ecat;
|
||||||
|
Eina_List *l;
|
||||||
|
|
||||||
|
/* if it exists - ignore this */
|
||||||
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat2)
|
||||||
|
if (!strcmp(ecat2->cat, path)) return;
|
||||||
|
|
||||||
|
ecat = E_NEW(E_Configure_Cat, 1);
|
||||||
|
if (!ecat) return;
|
||||||
|
|
||||||
|
ecat->cat = eina_stringshare_add(path);
|
||||||
|
ecat->pri = pri;
|
||||||
|
ecat->label = eina_stringshare_add(label);
|
||||||
|
if (icon_file) ecat->icon_file = eina_stringshare_add(icon_file);
|
||||||
|
if (icon) ecat->icon = eina_stringshare_add(icon);
|
||||||
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat2)
|
||||||
|
if (ecat2->pri > ecat->pri)
|
||||||
|
{
|
||||||
|
e_configure_registry =
|
||||||
|
eina_list_prepend_relative_list(e_configure_registry, ecat, l);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
e_configure_registry = eina_list_append(e_configure_registry, ecat);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_registry_category_del(const char *path)
|
||||||
|
{
|
||||||
|
E_Configure_Cat *ecat;
|
||||||
|
Eina_List *l;
|
||||||
|
char *cat;
|
||||||
|
|
||||||
|
cat = ecore_file_dir_get(path);
|
||||||
|
if (!cat) return;
|
||||||
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
||||||
|
if (!strcmp(cat, ecat->cat))
|
||||||
|
{
|
||||||
|
if (ecat->items) break;
|
||||||
|
e_configure_registry = eina_list_remove_list(e_configure_registry, l);
|
||||||
|
eina_stringshare_del(ecat->cat);
|
||||||
|
eina_stringshare_del(ecat->label);
|
||||||
|
if (ecat->icon) eina_stringshare_del(ecat->icon);
|
||||||
|
if (ecat->icon_file) eina_stringshare_del(ecat->icon_file);
|
||||||
|
free(ecat);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
free(cat);
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
e_configure_registry_custom_desktop_exec_callback_set(void (*func) (const void *data, E_Container *con, const char *params, Efreet_Desktop *desktop), const void *data)
|
||||||
|
{
|
||||||
|
custom_desktop_exec.func = func;
|
||||||
|
custom_desktop_exec.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
e_configure_registry_exists(const char *path)
|
||||||
|
{
|
||||||
|
E_Configure_Cat *ecat;
|
||||||
|
Eina_List *l;
|
||||||
|
char *cat;
|
||||||
|
const char *item;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
/* path is "category/item" */
|
||||||
|
cat = ecore_file_dir_get(path);
|
||||||
|
if (!cat) return 0;
|
||||||
|
item = ecore_file_file_get(path);
|
||||||
|
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
||||||
|
if (!strcmp(cat, ecat->cat))
|
||||||
|
{
|
||||||
|
E_Configure_It *eci;
|
||||||
|
Eina_List *ll;
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
ret = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EINA_LIST_FOREACH(ecat->items, ll, eci)
|
||||||
|
if (!strcmp(item, eci->item))
|
||||||
|
{
|
||||||
|
ret = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(cat);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_configure_menu_module_item_cb(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__)
|
_e_configure_menu_module_item_cb(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__)
|
||||||
{
|
{
|
||||||
|
@ -43,26 +258,6 @@ _configure_init_timer(void *data __UNUSED__)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_init(void)
|
|
||||||
{
|
|
||||||
e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, "preferences-extensions");
|
|
||||||
e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "preferences-plugin", e_int_config_modules);
|
|
||||||
|
|
||||||
maug = e_int_menus_menu_augmentation_add_sorted
|
|
||||||
("config/1", _("Modules"), _e_configure_menu_add, NULL, NULL, NULL);
|
|
||||||
|
|
||||||
handlers = eina_list_append
|
|
||||||
(handlers, ecore_event_handler_add
|
|
||||||
(EFREET_EVENT_DESKTOP_CACHE_UPDATE, _e_configure_cb_efreet_desktop_cache_update, NULL));
|
|
||||||
if (update_job)
|
|
||||||
{
|
|
||||||
ecore_job_del(update_job);
|
|
||||||
update_job = NULL;
|
|
||||||
}
|
|
||||||
ecore_timer_add(0.0, _configure_init_timer, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_configure_efreet_desktop_cleanup(void)
|
_e_configure_efreet_desktop_cleanup(void)
|
||||||
{
|
{
|
||||||
|
@ -258,193 +453,3 @@ _e_configure_registry_item_full_add(const char *path, int pri, const char *label
|
||||||
free(cat);
|
free(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_registry_item_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon, E_Config_Dialog *(*func) (E_Container *con, const char *params))
|
|
||||||
{
|
|
||||||
_e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_registry_generic_item_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon, void (*generic_func) (E_Container *con, const char *params))
|
|
||||||
{
|
|
||||||
_e_configure_registry_item_full_add(path, pri, label, icon_file, icon, NULL, generic_func, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_registry_item_del(const char *path)
|
|
||||||
{
|
|
||||||
E_Configure_Cat *ecat;
|
|
||||||
Eina_List *l;
|
|
||||||
const char *item;
|
|
||||||
char *cat;
|
|
||||||
|
|
||||||
/* path is "category/item" */
|
|
||||||
cat = ecore_file_dir_get(path);
|
|
||||||
if (!cat) return;
|
|
||||||
item = ecore_file_file_get(path);
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
|
||||||
if (!strcmp(cat, ecat->cat))
|
|
||||||
{
|
|
||||||
E_Configure_It *eci;
|
|
||||||
Eina_List *ll;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(ecat->items, ll, eci)
|
|
||||||
if (!strcmp(item, eci->item))
|
|
||||||
{
|
|
||||||
ecat->items = eina_list_remove_list(ecat->items, ll);
|
|
||||||
|
|
||||||
eina_stringshare_del(eci->item);
|
|
||||||
eina_stringshare_del(eci->label);
|
|
||||||
eina_stringshare_del(eci->icon);
|
|
||||||
if (eci->icon_file) eina_stringshare_del(eci->icon_file);
|
|
||||||
if (eci->desktop) efreet_desktop_free(eci->desktop);
|
|
||||||
free(eci);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free(cat);
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_registry_category_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon)
|
|
||||||
{
|
|
||||||
E_Configure_Cat *ecat2;
|
|
||||||
E_Configure_Cat *ecat;
|
|
||||||
Eina_List *l;
|
|
||||||
|
|
||||||
/* if it exists - ignore this */
|
|
||||||
EINA_LIST_FOREACH(e_configure_registry, l, ecat2)
|
|
||||||
if (!strcmp(ecat2->cat, path)) return;
|
|
||||||
|
|
||||||
ecat = E_NEW(E_Configure_Cat, 1);
|
|
||||||
if (!ecat) return;
|
|
||||||
|
|
||||||
ecat->cat = eina_stringshare_add(path);
|
|
||||||
ecat->pri = pri;
|
|
||||||
ecat->label = eina_stringshare_add(label);
|
|
||||||
if (icon_file) ecat->icon_file = eina_stringshare_add(icon_file);
|
|
||||||
if (icon) ecat->icon = eina_stringshare_add(icon);
|
|
||||||
EINA_LIST_FOREACH(e_configure_registry, l, ecat2)
|
|
||||||
if (ecat2->pri > ecat->pri)
|
|
||||||
{
|
|
||||||
e_configure_registry =
|
|
||||||
eina_list_prepend_relative_list(e_configure_registry, ecat, l);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e_configure_registry = eina_list_append(e_configure_registry, ecat);
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_registry_category_del(const char *path)
|
|
||||||
{
|
|
||||||
E_Configure_Cat *ecat;
|
|
||||||
Eina_List *l;
|
|
||||||
char *cat;
|
|
||||||
|
|
||||||
cat = ecore_file_dir_get(path);
|
|
||||||
if (!cat) return;
|
|
||||||
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
|
||||||
if (!strcmp(cat, ecat->cat))
|
|
||||||
{
|
|
||||||
if (ecat->items) break;
|
|
||||||
e_configure_registry = eina_list_remove_list(e_configure_registry, l);
|
|
||||||
eina_stringshare_del(ecat->cat);
|
|
||||||
eina_stringshare_del(ecat->label);
|
|
||||||
if (ecat->icon) eina_stringshare_del(ecat->icon);
|
|
||||||
if (ecat->icon_file) eina_stringshare_del(ecat->icon_file);
|
|
||||||
free(ecat);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free(cat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct {
|
|
||||||
void (*func) (const void *data, E_Container *con, const char *params, Efreet_Desktop *desktop);
|
|
||||||
const char *data;
|
|
||||||
} custom_desktop_exec = { NULL, NULL };
|
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_registry_call(const char *path, E_Container *con, const char *params)
|
|
||||||
{
|
|
||||||
E_Configure_Cat *ecat;
|
|
||||||
Eina_List *l;
|
|
||||||
char *cat;
|
|
||||||
const char *item;
|
|
||||||
|
|
||||||
/* path is "category/item" */
|
|
||||||
cat = ecore_file_dir_get(path);
|
|
||||||
if (!cat) return;
|
|
||||||
item = ecore_file_file_get(path);
|
|
||||||
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
|
||||||
if (!strcmp(cat, ecat->cat))
|
|
||||||
{
|
|
||||||
E_Configure_It *eci;
|
|
||||||
Eina_List *ll;
|
|
||||||
|
|
||||||
EINA_LIST_FOREACH(ecat->items, ll, eci)
|
|
||||||
if (!strcmp(item, eci->item))
|
|
||||||
{
|
|
||||||
if (eci->func) eci->func(con, params);
|
|
||||||
else if (eci->generic_func) eci->generic_func(con, params);
|
|
||||||
else if (eci->desktop)
|
|
||||||
{
|
|
||||||
if (custom_desktop_exec.func)
|
|
||||||
custom_desktop_exec.func(custom_desktop_exec.data,
|
|
||||||
con, params, eci->desktop);
|
|
||||||
else
|
|
||||||
e_exec(e_util_zone_current_get(con->manager),
|
|
||||||
eci->desktop, NULL, NULL, "config");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
free(cat);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EAPI void
|
|
||||||
e_configure_registry_custom_desktop_exec_callback_set(void (*func) (const void *data, E_Container *con, const char *params, Efreet_Desktop *desktop), const void *data)
|
|
||||||
{
|
|
||||||
custom_desktop_exec.func = func;
|
|
||||||
custom_desktop_exec.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI int
|
|
||||||
e_configure_registry_exists(const char *path)
|
|
||||||
{
|
|
||||||
E_Configure_Cat *ecat;
|
|
||||||
Eina_List *l;
|
|
||||||
char *cat;
|
|
||||||
const char *item;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
/* path is "category/item" */
|
|
||||||
cat = ecore_file_dir_get(path);
|
|
||||||
if (!cat) return 0;
|
|
||||||
item = ecore_file_file_get(path);
|
|
||||||
EINA_LIST_FOREACH(e_configure_registry, l, ecat)
|
|
||||||
if (!strcmp(cat, ecat->cat))
|
|
||||||
{
|
|
||||||
E_Configure_It *eci;
|
|
||||||
Eina_List *ll;
|
|
||||||
|
|
||||||
if (!item)
|
|
||||||
{
|
|
||||||
ret = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
EINA_LIST_FOREACH(ecat->items, ll, eci)
|
|
||||||
if (!strcmp(item, eci->item))
|
|
||||||
{
|
|
||||||
ret = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(cat);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue