Skip to content

Commit

Permalink
Closes greasemonkey#1249 fixing errors in the Error Console when usin…
Browse files Browse the repository at this point in the history
…g GM_notification on OSX without Growl
  • Loading branch information
erikvold authored and arantius committed Jan 24, 2011
1 parent 6a4ffd5 commit aef88fd
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions modules/GM_notification.js
@@ -1,24 +1,23 @@
// JSM exported symbols
var EXPORTED_SYMBOLS = ["GM_notification"];

const alertsServ = Components.classes["@mozilla.org/alerts-service;1"]
.getService(Components.interfaces.nsIAlertsService);
const {classes: Cc, interfaces: Ci} = Components;

function alert(msg) {
Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService)
.alert(null, "Greasemonkey alert", msg);
try {
var notify = Cc["@mozilla.org/alerts-service;1"]
.getService(Ci.nsIAlertsService)
.showAlertNotification;
} catch (e) {
var notify = function() {
Cc["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Ci.nsIPromptService)
.alert(null, "Greasemonkey alert", arguments[2]);
}
}

function GM_notification(aMsg, aTitle) {
var title = aTitle ? "" + aTitle : "Greasemonkey";
var message = aMsg ? "" + aMsg : "";
try {
alertsServ.showAlertNotification(
"chrome://greasemonkey/skin/icon_medium.png",
title, message, false, "", null);
} catch (e) {
// In case e.g. Growl is not installed on a Mac.
alert(title + "\n" + message);
}
notify(
"chrome://greasemonkey/skin/icon_medium.png",
title, message, false, "", null);
};

0 comments on commit aef88fd

Please sign in to comment.