Workaround for nsIFile.launch() and reveal() not working on Linux/Unix

For launch(), we just send the file through the Firefox's external helper app dialog. For reveal(), we display the path pre-selected in a window so the user can quickly copy it into another window (e.g. a terminal).
This commit is contained in:
Dan Stillman 2006-12-07 16:46:13 +00:00
parent b383fb6aa7
commit a26bc9728d
2 changed files with 46 additions and 4 deletions

View File

@ -1075,12 +1075,21 @@ var ZoteroPane = new function()
var internal = Zotero.MIME.hasInternalHandler(mimeType, ext);
}
var fileURL = attachment.getLocalFileURL();
if (internal || Zotero.MIME.fileHasInternalHandler(file))
{
window.loadURI(attachment.getLocalFileURL());
window.loadURI(fileURL);
}
else {
file.launch();
// Some platforms don't have nsILocalFile.launch, so we just load it and
// let the Firefox external helper app window handle it
try {
file.launch();
}
catch (e) {
window.loadURI(fileURL);
}
}
}
else {
@ -1105,7 +1114,17 @@ var ZoteroPane = new function()
{
var file = attachment.getFile();
if (file){
file.reveal();
try {
file.reveal();
}
catch (e) {
// On platforms that don't support nsILocalFile.reveal() (e.g. Linux), we
// open a small window with a selected read-only textbox containing the
// file path, so the user can open it, Control-c, Control-w, Alt-Tab, and
// Control-v the path into another app
var io = {alertText: file.path};
window.openDialog('chrome://zotero/content/selectableAlert.xul', "zotero-reveal-window", "chrome", io);
}
}
else {
alert(Zotero.getString('pane.item.attachments.fileNotFound'));
@ -1116,4 +1135,4 @@ var ZoteroPane = new function()
}
window.addEventListener("load", function(e) { ZoteroPane.onLoad(e); }, false);
window.addEventListener("unload", function(e) { ZoteroPane.onUnload(e); }, false);
window.addEventListener("unload", function(e) { ZoteroPane.onUnload(e); }, false);

View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
orient="vertical"
width="400"
height="200"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<keyset>
<key id="key_close" key="W" modifiers="accel" command="cmd_close"/>
</keyset>
<command id="cmd_close" oncommand="window.close();"/>
<textbox id="alert-textbox" class="plain" flex="1" readonly="true"/>
<script>
window.addEventListener('load', function(e){
document.getElementById('alert-textbox').value = window.arguments[0].alertText;
document.getElementById('alert-textbox').select();
}, false);
</script>
</window>