From 02cc702029ef40135846d2af55f6e71e4aba077a Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Fri, 18 Aug 2017 20:37:46 -0400 Subject: [PATCH] WPrefs: Edit proplist menus referenced by WMRootMenu. Previously, WPrefs could only be used to edit the menu specified in WMRootMenu. In a recent commit, the ability to specify a menu in proplist format defined in another file which is referenced by WMRootMenu was added. However, if a user attempted to edit such a menu in WPrefs, an error dialog appeared. We add the ability for WPrefs to read such a menu. After the user makes any changes, the result is stored in WMRootMenu, and *not* the original file. --- WPrefs.app/Menu.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c index feadd5fb..a18e495e 100644 --- a/WPrefs.app/Menu.c +++ b/WPrefs.app/Menu.c @@ -22,6 +22,7 @@ #include "WPrefs.h" #include #include +#include #include #include @@ -1493,6 +1494,26 @@ static void showData(_Panel * panel) pmenu = WMReadPropListFromFile(menuPath); + /* check if WMRootMenu references another file, and if so, + if that file is in proplist format */ + while (WMIsPLString(pmenu)) { + char *path = NULL; + + path = wexpandpath(WMGetFromPLString(pmenu)); + + if (access(path, F_OK) < 0) + path = wfindfile(DEF_CONFIG_PATHS, path); + + /* TODO: if needed, concatenate locale suffix to path. + See getLocalizedMenuFile() in src/rootmenu.c. */ + + if (!path) + break; + + pmenu = WMReadPropListFromFile(path); + wfree(path); + } + if (!pmenu || !WMIsPLArray(pmenu)) { int res;