From 97702618deb5ae613e6b8e91834886d5b1377c5a Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Sat, 19 Aug 2017 10:48:42 -0400 Subject: [PATCH] WPrefs: Display warning when attempting to modify a read-only menu file. --- 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); }