From a26bc9728d39f64e7858615d06495c9f987d7d15 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 7 Dec 2006 16:46:13 +0000 Subject: [PATCH] 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). --- chrome/content/zotero/overlay.js | 27 +++++++++++++++++++---- chrome/content/zotero/selectableAlert.xul | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 chrome/content/zotero/selectableAlert.xul diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 7736b0494..1fb175971 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -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); \ No newline at end of file +window.addEventListener("unload", function(e) { ZoteroPane.onUnload(e); }, false); diff --git a/chrome/content/zotero/selectableAlert.xul b/chrome/content/zotero/selectableAlert.xul new file mode 100644 index 000000000..950353ed4 --- /dev/null +++ b/chrome/content/zotero/selectableAlert.xul @@ -0,0 +1,23 @@ + + + + + + + + + + + + + +