Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_configure.c e_configure.h e_main.c Log Message: 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. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_configure.c,v retrieving revision 1.116 retrieving revision 1.117 diff -u -3 -r1.116 -r1.117 --- e_configure.c 30 Apr 2008 12:01:32 -0000 1.116 +++ e_configure.c 23 May 2008 08:29:45 -0000 1.117 @@ -1,16 +1,156 @@ #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; +static Evas_List *handlers = NULL; + EAPI void e_configure_init(void) { 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); + + 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 +_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)) +_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; char *cat; @@ -31,6 +171,8 @@ if (icon) eci->icon = evas_stringshare_add(icon); eci->func = 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) { @@ -63,13 +205,13 @@ 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); + _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); + _e_configure_registry_item_full_add(path, pri, label, icon_file, icon, NULL, generic_func, NULL); } EAPI void @@ -104,6 +246,7 @@ evas_stringshare_del(eci->label); evas_stringshare_del(eci->icon); if (eci->icon_file) evas_stringshare_del(eci->icon_file); + if (eci->desktop) efreet_desktop_free(eci->desktop); free(eci); goto done; } @@ -120,6 +263,15 @@ { E_Configure_Cat *ecat; 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); if (!ecat) return; @@ -172,6 +324,11 @@ 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) { @@ -201,6 +358,17 @@ { 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"); + } goto done; } } @@ -210,6 +378,8 @@ done: free(cat); } + + EAPI int e_configure_registry_exists(const char *path) =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_configure.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- e_configure.h 30 Apr 2008 12:01:32 -0000 1.11 +++ e_configure.h 23 May 2008 08:29:45 -0000 1.12 @@ -26,6 +26,7 @@ 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; }; 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_del(const char *path); 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 void e_configure_registry_custom_desktop_exec_callback_set(void (func) (), const void *data); EAPI void e_configure_init(void); EAPI Evas_List *e_configure_registry; =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_main.c,v retrieving revision 1.242 retrieving revision 1.243 diff -u -3 -r1.242 -r1.243 --- e_main.c 11 Jan 2008 07:33:55 -0000 1.242 +++ e_main.c 23 May 2008 08:29:45 -0000 1.243 @@ -421,9 +421,6 @@ ecore_x_io_error_handler_set(_e_main_cb_x_fatal, NULL); - TS("configure"); - e_configure_init(); - TS("x hints"); /* Init window manager hints */ e_hints_init(); @@ -475,6 +472,9 @@ } _e_main_shutdown_push(efreet_util_shutdown); TS("efreet done"); + + TS("configure"); + e_configure_init(); TS("dirs"); /* setup directories we will be using for configurations storage etc. */ ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs