Bug 843536 - Ctrl-o doesn't open file picker. r=sfoster

This commit is contained in:
Brian R. Bondy 2013-03-02 08:04:22 -05:00
parent 71b0a3cfca
commit 931b75ae4f
3 changed files with 29 additions and 0 deletions

View File

@ -758,6 +758,28 @@ var BrowserUI = {
} }
}, },
openFile: function() {
try {
const nsIFilePicker = Ci.nsIFilePicker;
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
let self = this;
let fpCallback = function fpCallback_done(aResult) {
if (aResult == nsIFilePicker.returnOK) {
self.goToURI(fp.fileURL.spec);
}
};
let windowTitle = Strings.browser.GetStringFromName("browserForOpenLocation");
fp.init(window, windowTitle, nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText |
nsIFilePicker.filterImages | nsIFilePicker.filterXML |
nsIFilePicker.filterHTML);
fp.open(fpCallback);
} catch (ex) {
dump ('BrowserUI openFile exception: ' + ex + '\n');
}
},
receiveMessage: function receiveMessage(aMessage) { receiveMessage: function receiveMessage(aMessage) {
let browser = aMessage.target; let browser = aMessage.target;
let json = aMessage.json; let json = aMessage.json;
@ -812,6 +834,7 @@ var BrowserUI = {
case "cmd_zoomout": case "cmd_zoomout":
case "cmd_volumeLeft": case "cmd_volumeLeft":
case "cmd_volumeRight": case "cmd_volumeRight":
case "cmd_openFile":
isSupported = true; isSupported = true;
break; break;
default: default:
@ -935,6 +958,9 @@ var BrowserUI = {
// Zoom out (portrait) or in (landscape) // Zoom out (portrait) or in (landscape)
Browser.zoom(Util.isPortrait() ? 1 : -1); Browser.zoom(Util.isPortrait() ? 1 : -1);
break; break;
case "cmd_openFile":
this.openFile();
break;
} }
} }
}; };

View File

@ -67,6 +67,7 @@
<command id="cmd_go" oncommand="CommandUpdater.doCommand(this.id);"/> <command id="cmd_go" oncommand="CommandUpdater.doCommand(this.id);"/>
<command id="cmd_openLocation" oncommand="CommandUpdater.doCommand(this.id);"/> <command id="cmd_openLocation" oncommand="CommandUpdater.doCommand(this.id);"/>
<command id="cmd_home" oncommand="CommandUpdater.doCommand(this.id);"/> <command id="cmd_home" oncommand="CommandUpdater.doCommand(this.id);"/>
<command id="cmd_openFile" oncommand="CommandUpdater.doCommand(this.id);"/>
<!-- tabs --> <!-- tabs -->
<command id="cmd_newTab" oncommand="CommandUpdater.doCommand(this.id);"/> <command id="cmd_newTab" oncommand="CommandUpdater.doCommand(this.id);"/>
@ -133,6 +134,7 @@
<key id="key_focusURL" key="l" modifiers="accel" command="cmd_openLocation"/> <key id="key_focusURL" key="l" modifiers="accel" command="cmd_openLocation"/>
<key id="key_focusURL2" key="&urlbar.accesskey;" modifiers="alt" command="cmd_openLocation"/> <key id="key_focusURL2" key="&urlbar.accesskey;" modifiers="alt" command="cmd_openLocation"/>
<key id="key_home" keycode="VK_HOME" modifiers="accel" command="cmd_home"/> <key id="key_home" keycode="VK_HOME" modifiers="accel" command="cmd_home"/>
<key id="key_open" key="o" modifiers="accel" command="cmd_openFile"/>
<!-- misc --> <!-- misc -->
<key id="key_zoomin" key="+" modifiers="accel" command="cmd_zoomin"/> <key id="key_zoomin" key="+" modifiers="accel" command="cmd_zoomin"/>

View File

@ -21,6 +21,7 @@ helpOnlineCharm=Help (online)
# General # General
browserForSaveLocation=Save Location browserForSaveLocation=Save Location
browserForOpenLocation=Open Location
# Download Manager # Download Manager
downloadsUnknownSize=Unknown size downloadsUnknownSize=Unknown size