From 44e48d8b89d200acb78478e94ff1c28b6936d9e2 Mon Sep 17 00:00:00 2001 From: "edward.lee@engineering.uiuc.edu" Date: Tue, 18 Dec 2007 11:56:09 -0800 Subject: [PATCH] Bug 408565 - Menu items "Open Containing Folder" / "Show in Finder" shouldn't be grayed out for in-progress/paused downloads. r=sdwilsh, a1.9=beltzner --- .../mozapps/downloads/content/downloads.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/toolkit/mozapps/downloads/content/downloads.js b/toolkit/mozapps/downloads/content/downloads.js index 2ec7c322a71..e2a2340b20f 100644 --- a/toolkit/mozapps/downloads/content/downloads.js +++ b/toolkit/mozapps/downloads/content/downloads.js @@ -265,14 +265,23 @@ function showDownload(aDownload) var f = getLocalFileFromNativePathOrUrl(aDownload.getAttribute("file")); try { + // Show the directory containing the file and select the file f.reveal(); - } catch (ex) { - // if reveal failed for some reason (eg on unix it's not currently - // implemented), send the file: URL window rooted at the parent to - // the OS handler for that protocol - var parent = f.parent; - if (parent) + } catch (e) { + // If reveal fails for some reason (e.g., it's not implemented on unix or + // the file doesn't exist), try using the parent if we have it. + let parent = f.parent.QueryInterface(Ci.nsILocalFile); + if (!parent) + return; + + try { + // "Double click" the parent directory to show where the file should be + parent.launch(); + } catch (e) { + // If launch also fails (probably because it's not implemented), let the + // OS handler try to open the parent openExternal(parent); + } } } @@ -629,7 +638,6 @@ var gDownloadViewController = { case "cmd_cancel": return dl.inProgress; case "cmd_open": - case "cmd_show": let file = getLocalFileFromNativePathOrUrl(dl.getAttribute("file")); return dl.openable && file.exists(); case "cmd_pause": @@ -643,6 +651,7 @@ var gDownloadViewController = { case "cmd_removeFromList": case "cmd_retry": return dl.removable; + case "cmd_show": case "cmd_copyLocation": return true; }