diff --git a/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h b/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h index 1c32696b8f..3b78375008 100644 --- a/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h +++ b/legacy/ecore/src/lib/ecore_desktop/Ecore_Desktop.h @@ -28,14 +28,6 @@ * For menu file details, see @ref Ecore_Desktop_Menu_Group. */ -extern Ecore_List *ecore_desktop_paths_config; -extern Ecore_List *ecore_desktop_paths_menus; -extern Ecore_List *ecore_desktop_paths_directories; -extern Ecore_List *ecore_desktop_paths_desktops; -extern Ecore_List *ecore_desktop_paths_icons; -extern Ecore_List *ecore_desktop_paths_kde_legacy; -extern Ecore_List *ecore_desktop_paths_xsessions; - struct _Ecore_Desktop { Ecore_Hash *data, *group, *Categories, *OnlyShowIn, *NotShowIn; @@ -155,6 +147,7 @@ extern "C" void ecore_desktop_icon_theme_destroy(Ecore_Desktop_Icon_Theme *icon_theme); + EAPI void ecore_desktop_menu_for_each(void (*func)(char *name, char *path, Ecore_Hash *apps)); Ecore_Desktop_Tree *ecore_desktop_menu_get(char *file); diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c index 89b8bbef33..b03fddc9a6 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c @@ -55,6 +55,7 @@ struct _ecore_desktop_menu_legacy_data int length, menu_length, level; }; +static int _ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int element, int level); static Ecore_Desktop_Tree *_ecore_desktop_menu_get0(char *file, Ecore_Desktop_Tree * merge_stack, int level); static Ecore_Desktop_Tree *_ecore_desktop_menu_create_menu(); static int _ecore_desktop_menu_unxml(const void *data, @@ -113,6 +114,78 @@ static int _ecore_desktop_menu_apply_rules(struct * Functions that deal with freedesktop.org menus. */ + +EAPI void +ecore_desktop_menu_for_each(void (*func)(char *name, char *path, Ecore_Hash *apps)) +{ + char *menu_file; + + /* Find the main menu file. */ + menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, + "applications.menu", -1, NULL, NULL); + if (!menu_file) + { + /* Try various quirks of various systems. */ + menu_file = ecore_desktop_paths_file_find(ecore_desktop_paths_menus, + "debian-menu.menu", -1, NULL, NULL); + /* FIXME: If all else fails, run debians funky menu generator shit. */ + } + + if (menu_file) + { +// char *path; + +// path = ecore_file_get_dir(menu_file); +// if (path) + { + Ecore_Desktop_Tree *menus; + + /* convert the xml into menus */ + menus = ecore_desktop_menu_get(menu_file); + if (menus) + { + /* create the .desktop and order files from the menu */ + ecore_desktop_tree_foreach(menus, 0, _ecore_desktop_menu_make_apps, func); +// FIXME: Can't free this just yet, causes major memory corruption. +// ecore_desktop_tree_del(menus); + } +// free(path); + + } + free(menu_file); + } +} + +static int +_ecore_desktop_menu_make_apps(const void *data, Ecore_Desktop_Tree * tree, int element, int level) +{ + if (tree->elements[element].type == ECORE_DESKTOP_TREE_ELEMENT_TYPE_STRING) + { + if (strncmp((char *)tree->elements[element].element, "