ile/local;1"].createInstance(Ci.nsIFile); file.initWithPath(path); callback(file); return; } catch (ex) { callback(null); return; } } if (path) { // "path" is an nsIFile callback(path); return; } const fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); const mode = toSave ? fp.modeSave : fp.modeOpen; const key = toSave ? "saveStyleSheet" : "importStyleSheet"; const fpCallback = function (result) { if (result == Ci.nsIFilePicker.returnCancel) { callback(null); } else { callback(fp.file); } }; if (toSave && suggestedFilename) { fp.defaultString = suggestedFilename; } fp.init(parentWindow.browsingContext, getString(key + ".title"), mode); fp.appendFilter(getString(key + ".filter"), "*.css"); fp.appendFilters(fp.filterAll); fp.open(fpCallback); } /** * Returns a Popup Menu for the Options ("gear") Button * * @param {function} toggleOrigSources * To toggle the original source pref * @param {function} toggleAtRulesSidebar * To toggle the pref to show at-rules side bar * @return {object} popupMenu * A Menu object holding the MenuItems */ export function optionsPopupMenu(toggleOrigSources, toggleAtRulesSidebar) { const popupMenu = new lazy.Menu(); popupMenu.append( new lazy.MenuItem({ id: "options-origsources", label: getString("showOriginalSources.label"), accesskey: getString("showOriginalSources.accesskey"), type: "checkbox", checked: Services.prefs.getBoolPref(PREF_ORIG_SOURCES), click: () => toggleOrigSources(), }) ); popupMenu.append( new lazy.MenuItem({ id: "options-show-at-rules", label: getString("showAtRulesSidebar.label"), accesskey: getString("showAtRulesSidebar.accesskey"), type: "checkbox", checked: Services.prefs.getBoolPref(PREF_AT_RULES_SIDEBAR), click: () => toggleAtRulesSidebar(), }) ); return popupMenu; } PK