formatting

SVN revision: 73281
This commit is contained in:
Mike Blumenkrantz 2012-07-04 12:42:30 +00:00
parent 5d2f230a26
commit 688ee47e83
1 changed files with 140 additions and 136 deletions

View File

@ -1,14 +1,14 @@
#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_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_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, const char *params); 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, const char *params);
static void _e_configure_registry_item_free(E_Configure_It *eci); static void _e_configure_registry_item_free(E_Configure_It *eci);
static void _configure_job(void *data); static void _configure_job(void *data);
static Eina_Bool _configure_init_timer(void *data); static Eina_Bool _configure_init_timer(void *data);
EAPI Eina_List *e_configure_registry = NULL; EAPI Eina_List *e_configure_registry = NULL;
@ -17,8 +17,9 @@ 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 { static struct
void (*func) (const void *data, E_Container *con, const char *params, Efreet_Desktop *desktop); {
void (*func)(const void *data, E_Container *con, const char *params, Efreet_Desktop *desktop);
const char *data; const char *data;
} custom_desktop_exec = { NULL, NULL }; } custom_desktop_exec = { NULL, NULL };
@ -29,13 +30,13 @@ e_configure_init(void)
e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "preferences-plugin", e_int_config_modules); e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "preferences-plugin", e_int_config_modules);
maug = e_int_menus_menu_augmentation_add_sorted maug = e_int_menus_menu_augmentation_add_sorted
("config/1", _("Modules"), _e_configure_menu_add, NULL, NULL, NULL); ("config/1", _("Modules"), _e_configure_menu_add, NULL, NULL, NULL);
if (update_job) if (update_job)
{ {
ecore_job_del(update_job); ecore_job_del(update_job);
update_job = NULL; update_job = NULL;
} }
ecore_timer_add(0.0, _configure_init_timer, NULL); ecore_timer_add(0.0, _configure_init_timer, NULL);
} }
@ -54,46 +55,47 @@ e_configure_registry_call(const char *path, E_Container *con, const char *params
EINA_LIST_FOREACH(e_configure_registry, l, ecat) EINA_LIST_FOREACH(e_configure_registry, l, ecat)
if (!strcmp(cat, ecat->cat)) if (!strcmp(cat, ecat->cat))
{ {
E_Configure_It *eci; E_Configure_It *eci;
Eina_List *ll; Eina_List *ll;
EINA_LIST_FOREACH(ecat->items, ll, eci) EINA_LIST_FOREACH(ecat->items, ll, eci)
if (!strcmp(item, eci->item)) if (!strcmp(item, eci->item))
{ {
if (!params) params = eci->params; if (!params) params = eci->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)
else if (eci->desktop) eci->generic_func(con, params);
{ else if (eci->desktop)
if (custom_desktop_exec.func) {
custom_desktop_exec.func(custom_desktop_exec.data, if (custom_desktop_exec.func)
con, params, eci->desktop); custom_desktop_exec.func(custom_desktop_exec.data,
else con, params, eci->desktop);
e_exec(e_util_zone_current_get(con->manager), else
eci->desktop, NULL, NULL, "config"); e_exec(e_util_zone_current_get(con->manager),
} eci->desktop, NULL, NULL, "config");
break; }
} break;
break; }
break;
} }
free(cat); free(cat);
} }
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, NULL, NULL); _e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, 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, NULL, NULL); _e_configure_registry_item_full_add(path, pri, label, icon_file, icon, NULL, generic_func, NULL, NULL);
} }
EAPI void EAPI void
e_configure_registry_item_params_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), const char *params) e_configure_registry_item_params_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), const char *params)
{ {
_e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, NULL, params); _e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, NULL, params);
} }
@ -114,18 +116,18 @@ e_configure_registry_item_del(const char *path)
EINA_LIST_FOREACH(e_configure_registry, l, ecat) EINA_LIST_FOREACH(e_configure_registry, l, ecat)
if (!strcmp(cat, ecat->cat)) if (!strcmp(cat, ecat->cat))
{ {
E_Configure_It *eci; E_Configure_It *eci;
Eina_List *ll; Eina_List *ll;
EINA_LIST_FOREACH(ecat->items, ll, eci) EINA_LIST_FOREACH(ecat->items, ll, eci)
if (!strcmp(item, eci->item)) if (!strcmp(item, eci->item))
{ {
ecat->items = eina_list_remove_list(ecat->items, ll); ecat->items = eina_list_remove_list(ecat->items, ll);
_e_configure_registry_item_free(eci); _e_configure_registry_item_free(eci);
break; break;
} }
break; break;
} }
free(cat); free(cat);
} }
@ -152,9 +154,9 @@ e_configure_registry_category_add(const char *path, int pri, const char *label,
EINA_LIST_FOREACH(e_configure_registry, l, ecat2) EINA_LIST_FOREACH(e_configure_registry, l, ecat2)
if (ecat2->pri > ecat->pri) if (ecat2->pri > ecat->pri)
{ {
e_configure_registry = e_configure_registry =
eina_list_prepend_relative_list(e_configure_registry, ecat, l); eina_list_prepend_relative_list(e_configure_registry, ecat, l);
return; return;
} }
e_configure_registry = eina_list_append(e_configure_registry, ecat); e_configure_registry = eina_list_append(e_configure_registry, ecat);
} }
@ -171,20 +173,20 @@ e_configure_registry_category_del(const char *path)
EINA_LIST_FOREACH(e_configure_registry, l, ecat) EINA_LIST_FOREACH(e_configure_registry, l, ecat)
if (!strcmp(cat, ecat->cat)) if (!strcmp(cat, ecat->cat))
{ {
if (ecat->items) break; if (ecat->items) break;
e_configure_registry = eina_list_remove_list(e_configure_registry, l); e_configure_registry = eina_list_remove_list(e_configure_registry, l);
eina_stringshare_del(ecat->cat); eina_stringshare_del(ecat->cat);
eina_stringshare_del(ecat->label); eina_stringshare_del(ecat->label);
if (ecat->icon) eina_stringshare_del(ecat->icon); if (ecat->icon) eina_stringshare_del(ecat->icon);
if (ecat->icon_file) eina_stringshare_del(ecat->icon_file); if (ecat->icon_file) eina_stringshare_del(ecat->icon_file);
free(ecat); free(ecat);
break; break;
} }
free(cat); free(cat);
} }
EAPI void 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) 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.func = func;
custom_desktop_exec.data = data; custom_desktop_exec.data = data;
@ -206,21 +208,21 @@ e_configure_registry_exists(const char *path)
EINA_LIST_FOREACH(e_configure_registry, l, ecat) EINA_LIST_FOREACH(e_configure_registry, l, ecat)
if (!strcmp(cat, ecat->cat)) if (!strcmp(cat, ecat->cat))
{ {
E_Configure_It *eci; E_Configure_It *eci;
Eina_List *ll; Eina_List *ll;
if (!item) if (!item)
{ {
ret = 1; ret = 1;
break; break;
} }
EINA_LIST_FOREACH(ecat->items, ll, eci) EINA_LIST_FOREACH(ecat->items, ll, eci)
if (!strcmp(item, eci->item)) if (!strcmp(item, eci->item))
{ {
ret = 1; ret = 1;
break; break;
} }
break; break;
} }
free(cat); free(cat);
@ -255,7 +257,7 @@ static Eina_Bool
_configure_init_timer(void *data __UNUSED__) _configure_init_timer(void *data __UNUSED__)
{ {
handlers = eina_list_append handlers = eina_list_append
(handlers, ecore_event_handler_add (handlers, ecore_event_handler_add
(EFREET_EVENT_DESKTOP_CACHE_UPDATE, _e_configure_cb_efreet_desktop_cache_update, NULL)); (EFREET_EVENT_DESKTOP_CACHE_UPDATE, _e_configure_cb_efreet_desktop_cache_update, NULL));
if (update_job) ecore_job_del(update_job); if (update_job) ecore_job_del(update_job);
update_job = ecore_job_add(_configure_job, NULL); update_job = ecore_job_add(_configure_job, NULL);
@ -269,18 +271,18 @@ _e_configure_efreet_desktop_cleanup(void)
E_Configure_Cat *ecat; E_Configure_Cat *ecat;
// printf("_e_configure_efreet_desktop_cleanup\n"); // printf("_e_configure_efreet_desktop_cleanup\n");
/* remove anything with a desktop entry */ /* remove anything with a desktop entry */
EINA_LIST_FOREACH(e_configure_registry, l, ecat) EINA_LIST_FOREACH(e_configure_registry, l, ecat)
{ {
E_Configure_It *eci; E_Configure_It *eci;
Eina_List *ll, *ln; Eina_List *ll, *ln;
EINA_LIST_FOREACH_SAFE(ecat->items, ll, ln, eci) EINA_LIST_FOREACH_SAFE (ecat->items, ll, ln, eci)
if (eci->desktop) if (eci->desktop)
{ {
_e_configure_registry_item_free(eci); _e_configure_registry_item_free(eci);
ecat->items = eina_list_remove_list(ecat->items, ll); ecat->items = eina_list_remove_list(ecat->items, ll);
} }
} }
} }
@ -297,61 +299,62 @@ _e_configure_efreet_desktop_update(void)
system_desktops = efreet_util_desktop_category_list("System"); system_desktops = efreet_util_desktop_category_list("System");
if ((!settings_desktops) && (!system_desktops)) if ((!settings_desktops) && (!system_desktops))
{ {
EINA_LIST_FREE(settings_desktops, desktop) EINA_LIST_FREE(settings_desktops, desktop)
efreet_desktop_free(desktop); efreet_desktop_free(desktop);
EINA_LIST_FREE(system_desktops, desktop) EINA_LIST_FREE(system_desktops, desktop)
efreet_desktop_free(desktop); efreet_desktop_free(desktop);
return; return;
} }
/* get ones in BOTH lists */ /* get ones in BOTH lists */
EINA_LIST_FOREACH(settings_desktops, l, desktop) EINA_LIST_FOREACH(settings_desktops, l, desktop)
{ {
char *s; char *s;
char *cfg_cat_name; char *cfg_cat_name;
const char *cfg_cat_icon; const char *cfg_cat_icon;
char *cfg_cat; char *cfg_cat;
char *cfg_cat_cfg; char *cfg_cat_cfg;
const char *cfg_icon; const char *cfg_icon;
char *label; char *label;
int cfg_pri; int cfg_pri;
int dopref; int dopref;
dopref = 0; dopref = 0;
cfg_cat = NULL; cfg_cat = NULL;
cfg_icon = NULL; cfg_icon = NULL;
cfg_cat_cfg = NULL; cfg_cat_cfg = NULL;
cfg_pri = 1000; cfg_pri = 1000;
cfg_cat_name = NULL; cfg_cat_name = NULL;
cfg_cat_icon = NULL; cfg_cat_icon = NULL;
label = NULL; label = NULL;
if (!eina_list_data_find(system_desktops, desktop)) if (!eina_list_data_find(system_desktops, desktop))
{ {
/* settings desktop but not in system -> put in preferences */ /* settings desktop but not in system -> put in preferences */
dopref = 1; dopref = 1;
} }
if (desktop->x) if (desktop->x)
{ {
cfg_cat_cfg = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category"); cfg_cat_cfg = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category");
s = eina_hash_find(desktop->x, "X-Enlightenment-Config-Priority"); s = eina_hash_find(desktop->x, "X-Enlightenment-Config-Priority");
if (s) cfg_pri = atoi(s); if (s) cfg_pri = atoi(s);
cfg_cat_name = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category-Name"); cfg_cat_name = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category-Name");
cfg_cat_icon = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category-Icon"); cfg_cat_icon = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category-Icon");
if ((cfg_cat_icon) && (cfg_cat_icon[0] != '/')) if ((cfg_cat_icon) && (cfg_cat_icon[0] != '/'))
cfg_cat_icon = efreet_icon_path_find(e_config->icon_theme, cfg_cat_icon = efreet_icon_path_find(e_config->icon_theme,
cfg_cat_icon, 64); cfg_cat_icon, 64);
} }
if (desktop->icon) if (desktop->icon)
{ {
if (desktop->icon[0] == '/') if (desktop->icon[0] == '/')
cfg_icon = desktop->icon; cfg_icon = desktop->icon;
else else
cfg_icon = efreet_icon_path_find(e_config->icon_theme, cfg_icon = efreet_icon_path_find(e_config->icon_theme,
desktop->icon, 64); desktop->icon, 64);
} }
if (desktop->name) label = desktop->name; if (desktop->name) label = desktop->name;
else if (desktop->generic_name) label = desktop->generic_name; else if (desktop->generic_name)
else label = "???"; label = desktop->generic_name;
else label = "???";
if (!cfg_cat_cfg) if (!cfg_cat_cfg)
{ {
const char *ic = cfg_cat_icon; const char *ic = cfg_cat_icon;
@ -393,9 +396,9 @@ _e_configure_efreet_desktop_update(void)
NULL, NULL, desktop, NULL); NULL, NULL, desktop, NULL);
} }
EINA_LIST_FREE(settings_desktops, desktop) EINA_LIST_FREE(settings_desktops, desktop)
efreet_desktop_free(desktop); efreet_desktop_free(desktop);
EINA_LIST_FREE(system_desktops, desktop) EINA_LIST_FREE(system_desktops, desktop)
efreet_desktop_free(desktop); efreet_desktop_free(desktop);
} }
static Eina_Bool static Eina_Bool
@ -408,7 +411,7 @@ _e_configure_cb_efreet_desktop_cache_update(void *data __UNUSED__, int type __UN
} }
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), Efreet_Desktop *desktop, const char *params) _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, const char *params)
{ {
Eina_List *l; Eina_List *l;
char *cat; char *cat;
@ -437,20 +440,20 @@ _e_configure_registry_item_full_add(const char *path, int pri, const char *label
EINA_LIST_FOREACH(e_configure_registry, l, ecat) EINA_LIST_FOREACH(e_configure_registry, l, ecat)
if (!strcmp(cat, ecat->cat)) if (!strcmp(cat, ecat->cat))
{ {
E_Configure_It *eci2; E_Configure_It *eci2;
Eina_List *ll; Eina_List *ll;
EINA_LIST_FOREACH(ecat->items, ll, eci2) EINA_LIST_FOREACH(ecat->items, ll, eci2)
if (eci2->pri > eci->pri) if (eci2->pri > eci->pri)
{ {
ecat->items = eina_list_prepend_relative_list(ecat->items, eci, ll); ecat->items = eina_list_prepend_relative_list(ecat->items, eci, ll);
goto done; goto done;
} }
ecat->items = eina_list_append(ecat->items, eci); ecat->items = eina_list_append(ecat->items, eci);
goto done; goto done;
} }
done: done:
free(cat); free(cat);
} }
@ -465,3 +468,4 @@ _e_configure_registry_item_free(E_Configure_It *eci)
if (eci->params) eina_stringshare_del(eci->params); if (eci->params) eina_stringshare_del(eci->params);
free(eci); free(eci);
} }