Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
fix options' filepickers (#82)
Not sure as why the filepicker callback passed to |open()| is working in all
Mozilla's code without having an explicite |done| method...
  • Loading branch information
foudfou committed Feb 10, 2013
1 parent 730a679 commit 2bbab71
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/chrome/content/options.js
Expand Up @@ -306,28 +306,30 @@ var firetrayUIOptions = {
},

chooseAppIconFile: function() {
let updateIcon = firetray.Handler.setIconImageDefault.bind(firetray.Handler);
this._chooseIconFile("app_icon_custom_filename");
firetray.Handler.setIconImageDefault();
},

chooseMailIconFile: function() {
this._chooseIconFile("custom_mail_icon_filename");
firetray.Messaging.updateIcon();
let updateIcon = firetray.Messaging.updateIcon.bind(firetray.Messaging);
this._chooseIconFile("custom_mail_icon_filename", updateIcon);
},

_chooseIconFile: function(elementId, prefpaneId) {
_chooseIconFile: function(elementId, callback) {
const nsIFilePicker = Ci.nsIFilePicker;
var filePicker = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);

let fpCallback = function fpCallback_done(aResult) {
let fpCallback = { done: function(aResult) {
if (aResult == nsIFilePicker.returnOK ||
aResult == nsIFilePicker.returnReplace) {
let filenameElt = document.getElementById(elementId);
filenameElt.value = filePicker.file.path;
let prefpane = firetrayUIOptions.getAncestorPrefpane(filenameElt);
prefpane.userChangedValue(filenameElt);

callback.call();
}
};
}};

filePicker.init(window, "Select Icon", nsIFilePicker.modeOpen); // FIXME: i18n
filePicker.appendFilters(nsIFilePicker.filterImages);
Expand Down

0 comments on commit 2bbab71

Please sign in to comment.