forked from enlightenment/enlightenment
e can now find any system config .desktops.. and put them automatically in
its config panel. the requirments: must be BOTH in category "System" and "Settings". if so - it will go in the config panel. SVN revision: 34645
This commit is contained in:
parent
cda8fd0779
commit
f195fc3275
|
@ -1,16 +1,156 @@
|
||||||
#include "e.h"
|
#include "e.h"
|
||||||
|
|
||||||
|
static void _e_configure_efreet_desktop_update(void);
|
||||||
|
static int _e_configure_cb_efreet_desktop_list_change(void *data, int type, void *event);
|
||||||
|
static int _e_configure_cb_efreet_desktop_change(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);
|
||||||
|
|
||||||
Evas_List *e_configure_registry = NULL;
|
Evas_List *e_configure_registry = NULL;
|
||||||
|
|
||||||
|
static Evas_List *handlers = NULL;
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
e_configure_init(void)
|
e_configure_init(void)
|
||||||
{
|
{
|
||||||
e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, "enlightenment/extensions");
|
e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, "enlightenment/extensions");
|
||||||
e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "enlightenment/modules", e_int_config_modules);
|
e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "enlightenment/modules", e_int_config_modules);
|
||||||
|
|
||||||
|
handlers = evas_list_append
|
||||||
|
(handlers, ecore_event_handler_add
|
||||||
|
(EFREET_EVENT_DESKTOP_LIST_CHANGE, _e_configure_cb_efreet_desktop_list_change, NULL));
|
||||||
|
handlers = evas_list_append
|
||||||
|
(handlers, ecore_event_handler_add
|
||||||
|
(EFREET_EVENT_DESKTOP_CHANGE, _e_configure_cb_efreet_desktop_change, NULL));
|
||||||
|
// _e_configure_efreet_desktop_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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))
|
_e_configure_efreet_desktop_update(void)
|
||||||
|
{
|
||||||
|
Ecore_List *settings_desktops, *system_desktops;
|
||||||
|
Efreet_Desktop *desktop;
|
||||||
|
Evas_List *l, *ll, *remove_items = NULL, *remove_cats = NULL;
|
||||||
|
char buf[1024];
|
||||||
|
|
||||||
|
/* remove anything with a desktop entry */
|
||||||
|
for (l = e_configure_registry; l; l = l->next)
|
||||||
|
{
|
||||||
|
E_Configure_Cat *ecat;
|
||||||
|
|
||||||
|
ecat = l->data;
|
||||||
|
for (ll = ecat->items; ll; ll = ll->next)
|
||||||
|
{
|
||||||
|
E_Configure_It *eci;
|
||||||
|
|
||||||
|
eci = ll->data;
|
||||||
|
if (eci->desktop)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "%s/%s", ecat->cat, eci->item);
|
||||||
|
remove_items = evas_list_append(remove_items, strdup(buf));
|
||||||
|
remove_cats = evas_list_append(remove_cats, strdup(ecat->cat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (remove_items)
|
||||||
|
{
|
||||||
|
e_configure_registry_item_del(remove_items->data);
|
||||||
|
free(remove_items->data);
|
||||||
|
remove_items = evas_list_remove_list(remove_items, remove_items);
|
||||||
|
}
|
||||||
|
while (remove_cats)
|
||||||
|
{
|
||||||
|
e_configure_registry_category_del(remove_cats->data);
|
||||||
|
free(remove_cats->data);
|
||||||
|
remove_cats = evas_list_remove_list(remove_cats, remove_cats);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get desktops */
|
||||||
|
settings_desktops = efreet_util_desktop_category_list("Settings");
|
||||||
|
system_desktops = efreet_util_desktop_category_list("System");
|
||||||
|
if ((!settings_desktops) || (!system_desktops)) return;
|
||||||
|
|
||||||
|
/* get ones in BOTH lists */
|
||||||
|
ecore_list_first_goto(settings_desktops);
|
||||||
|
while ((desktop = ecore_list_next(settings_desktops)))
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
char *cfg_cat_item;
|
||||||
|
char *cfg_cat;
|
||||||
|
char *cfg_cat_cfg;
|
||||||
|
char *cfg_icon;
|
||||||
|
char *label;
|
||||||
|
int cfg_pri;
|
||||||
|
|
||||||
|
if (!ecore_list_goto(system_desktops, desktop)) continue;
|
||||||
|
cfg_cat = NULL;
|
||||||
|
cfg_icon = NULL;
|
||||||
|
cfg_cat_cfg = NULL;
|
||||||
|
cfg_pri = 1000;
|
||||||
|
label = NULL;
|
||||||
|
if (desktop->x)
|
||||||
|
{
|
||||||
|
cfg_cat_cfg = ecore_hash_get(desktop->x, "X-Enlightenment-Config-Category");
|
||||||
|
s = ecore_hash_get(desktop->x, "X-Enlightenment-Config-Priority");
|
||||||
|
if (s) cfg_pri = atoi(s);
|
||||||
|
}
|
||||||
|
if (desktop->icon)
|
||||||
|
{
|
||||||
|
if (desktop->icon[0] == '/')
|
||||||
|
cfg_icon = strdup(desktop->icon);
|
||||||
|
else
|
||||||
|
cfg_icon = efreet_icon_path_find(e_config->icon_theme,
|
||||||
|
desktop->icon, "64x64");
|
||||||
|
}
|
||||||
|
if (desktop->name) label = desktop->name;
|
||||||
|
else if (desktop->generic_name) label = desktop->generic_name;
|
||||||
|
else label = "???";
|
||||||
|
if (!cfg_cat_cfg)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "system/%s", label);
|
||||||
|
cfg_cat_cfg = buf;
|
||||||
|
e_configure_registry_category_add("system",
|
||||||
|
1000, _("System"),
|
||||||
|
NULL,
|
||||||
|
"enlightenment/system"); // FIXME: another icon?
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg_cat = ecore_file_dir_get(cfg_cat_cfg);
|
||||||
|
if (!cfg_cat) cfg_cat = strdup(cfg_cat_cfg);
|
||||||
|
if (cfg_cat)
|
||||||
|
{
|
||||||
|
e_configure_registry_category_add(cfg_cat,
|
||||||
|
1000, cfg_cat,
|
||||||
|
NULL,
|
||||||
|
NULL); // FIXME: icon?
|
||||||
|
free(cfg_cat);
|
||||||
|
cfg_cat = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_e_configure_registry_item_full_add(cfg_cat_cfg, cfg_pri, label,
|
||||||
|
NULL, cfg_icon,
|
||||||
|
NULL, NULL,
|
||||||
|
desktop);
|
||||||
|
if (cfg_icon) free(cfg_icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_e_configure_cb_efreet_desktop_list_change(void *data, int type, void *event)
|
||||||
|
{
|
||||||
|
_e_configure_efreet_desktop_update();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_e_configure_cb_efreet_desktop_change(void *data, int type, void *event)
|
||||||
|
{
|
||||||
|
_e_configure_efreet_desktop_update();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
Evas_List *l;
|
Evas_List *l;
|
||||||
char *cat;
|
char *cat;
|
||||||
|
@ -31,6 +171,8 @@ _e_configure_registry_item_full_add(const char *path, int pri, const char *label
|
||||||
if (icon) eci->icon = evas_stringshare_add(icon);
|
if (icon) eci->icon = evas_stringshare_add(icon);
|
||||||
eci->func = func;
|
eci->func = func;
|
||||||
eci->generic_func = generic_func;
|
eci->generic_func = generic_func;
|
||||||
|
eci->desktop = desktop;
|
||||||
|
if (eci->desktop) efreet_desktop_ref(eci->desktop);
|
||||||
|
|
||||||
for (l = e_configure_registry; l; l = l->next)
|
for (l = e_configure_registry; l; l = l->next)
|
||||||
{
|
{
|
||||||
|
@ -63,13 +205,13 @@ _e_configure_registry_item_full_add(const char *path, int pri, const char *label
|
||||||
EAPI void
|
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_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);
|
_e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
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_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);
|
_e_configure_registry_item_full_add(path, pri, label, icon_file, icon, NULL, generic_func, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
|
@ -104,6 +246,7 @@ e_configure_registry_item_del(const char *path)
|
||||||
evas_stringshare_del(eci->label);
|
evas_stringshare_del(eci->label);
|
||||||
evas_stringshare_del(eci->icon);
|
evas_stringshare_del(eci->icon);
|
||||||
if (eci->icon_file) evas_stringshare_del(eci->icon_file);
|
if (eci->icon_file) evas_stringshare_del(eci->icon_file);
|
||||||
|
if (eci->desktop) efreet_desktop_free(eci->desktop);
|
||||||
free(eci);
|
free(eci);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -121,6 +264,15 @@ e_configure_registry_category_add(const char *path, int pri, const char *label,
|
||||||
E_Configure_Cat *ecat;
|
E_Configure_Cat *ecat;
|
||||||
Evas_List *l;
|
Evas_List *l;
|
||||||
|
|
||||||
|
/* if it exists - ignore this */
|
||||||
|
for (l = e_configure_registry; l; l = l->next)
|
||||||
|
{
|
||||||
|
E_Configure_Cat *ecat2;
|
||||||
|
|
||||||
|
ecat2 = l->data;
|
||||||
|
if (!strcmp(ecat2->cat, path)) return;
|
||||||
|
}
|
||||||
|
|
||||||
ecat = E_NEW(E_Configure_Cat, 1);
|
ecat = E_NEW(E_Configure_Cat, 1);
|
||||||
if (!ecat) return;
|
if (!ecat) return;
|
||||||
|
|
||||||
|
@ -172,6 +324,11 @@ e_configure_registry_category_del(const char *path)
|
||||||
free(cat);
|
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
|
EAPI void
|
||||||
e_configure_registry_call(const char *path, E_Container *con, const char *params)
|
e_configure_registry_call(const char *path, E_Container *con, const char *params)
|
||||||
{
|
{
|
||||||
|
@ -201,6 +358,17 @@ e_configure_registry_call(const char *path, E_Container *con, const char *params
|
||||||
{
|
{
|
||||||
if (eci->func) eci->func(con, params);
|
if (eci->func) eci->func(con, params);
|
||||||
else if (eci->generic_func) eci->generic_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");
|
||||||
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,6 +379,8 @@ e_configure_registry_call(const char *path, E_Container *con, const char *params
|
||||||
free(cat);
|
free(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
e_configure_registry_exists(const char *path)
|
e_configure_registry_exists(const char *path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,7 @@ struct _E_Configure_It
|
||||||
const char *icon;
|
const char *icon;
|
||||||
E_Config_Dialog *(*func) (E_Container *con, const char *params);
|
E_Config_Dialog *(*func) (E_Container *con, const char *params);
|
||||||
void (*generic_func) (E_Container *con, const char *params);
|
void (*generic_func) (E_Container *con, const char *params);
|
||||||
|
Efreet_Desktop *desktop;
|
||||||
};
|
};
|
||||||
|
|
||||||
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));
|
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));
|
||||||
|
@ -35,7 +36,7 @@ EAPI void e_configure_registry_category_add(const char *path, int pri, const cha
|
||||||
EAPI void e_configure_registry_category_del(const char *path);
|
EAPI void e_configure_registry_category_del(const char *path);
|
||||||
EAPI void e_configure_registry_call(const char *path, E_Container *con, const char *params);
|
EAPI void e_configure_registry_call(const char *path, E_Container *con, const char *params);
|
||||||
EAPI int e_configure_registry_exists(const char *path);
|
EAPI int e_configure_registry_exists(const char *path);
|
||||||
|
EAPI void e_configure_registry_custom_desktop_exec_callback_set(void (func) (), const void *data);
|
||||||
EAPI void e_configure_init(void);
|
EAPI void e_configure_init(void);
|
||||||
|
|
||||||
EAPI Evas_List *e_configure_registry;
|
EAPI Evas_List *e_configure_registry;
|
||||||
|
|
|
@ -421,9 +421,6 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL);
|
ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL);
|
||||||
|
|
||||||
TS("configure");
|
|
||||||
e_configure_init();
|
|
||||||
|
|
||||||
TS("x hints");
|
TS("x hints");
|
||||||
/* Init window manager hints */
|
/* Init window manager hints */
|
||||||
e_hints_init();
|
e_hints_init();
|
||||||
|
@ -476,6 +473,9 @@ main(int argc, char **argv)
|
||||||
_e_main_shutdown_push(efreet_util_shutdown);
|
_e_main_shutdown_push(efreet_util_shutdown);
|
||||||
TS("efreet done");
|
TS("efreet done");
|
||||||
|
|
||||||
|
TS("configure");
|
||||||
|
e_configure_init();
|
||||||
|
|
||||||
TS("dirs");
|
TS("dirs");
|
||||||
/* setup directories we will be using for configurations storage etc. */
|
/* setup directories we will be using for configurations storage etc. */
|
||||||
if (!_e_main_dirs_init())
|
if (!_e_main_dirs_init())
|
||||||
|
|
Loading…
Reference in New Issue