3 static void _e_configure_menu_module_item_cb(void *data, E_Menu *m, E_Menu_Item *mi);
4 static void _e_configure_menu_add(void *data, E_Menu *m);
5 static void _e_configure_efreet_desktop_cleanup(void);
6 static void _e_configure_efreet_desktop_update(void);
7 static Eina_Bool _e_configure_cb_efreet_desktop_cache_update(void *data, int type, void *event);
8 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);
9 static void _e_configure_registry_item_free(E_Configure_It *eci);
11 static void _configure_job(void *data);
12 static Eina_Bool _configure_init_timer(void *data);
14 EAPI Eina_List *e_configure_registry = NULL;
16 static Eina_List *handlers = NULL;
17 static E_Int_Menu_Augmentation *maug = NULL;
18 static Ecore_Job *update_job = NULL;
21 void (*func) (const void *data, E_Container *con, const char *params, Efreet_Desktop *desktop);
23 } custom_desktop_exec = { NULL, NULL };
26 e_configure_init(void)
28 e_configure_registry_category_add("extensions", 90, _("Extensions"), NULL, "preferences-extensions");
29 e_configure_registry_item_add("extensions/modules", 10, _("Modules"), NULL, "preferences-plugin", e_int_config_modules);
31 maug = e_int_menus_menu_augmentation_add_sorted
32 ("config/1", _("Modules"), _e_configure_menu_add, NULL, NULL, NULL);
36 ecore_job_del(update_job);
39 ecore_timer_add(0.0, _configure_init_timer, NULL);
43 e_configure_registry_call(const char *path, E_Container *con, const char *params)
45 E_Configure_Cat *ecat;
50 /* path is "category/item" */
51 cat = ecore_file_dir_get(path);
53 item = ecore_file_file_get(path);
54 EINA_LIST_FOREACH(e_configure_registry, l, ecat)
55 if (!strcmp(cat, ecat->cat))
60 EINA_LIST_FOREACH(ecat->items, ll, eci)
61 if (!strcmp(item, eci->item))
63 if (!params) params = eci->params;
65 if (eci->func) eci->func(con, params);
66 else if (eci->generic_func) eci->generic_func(con, params);
67 else if (eci->desktop)
69 if (custom_desktop_exec.func)
70 custom_desktop_exec.func(custom_desktop_exec.data,
71 con, params, eci->desktop);
73 e_exec(e_util_zone_current_get(con->manager),
74 eci->desktop, NULL, NULL, "config");
84 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))
86 _e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, NULL, NULL);
90 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))
92 _e_configure_registry_item_full_add(path, pri, label, icon_file, icon, NULL, generic_func, NULL, NULL);
96 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)
98 _e_configure_registry_item_full_add(path, pri, label, icon_file, icon, func, NULL, NULL, params);
102 e_configure_registry_item_del(const char *path)
104 E_Configure_Cat *ecat;
109 /* path is "category/item" */
110 cat = ecore_file_dir_get(path);
112 item = ecore_file_file_get(path);
114 EINA_LIST_FOREACH(e_configure_registry, l, ecat)
115 if (!strcmp(cat, ecat->cat))
120 EINA_LIST_FOREACH(ecat->items, ll, eci)
121 if (!strcmp(item, eci->item))
123 ecat->items = eina_list_remove_list(ecat->items, ll);
125 _e_configure_registry_item_free(eci);
134 e_configure_registry_category_add(const char *path, int pri, const char *label, const char *icon_file, const char *icon)
136 E_Configure_Cat *ecat2;
137 E_Configure_Cat *ecat;
140 /* if it exists - ignore this */
141 EINA_LIST_FOREACH(e_configure_registry, l, ecat2)
142 if (!strcmp(ecat2->cat, path)) return;
144 ecat = E_NEW(E_Configure_Cat, 1);
147 ecat->cat = eina_stringshare_add(path);
149 ecat->label = eina_stringshare_add(label);
150 if (icon_file) ecat->icon_file = eina_stringshare_add(icon_file);
151 if (icon) ecat->icon = eina_stringshare_add(icon);
152 EINA_LIST_FOREACH(e_configure_registry, l, ecat2)
153 if (ecat2->pri > ecat->pri)
155 e_configure_registry =
156 eina_list_prepend_relative_list(e_configure_registry, ecat, l);
159 e_configure_registry = eina_list_append(e_configure_registry, ecat);
163 e_configure_registry_category_del(const char *path)
165 E_Configure_Cat *ecat;
169 cat = ecore_file_dir_get(path);
171 EINA_LIST_FOREACH(e_configure_registry, l, ecat)
172 if (!strcmp(cat, ecat->cat))
174 if (ecat->items) break;
175 e_configure_registry = eina_list_remove_list(e_configure_registry, l);
176 eina_stringshare_del(ecat->cat);
177 eina_stringshare_del(ecat->label);
178 if (ecat->icon) eina_stringshare_del(ecat->icon);
179 if (ecat->icon_file) eina_stringshare_del(ecat->icon_file);
187 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)
189 custom_desktop_exec.func = func;
190 custom_desktop_exec.data = data;
194 e_configure_registry_exists(const char *path)
196 E_Configure_Cat *ecat;
202 /* path is "category/item" */
203 cat = ecore_file_dir_get(path);
205 item = ecore_file_file_get(path);
206 EINA_LIST_FOREACH(e_configure_registry, l, ecat)
207 if (!strcmp(cat, ecat->cat))
217 EINA_LIST_FOREACH(ecat->items, ll, eci)
218 if (!strcmp(item, eci->item))
231 _e_configure_menu_module_item_cb(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__)
233 e_int_config_modules(m->zone->container, NULL);
237 _e_configure_menu_add(void *data __UNUSED__, E_Menu *m)
241 mi = e_menu_item_new(m);
242 e_menu_item_label_set(mi, _("Modules"));
243 e_util_menu_item_theme_icon_set(mi, "preferences-plugin");
244 e_menu_item_callback_set(mi, _e_configure_menu_module_item_cb, NULL);
248 _configure_job(void *data __UNUSED__)
250 _e_configure_efreet_desktop_update();
255 _configure_init_timer(void *data __UNUSED__)
257 handlers = eina_list_append
258 (handlers, ecore_event_handler_add
259 (EFREET_EVENT_DESKTOP_CACHE_UPDATE, _e_configure_cb_efreet_desktop_cache_update, NULL));
260 if (update_job) ecore_job_del(update_job);
261 update_job = ecore_job_add(_configure_job, NULL);
266 _e_configure_efreet_desktop_cleanup(void)
269 E_Configure_Cat *ecat;
271 // printf("_e_configure_efreet_desktop_cleanup\n");
272 /* remove anything with a desktop entry */
273 EINA_LIST_FOREACH(e_configure_registry, l, ecat)
278 EINA_LIST_FOREACH_SAFE(ecat->items, ll, ln, eci)
281 _e_configure_registry_item_free(eci);
282 ecat->items = eina_list_remove_list(ecat->items, ll);
288 _e_configure_efreet_desktop_update(void)
290 Eina_List *settings_desktops, *system_desktops;
291 Efreet_Desktop *desktop;
296 settings_desktops = efreet_util_desktop_category_list("Settings");
297 system_desktops = efreet_util_desktop_category_list("System");
298 if ((!settings_desktops) || (!system_desktops))
300 EINA_LIST_FREE(settings_desktops, desktop)
301 efreet_desktop_free(desktop);
302 EINA_LIST_FREE(system_desktops, desktop)
303 efreet_desktop_free(desktop);
307 /* get ones in BOTH lists */
308 EINA_LIST_FOREACH(settings_desktops, l, desktop)
312 const char *cfg_cat_icon;
315 const char *cfg_icon;
319 if (!eina_list_data_find(system_desktops, desktop)) continue;
329 cfg_cat_cfg = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category");
330 s = eina_hash_find(desktop->x, "X-Enlightenment-Config-Priority");
331 if (s) cfg_pri = atoi(s);
332 cfg_cat_name = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category-Name");
333 cfg_cat_icon = eina_hash_find(desktop->x, "X-Enlightenment-Config-Category-Icon");
334 if ((cfg_cat_icon) && (cfg_cat_icon[0] != '/'))
335 cfg_cat_icon = efreet_icon_path_find(e_config->icon_theme,
340 if (desktop->icon[0] == '/')
341 cfg_icon = desktop->icon;
343 cfg_icon = efreet_icon_path_find(e_config->icon_theme,
346 if (desktop->name) label = desktop->name;
347 else if (desktop->generic_name) label = desktop->generic_name;
353 snprintf(buf, sizeof(buf), "system/%s", label);
356 if (!ic) ic = "system";
357 e_configure_registry_category_add("system", 1000, _("System"),
362 cfg_cat = ecore_file_dir_get(cfg_cat_cfg);
363 if (!cfg_cat) cfg_cat = strdup(cfg_cat_cfg);
366 if (!cfg_cat_name) cfg_cat_name = cfg_cat;
367 e_configure_registry_category_add(cfg_cat,
374 _e_configure_registry_item_full_add(cfg_cat_cfg, cfg_pri, label,
376 NULL, NULL, desktop, NULL);
378 EINA_LIST_FREE(settings_desktops, desktop)
379 efreet_desktop_free(desktop);
380 EINA_LIST_FREE(system_desktops, desktop)
381 efreet_desktop_free(desktop);
385 _e_configure_cb_efreet_desktop_cache_update(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
387 _e_configure_efreet_desktop_cleanup();
388 if (update_job) ecore_job_del(update_job);
389 update_job = ecore_job_add(_configure_job, NULL);
394 _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)
400 E_Configure_Cat *ecat;
402 /* path is "category/item" */
403 cat = ecore_file_dir_get(path);
405 item = ecore_file_file_get(path);
406 eci = E_NEW(E_Configure_It, 1);
409 eci->item = eina_stringshare_add(item);
411 eci->label = eina_stringshare_add(label);
412 if (icon_file) eci->icon_file = eina_stringshare_add(icon_file);
413 if (icon) eci->icon = eina_stringshare_add(icon);
414 if (params) eci->params = eina_stringshare_add(params);
416 eci->generic_func = generic_func;
417 eci->desktop = desktop;
418 if (eci->desktop) efreet_desktop_ref(eci->desktop);
420 EINA_LIST_FOREACH(e_configure_registry, l, ecat)
421 if (!strcmp(cat, ecat->cat))
423 E_Configure_It *eci2;
426 EINA_LIST_FOREACH(ecat->items, ll, eci2)
427 if (eci2->pri > eci->pri)
429 ecat->items = eina_list_prepend_relative_list(ecat->items, eci, ll);
432 ecat->items = eina_list_append(ecat->items, eci);
441 _e_configure_registry_item_free(E_Configure_It *eci)
443 eina_stringshare_del(eci->item);
444 eina_stringshare_del(eci->label);
445 eina_stringshare_del(eci->icon);
446 if (eci->icon_file) eina_stringshare_del(eci->icon_file);
447 if (eci->desktop) efreet_desktop_free(eci->desktop);
448 if (eci->params) eina_stringshare_del(eci->params);