Bug 570155: Make the helperApp dialog use the getFileDisplayname helper consistently (fixes a broken #ifdef exposed by bug 569373), and refactor some ifdefs to avoid code duplication, r=Neil

--HG--
extra : rebase_source : d13c45e747021f868ec608db62233fae54868441
This commit is contained in:
Gavin Sharp 2010-06-07 10:31:58 -04:00
Родитель d38f3cb61f
Коммит b9d3e4d85b
1 изменённых файлов: 7 добавлений и 41 удалений

Просмотреть файл

@ -705,12 +705,7 @@ nsUnknownContentTypeDialog.prototype = {
otherHandler.setAttribute("path", otherHandler.setAttribute("path",
this.getPath(this.chosenApp.executable)); this.getPath(this.chosenApp.executable));
#if XP_MACOSX otherHandler.label = this.getFileDisplayName(this.chosenApp.executable);
this.chosenApp.executable.QueryInterface(Components.interfaces.nsILocalFileMac);
otherHandler.label = this.chosenApp.executable.bundleDisplayName;
#else
otherHandler.label = this.chosenApp.executable.leafName;
#endif
otherHandler.hidden = false; otherHandler.hidden = false;
} }
@ -1024,32 +1019,9 @@ nsUnknownContentTypeDialog.prototype = {
if (params.handlerApp && if (params.handlerApp &&
params.handlerApp.executable && params.handlerApp.executable &&
params.handlerApp.executable.isFile()) { params.handlerApp.executable.isFile()) {
// Show the "handler" menulist since we have a (user-specified)
// application now.
this.dialogElement("modeDeck").setAttribute("selectedIndex", "0");
// Remember the file they chose to run. // Remember the file they chose to run.
this.chosenApp = params.handlerApp; this.chosenApp = params.handlerApp;
// Update dialog
var otherHandler = this.dialogElement("otherHandler");
otherHandler.removeAttribute("hidden");
otherHandler.setAttribute("path",
this.getPath(this.chosenApp.executable));
otherHandler.label =
this.getFileDisplayName(this.chosenApp.executable);
this.dialogElement("openHandler").selectedIndex = 1;
this.dialogElement("openHandler").setAttribute("lastSelectedItemID",
"otherHandler");
this.dialogElement("mode").selectedItem = this.dialogElement("open");
} else {
var openHandler = this.dialogElement("openHandler");
var lastSelectedID = openHandler.getAttribute("lastSelectedItemID");
if (!lastSelectedID)
lastSelectedID = "defaultHandler";
openHandler.selectedItem = this.dialogElement(lastSelectedID);
}
#else #else
var nsIFilePicker = Components.interfaces.nsIFilePicker; var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"] var fp = Components.classes["@mozilla.org/filepicker;1"]
@ -1061,28 +1033,23 @@ nsUnknownContentTypeDialog.prototype = {
fp.appendFilters(nsIFilePicker.filterApps); fp.appendFilters(nsIFilePicker.filterApps);
if (fp.show() == nsIFilePicker.returnOK && fp.file) { if (fp.show() == nsIFilePicker.returnOK && fp.file) {
// Show the "handler" menulist since we have a (user-specified)
// application now.
this.dialogElement("modeDeck").setAttribute("selectedIndex", "0");
// Remember the file they chose to run. // Remember the file they chose to run.
var localHandlerApp = var localHandlerApp =
Components.classes["@mozilla.org/uriloader/local-handler-app;1"]. Components.classes["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(Components.interfaces.nsILocalHandlerApp); createInstance(Components.interfaces.nsILocalHandlerApp);
localHandlerApp.executable = fp.file; localHandlerApp.executable = fp.file;
this.chosenApp = localHandlerApp; this.chosenApp = localHandlerApp;
#endif
// Show the "handler" menulist since we have a (user-specified)
// application now.
this.dialogElement("modeDeck").setAttribute("selectedIndex", "0");
// Update dialog. // Update dialog.
var otherHandler = this.dialogElement("otherHandler"); var otherHandler = this.dialogElement("otherHandler");
otherHandler.removeAttribute("hidden"); otherHandler.removeAttribute("hidden");
otherHandler.setAttribute("path", this.getPath(this.chosenApp.executable)); otherHandler.setAttribute("path", this.getPath(this.chosenApp.executable));
#ifdef XP_MACOSX otherHandler.label = this.getFileDisplayName(this.chosenApp.executable);
this.chosenApp.executable
.QueryInterface(Components.interfaces.nsILocalFileMac);
otherHandler.label = this.chosenApp.executable.bundleDisplayName;
#else
otherHandler.label = this.chosenApp.executable.leafName;
#endif
this.dialogElement("openHandler").selectedIndex = 1; this.dialogElement("openHandler").selectedIndex = 1;
this.dialogElement("openHandler").setAttribute("lastSelectedItemID", "otherHandler"); this.dialogElement("openHandler").setAttribute("lastSelectedItemID", "otherHandler");
@ -1095,7 +1062,6 @@ nsUnknownContentTypeDialog.prototype = {
lastSelectedID = "defaultHandler"; lastSelectedID = "defaultHandler";
openHandler.selectedItem = this.dialogElement(lastSelectedID); openHandler.selectedItem = this.dialogElement(lastSelectedID);
} }
#endif
}, },
// Turn this on to get debugging messages. // Turn this on to get debugging messages.