Bug 437056 add 'Choose this folder' option to filter dialog, r=mkmelin
authorJoey Minta <jminta@gmail.com>
Wed, 17 Sep 2008 13:40:21 -0400
changeset 361 d6628cc24bc509a592d94070b4cc22befac0a02f
parent 360 6fb2a576f786f77f14bdecaee18d10039493ff15
child 362 8240c87b0dab89ffbd604416a49c7c4c0a570250
push idunknown
push userunknown
push dateunknown
reviewersmkmelin
bugs437056
Bug 437056 add 'Choose this folder' option to filter dialog, r=mkmelin
mail/base/content/FilterListDialog.js
mail/base/content/FilterListDialog.xul
--- a/mail/base/content/FilterListDialog.js
+++ b/mail/base/content/FilterListDialog.js
@@ -321,17 +321,18 @@ function runSelectedFilters()
 {
   // if run button has "stop" label, do stop.
   var runButton = document.getElementById("runFiltersButton");
   if (runButton.getAttribute("label") == runButton.getAttribute("stoplabel")) {
     gFilterListMsgWindow.StopUrls();
     return;
   }
 
-  var folder = document.getElementById("runFiltersFolder").selectedItem._folder;
+  var menu = document.getElementById("runFiltersFolder");
+  var folder = menu._folder || menu.selectedItem._folder;
 
   var filterService = Components.classes["@mozilla.org/messenger/services/filters;1"].getService(Components.interfaces.nsIMsgFilterService);
   var filterList = filterService.getTempFilterList(folder);
   var folders = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
   folders.AppendElement(folder);
 
   // make sure the tmp filter list uses the real filter list log stream
   filterList.logStream = gCurrentFilterList.logStream;
@@ -538,16 +539,22 @@ function onFilterListKeyPress(event)
   if (event.charCode != KeyEvent.DOM_VK_SPACE)
     return;
 
   var list = document.getElementById("filterList")
   for each (var item in list.selectedItems)
     toggleFilter(item, list.getIndexOfItem(item));
 }
 
+function onTargetSelect(event) {
+  var menu = document.getElementById("runFiltersFolder");
+  menu._folder = event.target._folder;
+  menu.setAttribute("label", event.target._folder.prettyName);
+}
+
 /**
   * For a given server folder, get the first folder. For imap and pop it's INBOX
   * and it's the very first group for news accounts.
   */
 function getFirstFolder(msgFolder)
 {
   // Sanity check.
   if (! msgFolder.isServer)
--- a/mail/base/content/FilterListDialog.xul
+++ b/mail/base/content/FilterListDialog.xul
@@ -35,18 +35,22 @@
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK ***** 
 
 <?xml-stylesheet href="chrome://messenger/skin/filterDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/messenger.css" type="text/css"?>
+ <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 
-<!DOCTYPE window SYSTEM "chrome://messenger/locale/FilterListDialog.dtd">
+<!DOCTYPE window [
+<!ENTITY % filtersDTD SYSTEM "chrome://messenger/locale/FilterListDialog.dtd">%filtersDTD;
+<!ENTITY % pickerDTD SYSTEM "chrome://messenger/locale/msgFolderPickerOverlay.dtd"> %pickerDTD;
+]>
 
 <window id="filterListDialog"
   xmlns:nc="http://home.netscape.com/NC-rdf#"
   xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
   windowtype="mailnews:filterlist"
   style="width: 45em; height: 31em;"
   onload="onLoad();"
   onunload="onFilterUnload();"
@@ -124,18 +128,21 @@
       </row>
       <row>
         <vbox>
           <separator class="thin"/>
           <hbox align="center">
             <label id="folderPickerPrefix" value="&folderPickerPrefix.label;" 
                    accesskey="&folderPickerPrefix.accesskey;"
                    disabled="true" control="runFiltersFolder"/>
-            <menulist id="runFiltersFolder" disabled="true" flex="1">
-              <menupopup id="runFiltersPopup" type="folder"/>
+            <menulist id="runFiltersFolder" disabled="true" flex="1"
+                      oncommand="onTargetSelect(event);">
+              <menupopup id="runFiltersPopup" type="folder"
+                         showFileHereLabel="true"
+                         fileHereLabel="&filemessageschoosethis.label;"/>
             </menulist>
           </hbox>
         </vbox>
         <vbox>
           <separator class="thin"/>
           <button id="runFiltersButton" 
                   label="&runFilters.label;" 
                   accesskey="&runFilters.accesskey;"