[Pkg-mozext-commits] [greasemonkey] 09/30: TODO: Show PopupNotifications about parse error(s)

David Prévot taffit at moszumanska.debian.org
Thu Nov 26 00:56:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit 83cda6defd5ed53553a64db6e3348af602a0a717
Author: janekptacijarabaci <janekptacijarabaci at seznam.cz>
Date:   Sun Nov 1 09:22:17 2015 +0100

    TODO: Show PopupNotifications about parse error(s)
---
 content/config.js | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/content/config.js b/content/config.js
index d0f1e0a..90201bc 100644
--- a/content/config.js
+++ b/content/config.js
@@ -7,6 +7,12 @@ Cu.import('chrome://greasemonkey-modules/content/script.js');
 Cu.import('chrome://greasemonkey-modules/content/third-party/MatchPattern.js');
 Cu.import('chrome://greasemonkey-modules/content/util.js');
 
+var gStringBundle = Components
+    .classes["@mozilla.org/intl/stringbundle;1"]
+    .getService(Components.interfaces.nsIStringBundleService)
+    .createBundle("chrome://greasemonkey/locale/greasemonkey.properties");
+
+
 function Config() {
   this._saveTimer = null;
   this._scripts = null;
@@ -244,7 +250,31 @@ Config.prototype.updateModifiedScripts = function(
       Cu.import('chrome://greasemonkey-modules/content/parseScript.js', scope);
       var parsedScript = scope.parse(
           script.textContent, GM_util.uriFromUrl(script.downloadURL));
-      // TODO: Show PopupNotifications about parse error(s)?
+      if (!parsedScript || parsedScript.parseErrors.length) {
+        var chromeWin = GM_util.getBrowserWindow();
+        if (chromeWin && chromeWin.gBrowser) {
+          var msg = "(" + script.localized.name + ") "
+              + gStringBundle.GetStringFromName("error.parsingScript")
+              + "\n" + parsedScript.parseErrors;
+          var buttons = [];
+          buttons.push({
+            "label": gStringBundle.GetStringFromName("notification.ok.label"),
+            "accessKey": gStringBundle
+                .GetStringFromName("notification.ok.accesskey"),
+            "popup": null,
+            "callback": function () {}
+          });
+          var notificationBox = chromeWin.gBrowser.getNotificationBox();
+          notificationBox.appendNotification(
+            msg,
+            "parse-userscript",
+            "chrome://greasemonkey/skin/icon16.png",
+            notificationBox.PRIORITY_WARNING_MEDIUM,
+            buttons
+          );
+          GM_util.logError(msg, true, script.fileURL, null);
+        }
+      }
       script.updateFromNewScript(parsedScript, aUrl, aWindowId, aBrowser);
     } else {
       // We are already downloading dependencies for this script

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list