Bug 781973 - Use filepicker's open() instead of the obsolete show() in /browser. r=bbondy
This commit is contained in:
@@ -1715,6 +1715,28 @@ var gApplicationsPane = {
|
||||
aEvent.stopPropagation();
|
||||
|
||||
var handlerApp;
|
||||
let chooseAppCallback = function(aHandlerApp) {
|
||||
// Rebuild the actions menu whether the user picked an app or canceled.
|
||||
// If they picked an app, we want to add the app to the menu and select it.
|
||||
// If they canceled, we want to go back to their previous selection.
|
||||
this.rebuildActionsMenu();
|
||||
|
||||
// If the user picked a new app from the menu, select it.
|
||||
if (aHandlerApp) {
|
||||
let typeItem = this._list.selectedItem;
|
||||
let actionsMenu =
|
||||
document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
|
||||
let menuItems = actionsMenu.menupopup.childNodes;
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menuItem = menuItems[i];
|
||||
if (menuItem.handlerApp && menuItem.handlerApp.equals(aHandlerApp)) {
|
||||
actionsMenu.selectedIndex = i;
|
||||
this.onSelectAction(menuItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
#ifdef XP_WIN
|
||||
var params = {};
|
||||
@@ -1743,47 +1765,33 @@ var gApplicationsPane = {
|
||||
// Add the app to the type's list of possible handlers.
|
||||
handlerInfo.addPossibleApplicationHandler(handlerApp);
|
||||
}
|
||||
|
||||
chooseAppCallback(handlerApp);
|
||||
#else
|
||||
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
||||
var winTitle = this._prefsBundle.getString("fpTitleChooseApp");
|
||||
fp.init(window, winTitle, Ci.nsIFilePicker.modeOpen);
|
||||
fp.appendFilters(Ci.nsIFilePicker.filterApps);
|
||||
let winTitle = this._prefsBundle.getString("fpTitleChooseApp");
|
||||
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
|
||||
let fpCallback = function fpCallback_done(aResult) {
|
||||
if (aResult == Ci.nsIFilePicker.returnOK && fp.file &&
|
||||
this._isValidHandlerExecutable(fp.file)) {
|
||||
handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
||||
createInstance(Ci.nsILocalHandlerApp);
|
||||
handlerApp.name = getFileDisplayName(fp.file);
|
||||
handlerApp.executable = fp.file;
|
||||
|
||||
// Add the app to the type's list of possible handlers.
|
||||
let handlerInfo = this._handledTypes[this._list.selectedItem.type];
|
||||
handlerInfo.addPossibleApplicationHandler(handlerApp);
|
||||
|
||||
chooseAppCallback(handlerApp);
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
// Prompt the user to pick an app. If they pick one, and it's a valid
|
||||
// selection, then add it to the list of possible handlers.
|
||||
if (fp.show() == Ci.nsIFilePicker.returnOK && fp.file &&
|
||||
this._isValidHandlerExecutable(fp.file)) {
|
||||
handlerApp = Cc["@mozilla.org/uriloader/local-handler-app;1"].
|
||||
createInstance(Ci.nsILocalHandlerApp);
|
||||
handlerApp.name = getFileDisplayName(fp.file);
|
||||
handlerApp.executable = fp.file;
|
||||
|
||||
// Add the app to the type's list of possible handlers.
|
||||
let handlerInfo = this._handledTypes[this._list.selectedItem.type];
|
||||
handlerInfo.addPossibleApplicationHandler(handlerApp);
|
||||
}
|
||||
fp.init(window, winTitle, Ci.nsIFilePicker.modeOpen);
|
||||
fp.appendFilters(Ci.nsIFilePicker.filterApps);
|
||||
fp.open(fpCallback);
|
||||
#endif
|
||||
|
||||
// Rebuild the actions menu whether the user picked an app or canceled.
|
||||
// If they picked an app, we want to add the app to the menu and select it.
|
||||
// If they canceled, we want to go back to their previous selection.
|
||||
this.rebuildActionsMenu();
|
||||
|
||||
// If the user picked a new app from the menu, select it.
|
||||
if (handlerApp) {
|
||||
let typeItem = this._list.selectedItem;
|
||||
let actionsMenu =
|
||||
document.getAnonymousElementByAttribute(typeItem, "class", "actionsMenu");
|
||||
let menuItems = actionsMenu.menupopup.childNodes;
|
||||
for (let i = 0; i < menuItems.length; i++) {
|
||||
let menuItem = menuItems[i];
|
||||
if (menuItem.handlerApp && menuItem.handlerApp.equals(handlerApp)) {
|
||||
actionsMenu.selectedIndex = i;
|
||||
this.onSelectAction(menuItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Mark which item in the list was last selected so we can reselect it
|
||||
|
||||
Reference in New Issue
Block a user