From cc7e3898aa17252834333463fdadad78e5714933 Mon Sep 17 00:00:00 2001 From: "Stefan.Borggraefe%gmx.de" Date: Tue, 4 May 2004 22:28:14 +0000 Subject: [PATCH] Bug 81572: "Never provide only a text field for file/folder input (newsrc file)" r=mscott, sr=bienvenu --- .../base/prefs/resources/content/am-server.js | 27 +++++++++++++++++++ .../prefs/resources/content/am-server.xul | 6 ++++- .../resources/locale/en-US/am-server-top.dtd | 3 +++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/mailnews/base/prefs/resources/content/am-server.js b/mailnews/base/prefs/resources/content/am-server.js index 1eaed788667..67cfb60b3fd 100644 --- a/mailnews/base/prefs/resources/content/am-server.js +++ b/mailnews/base/prefs/resources/content/am-server.js @@ -273,3 +273,30 @@ function setupNotifyUI() if (locked) broadcaster.setAttribute("disabled","true"); } + +function BrowseForNewsrc() +{ + var newsrcTextBox = document.getElementById("nntp.newsrcFilePath"); + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + fp.init(window, + document.getElementById("browseForNewsrc").getAttribute("filepickertitle"), + nsIFilePicker.modeSave); + + var currentNewsrcFile; + try { + currentNewsrcFile = Components.classes[LOCALFILE_CTRID].createInstance(nsILocalFile); + currentNewsrcFile.initWithPath(newsrcTextBox.value); + } catch (e) { + dump("Failed to create nsILocalFile instance for the current newsrc file.\n"); + } + + if (currentNewsrcFile) { + fp.displayDirectory = currentNewsrcFile.parent; + fp.defaultString = currentNewsrcFile.leafName; + } + + fp.appendFilters(nsIFilePicker.filterAll); + + if (fp.show() != nsIFilePicker.returnCancel) + newsrcTextBox.value = fp.file.path; +} diff --git a/mailnews/base/prefs/resources/content/am-server.xul b/mailnews/base/prefs/resources/content/am-server.xul index 429f5ae3889..e23d679ff4a 100644 --- a/mailnews/base/prefs/resources/content/am-server.xul +++ b/mailnews/base/prefs/resources/content/am-server.xul @@ -269,9 +269,13 @@