[PATCH 1/3] WPrefs: Display warning when attempting to modify a read-only menu file.

Doug Torrance <[email protected]> Sat, 19 Aug 2017 10:48:42 -0400
Newsgroups gmane.compw.window-managers.windowmaker.devel
Message-ID <[email protected]>
---
 WPrefs.app/Menu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c
index a18e495e..6e682b57 100644
--- a/WPrefs.app/Menu.c
+++ b/WPrefs.app/Menu.c
@@ -1484,6 +1484,7 @@ static void showData(_Panel * panel)
 {
 	const char *gspath;
 	char *menuPath;
+	char buf[1024];
 	WMPropList *pmenu;
 
 	gspath = wusergnusteppath();
@@ -1510,6 +1511,21 @@ static void showData(_Panel * panel)
 		if (!path)
 			break;
 
+		if (access(path, W_OK) < 0) {
+			snprintf(buf, 1024,
+				 _("The menu file \"%s\" referenced by "
+				   "WMRootMenu is read-only.\n"
+				   "You cannot use WPrefs to modify it."),
+				 path);
+			WMRunAlertPanel(WMWidgetScreen(panel->parent),
+					panel->parent,
+					_("Warning"), buf,
+					_("OK"), NULL, NULL);
+			panel->dontSave = True;
+			wfree(path);
+			return;
+		}
+
 		pmenu = WMReadPropListFromFile(path);
 		wfree(path);
 	}
-- 
2.11.0


-- 
To unsubscribe, send mail to [email protected].