From 19fae92d529533570df6c3f7c1cb3ac6b1146bcb Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 13 Nov 2006 14:20:43 +0000 Subject: [PATCH] *No more KDE duplicates in menus. *Start documenting the FDO menu process a bit better. SVN revision: 27087 --- .../lib/ecore_desktop/ecore_desktop_menu.c | 207 +++++++++--------- .../lib/ecore_desktop/ecore_desktop_paths.c | 3 +- 2 files changed, 110 insertions(+), 100 deletions(-) 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 5cf7335fd3..f3e3e481e0 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c @@ -5,6 +5,8 @@ * follow the spec in a way that is easy to check. Only then can we start to * optomize into "ugly but fast". * + * There are notes at the very end about all those nasty steps we need to do to + * follow the spec. */ #include @@ -17,7 +19,7 @@ #include #include -//#define DEBUG 1 +#define DEBUG 1 struct _ecore_desktop_menu_expand_apps_data { @@ -1683,100 +1685,6 @@ _ecore_desktop_menu_apply_rules(struct _ecore_desktop_menu_generate_data *genera } /* -OR (implied) - loop through the rules - as soon as one matches, return true - otherwise return false. - -SUB RULES - process the sub rules, return the result - -AND - loop through the rules - as soon as one doesn't match, return false - otherwise return true. - -NOT (implied OR) - loop through the rules - as soon as one matches, return false - otherwise return true. - -ALL - return true - -FILENAME - if the rule string matches the desktop id return true - otherwise return false - -CATEGORY - loop through the apps categories - as soon as one matches the rule string, return true - otherwise return false. - */ - -/* -merge menus -* expand 's to . -* expand 's -* for each dir (recursive) -* create recursively nested <> element -* // dirpath -* dirpath -* if exist .directory -* add <.directory> to name -* -* for each *.desktop - if no categories in bar.desktop -* prefix-bar.desktop - add "Legacy" to categories -* add any prefix to the desktop ID. -* add it to the pool -* -* for each , and element -* get the root elements from that elements file/s. -* remove the element from those root elements. -* replace that element with the child elements of those root elements. -* expand the with the name/s of that elements file/s -* loop until all , , and elements are done, -* careful to avoid infinite loops in files that reference each other. -* for each recursively - consolidate duplicate child s. -* expand s and s to s and s. - consolidate duplicate child s, s, and s. - resolve duplicate s. - for each recursively - for each - do the move. - mark any that has been affected. - for each marked recursively - consolidate duplicate child s. -* for each recursively -* if there are elements that are not ovreridden by a element -* remove this element and all it's children. - -*generate menus -* for each that is (which is the default) -* for each -* for each .desktop -* if it exists in the pool, replace it. -* else add it to the pool. -* for each parent -* for each .desktop in the pool -* if it doesn't exist in the child pool -* add it to the pool. -* for each and -* if rule is an -* for each .desktop in pool -* for each rule -* if rule matches .desktop in pool -* add .desktop to menu. -* mark it as allocated -* if rule is an -* for each .desktop in menu -* for each rule -* if rule matches .desktop in menu -* remove .desktop from menu. -* leave it as allocated. ones. -* Only the unallocated .desktop entries can be used. +ALL + return true -generate menu layout +FILENAME + if the rule string matches the desktop id return true + otherwise return false + +CATEGORY + loop through the apps categories + as soon as one matches the rule string, return true + otherwise return false. + +OR (implied) + loop through the rules + as soon as one matches, return true + otherwise return false. + +SUB RULES + process the sub rules, return the result + +AND + loop through the rules + as soon as one doesn't match, return false + otherwise return true. + +NOT (implied OR) + loop through the rules + as soon as one matches, return false + otherwise return true. + */ + +/* FDO PARSING STEPS. + +An asterisk in the first column marks those bits that are done. +The spec is not numbered, so I have invented a numbering to help match the +steps to the code. + + 10000000 merge menus +*11000000 expand 's to . +*12000000 expand 's +*12100000 for each dir (recursive) +*12110000 create recursively nested <> element +*12120000 // dirpath +*12130000 dirpath +*12140000 if exist .directory +*12141000 add <.directory> to name +*12150000 +*12160000 for each *.desktop + 12161000 if no categories in bar.desktop +*12161100 prefix-bar.desktop + 12162000 add "Legacy" to categories +*12163000 add any prefix to the desktop ID. +*12164000 add it to the pool +*12170000 +*13000000 for each and element +*13100000 get the root elements from that elements file/s. +*13200000 remove the element from those root elements. +*13300000 replace that element with the child elements of those root elements. +*13400000? expand the with the name/s of that elements file/s +*14000000 loop until all and elements are done, +*14000000 careful to avoid infinite loops in files that reference each other. +*15000000 for each recursively + 15100000 consolidate duplicate child s. +*15200000 expand s and s to s and s. + 15300000 consolidate duplicate child s, s, and s. + 15400000? resolve duplicate s. + 16000000 for each recursively (but from the deepest level out) + 16100000 for each + 16110000 do the move. + 16120000 mark any that has been affected. + 17000000 for each marked recursively + 17100000 consolidate duplicate child s. +*18000000 for each recursively +*18100000 if there are elements that are not ovreridden by a element +*18110000 remove this element and all it's children. + +*20000000 generate menus +*21000000 for each that is (which is the default) +*21100000 for each +*21110000 for each .desktop +*21111000 if it exists in the pool, replace it. +*21112000 else add it to the pool. +*21200000 for each parent +*21210000 for each .desktop in the pool +*21211000 if it doesn't exist in the child pool +*21211100 add it to the pool. +*21300000 for each and +*21310000 if rule is an +*21311000 for each .desktop in pool +*21311100 for each rule +*21311110 if rule matches .desktop in pool +*21311111 add .desktop to menu. +*21311112 mark it as allocated +*21320000 if rule is an +*21321000 for each .desktop in menu +*21321100 for each rule +*21321110 if rule matches .desktop in menu +*21321111 remove .desktop from menu. +*21321112 leave it as allocated. + +*30000000 generate unallocated menus +*31000000 Same as for menus, but only the ones. +*32000000 Only the unallocated .desktop entries can be used. + + 40000000 generate menu layout + This part of the spec is a whole other rabbit hole, and optional. B-) */ diff --git a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c index 3e2a39ab2d..e26f1c927a 100644 --- a/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c +++ b/legacy/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c @@ -181,7 +181,8 @@ _ecore_desktop_paths_create(void) "XDG_DATA_HOME", "XDG_DATA_DIRS", "~/.local/share:~/.kde/share", "/usr/local/share:/usr/share", - "applications:applnk:applications/kde", +// "applications:applnk:applications/kde", + "applications:applnk", "dist/desktop-files:dist/short-menu:gnome/apps", "xdgdata-apps:apps"); _ecore_desktop_paths_check_and_add(ecore_desktop_paths_desktops,