Bug 445012 – Migrate MailNews Character Encoding to the new prefwindow
authorIan Neal <iann_cvs@blueyonder.co.uk>
Sat, 09 Aug 2008 00:28:00 +0100
changeset 71 6cf4fa11fca725e536f0073e2888cedb9c09f93d
parent 70 5b875623717ccb502e90ab0a64980ba7169b8522
child 72 c4f3403b3c6d739cbb1eb157f551955906eae271
push idunknown
push userunknown
push dateunknown
bugs445012
Bug 445012 – Migrate MailNews Character Encoding to the new prefwindow p=me r=mnyromyr sr=neil
mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
mailnews/base/prefs/resources/content/pref-character_encoding.js
mailnews/base/prefs/resources/content/pref-character_encoding.xul
mailnews/jar.mn
--- a/mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
+++ b/mailnews/base/prefs/resources/content/mailPrefsOverlay.xul
@@ -1,12 +1,12 @@
 <?xml version="1.0"?>
 
 <!DOCTYPE overlay [
-<!ENTITY % mailPrefsOverlayDTD SYSTEM "chrome://messenger/locale/mailPrefsOverlay.dtd" >
+<!ENTITY % mailPrefsOverlayDTD SYSTEM "chrome://messenger/locale/mailPrefsOverlay.dtd">
 %mailPrefsOverlayDTD;
 ]>
 
 <overlay id="mailPrefsOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
   <preferences id="appearance_preferences">
     <preference id="general.startup.mail"
@@ -81,16 +81,21 @@
                   prefpane="tags_pane"
                   url="chrome://messenger/content/pref-tags.xul"
                   helpTopic="mail-prefs-tags"/>
         <treeitem id="receiptsItem"
                   label="&return.label;"
                   prefpane="receipts_pane"
                   url="chrome://messenger/content/pref-receipts.xul"
                   helpTopic="mail-prefs-receipts"/>
+        <treeitem id="characterEncodingItem"
+                  label="&characterEncoding.label;"
+                  prefpane="character_encoding_pane"
+                  url="chrome://messenger/content/pref-character_encoding.xul"
+                  helpTopic="mail_prefs_character_encoding"/>
         <treeitem id="offlineItem"
                   label="&offline.label;"
                   prefpane="offline_pane"
                   url="chrome://messenger/content/pref-offline.xul"
                   helpTopic="mail_prefs_offline"/>
       </treechildren>
     </treeitem>
   </treechildren>
@@ -140,21 +145,21 @@
         </treeitem>
         <treeitem>
           <treerow>
             <treecell label="(Migrated: &return.label;)"/>
           </treerow>
         </treeitem>
         <treeitem>
           <treerow>
-            <treecell url="chrome://messenger/content/pref-character_encoding.xul" label="&characterEncoding.label;"/> 
+            <treecell label="(Migrated: &characterEncoding.label;)"/>
           </treerow>
         </treeitem>
         <treeitem>
           <treerow>
             <treecell label="(Migrated: &offline.label;)"/>
           </treerow>
         </treeitem>
       </treechildren>
     </treeitem>
   </treechildren>
-           
-</overlay>         
+ 
+</overlay>
new file mode 100644
--- /dev/null
+++ b/mailnews/base/prefs/resources/content/pref-character_encoding.js
@@ -0,0 +1,60 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is SeaMonkey Project code.
+ *
+ * The Initial Developer of the Original Code is
+ * Ian Neal <iann_bugzilla@blueyonder.co.uk>
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * 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 ***** */
+
+// The contents of this file will be loaded into the scope of the object
+// <prefpane id="character_encoding_pane">!
+
+function Startup ()
+{
+  var observerService = Components.classes["@mozilla.org/observer-service;1"]
+                                  .getService(Components.interfaces.nsIObserverService);
+  observerService.notifyObservers(null, "charsetmenu-selected", "other");
+  observerService.notifyObservers(null, "charsetmenu-selected", "mailedit");
+
+  var viewCharsetList = document.getElementById("viewDefaultCharsetList");
+  // Need to set ref attribute once overlay has loaded.
+  viewCharsetList.setAttribute("ref", "NC:DecodersRoot");
+  // Since the menulist starts off empty it has no selected item
+  // so try and set it to the preference value.
+  viewCharsetList.value = document.getElementById("mailnews.view_default_charset").value;
+
+  var sendCharsetList = document.getElementById("sendDefaultCharsetList");
+  // Need to set ref attribute once overlay has loaded.
+  sendCharsetList.setAttribute("ref", "NC:MaileditCharsetMenuRoot");
+  // Since the menulist starts off empty it has no selected item
+  // so try and set it to the preference value.
+  sendCharsetList.value = document.getElementById("mailnews.send_default_charset").value;
+}
--- a/mailnews/base/prefs/resources/content/pref-character_encoding.xul
+++ b/mailnews/base/prefs/resources/content/pref-character_encoding.xul
@@ -1,64 +1,115 @@
 <?xml version="1.0"?>
 
-<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+   -
+   - The contents of this file are subject to the Mozilla Public License Version
+   - 1.1 (the "License"); you may not use this file except in compliance with
+   - the License. You may obtain a copy of the License at
+   - http://www.mozilla.org/MPL/
+   -
+   - Software distributed under the License is distributed on an "AS IS" basis,
+   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+   - for the specific language governing rights and limitations under the
+   - License.
+   -
+   - The Original Code is mozilla.org Code.
+   -
+   - The Initial Developer of the Original Code is
+   - Netscape Communications Corporation.
+   - Portions created by the Initial Developer are Copyright (C) 1998-2000
+   - the Initial Developer. All Rights Reserved.
+   -
+   - Contributor(s):
+   -
+   - Alternatively, the contents of this file may be used under the terms of
+   - either the GNU General Public License Version 2 or later (the "GPL"), or
+   - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+   - in which case the provisions of the GPL or the LGPL are applicable instead
+   - of those above. If you wish to allow use of your version of this file only
+   - under the terms of either the GPL or the LGPL, and not to allow others to
+   - use your version of this file under the terms of the MPL, indicate your
+   - decision by deleting the provisions above and replace them with the notice
+   - and other provisions required by the LGPL or the GPL. 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/prefPanels.css" type="text/css"?>
 
-<!DOCTYPE page SYSTEM "chrome://messenger/locale/pref-character_encoding.dtd">
-
-<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-      onload="parent.initPanel('chrome://messenger/content/pref-character_encoding.xul');"
-      headertitle="&pref.character.encoding.title;">
+<!DOCTYPE overlay SYSTEM "chrome://messenger/locale/pref-character_encoding.dtd">
 
-  <script type="application/x-javascript">
-  <![CDATA[
-    var _elementIDs = ["viewDefaultCharsetList",
-                       "strictlyMime", "sendDefaultCharsetList",
-                       "replyInDefaultCharset"];
-    var observerService = Components.classes["@mozilla.org/observer-service;1"]
-                                    .getService(Components.interfaces.nsIObserverService);
-    observerService.notifyObservers(null, "charsetmenu-selected", "other");
-    observerService.notifyObservers(null, "charsetmenu-selected", "mailedit");
-  ]]>
-  </script>
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <prefpane id="character_encoding_pane"
+            label="&pref.character.encoding.title;"
+            script="chrome://messenger/content/pref-character_encoding.js">
+    <preferences id="character_encoding_preferences">
+      <preference id="mailnews.view_default_charset"
+                  name="mailnews.view_default_charset"
+                  type="wstring"/>
+      <preference id="mail.strictly_mime"
+                  name="mail.strictly_mime"
+                  type="bool"/>
+      <preference id="mailnews.send_default_charset"
+                  name="mailnews.send_default_charset"
+                  type="wstring"/>
+      <preference id="mailnews.reply_in_default_charset"
+                  name="mailnews.reply_in_default_charset"
+                  type="bool"/>
+    </preferences>
 
-  <groupbox align="start">
-    <caption label="&messageDisplay.caption;"/>
-    <hbox align="center">
-      <label control="viewDefaultCharsetList"
-             value="&viewDefaultCharset.label;" accesskey="&viewDefaultCharset.accesskey;"/>
-      <menulist id="viewDefaultCharsetList" ref="NC:DecodersRoot" datasources="rdf:charset-menu"
-                preftype="localizedstring" prefstring="mailnews.view_default_charset">
-        <template>
-          <menupopup>
-            <menuitem label="rdf:http://home.netscape.com/NC-rdf#Name" value="..." uri="..."/>
-          </menupopup>
-        </template>
-      </menulist>
-    </hbox>
-  </groupbox>
+    <groupbox align="start">
+      <caption label="&messageDisplay.caption;"/>
+      <hbox align="center">
+        <label control="viewDefaultCharsetList"
+               value="&viewDefaultCharset.label;"
+               accesskey="&viewDefaultCharset.accesskey;"/>
+        <menulist id="viewDefaultCharsetList"
+                  ref=""
+                  datasources="rdf:charset-menu"
+                  preference="mailnews.view_default_charset">
+          <template>
+            <menupopup>
+              <menuitem label="rdf:http://home.netscape.com/NC-rdf#Name"
+                        value="..."
+                        uri="..."/>
+            </menupopup>
+          </template>
+        </menulist>
+      </hbox>
+    </groupbox>
 
-  <!-- Composing Mail -->
-  <groupbox align="start">
-    <caption label="&composingMessages.caption;"/>
+    <!-- Composing Mail -->
+    <groupbox align="start">
+      <caption label="&composingMessages.caption;"/>
 
-    <checkbox id="strictlyMime" label="&useMIME.label;"
-              prefstring="mail.strictly_mime"
-              accesskey="&useMIME.accesskey;"/>
+      <checkbox id="strictlyMime"
+                label="&useMIME.label;"
+                accesskey="&useMIME.accesskey;"
+                preference="mail.strictly_mime"/>
 
-    <hbox align="center">
-      <label value="&sendDefaultCharset.label;" accesskey="&sendDefaultCharset.accesskey;"
-             page="sendDefaultCharsetList" control="sendDefaultCharsetList"/>
-      <menulist id="sendDefaultCharsetList" ref="NC:MaileditCharsetMenuRoot" datasources="rdf:charset-menu"
-                preftype="localizedstring" prefstring="mailnews.send_default_charset">
-        <template>
-          <menupopup>
-            <menuitem label="rdf:http://home.netscape.com/NC-rdf#Name" value="..." uri="..."/>
-          </menupopup>
-        </template>
-      </menulist>  
-    </hbox>
-    <checkbox id="replyInDefaultCharset" label="&replyInDefaultCharset2.label;"
-              prefstring="mailnews.reply_in_default_charset"
-              accesskey="&replyInDefaultCharset2.accesskey;"/>
-  </groupbox>
-</page>
+      <hbox align="center">
+        <label value="&sendDefaultCharset.label;"
+               accesskey="&sendDefaultCharset.accesskey;"
+               control="sendDefaultCharsetList"/>
+        <menulist id="sendDefaultCharsetList"
+                  ref=""
+                  datasources="rdf:charset-menu"
+                  preference="mailnews.send_default_charset">
+          <template>
+            <menupopup>
+              <menuitem label="rdf:http://home.netscape.com/NC-rdf#Name"
+                        value="..."
+                        uri="..."/>
+            </menupopup>
+          </template>
+        </menulist>  
+      </hbox>
+      <checkbox id="replyInDefaultCharset"
+                label="&replyInDefaultCharset2.label;"
+                accesskey="&replyInDefaultCharset2.accesskey;"
+                preference="mailnews.reply_in_default_charset"/>
+    </groupbox>
+  </prefpane>
+</overlay>
--- a/mailnews/jar.mn
+++ b/mailnews/jar.mn
@@ -85,16 +85,17 @@ messenger.jar:
     content/messenger/pref-junk.js                                             (base/prefs/resources/content/pref-junk.js)
     content/messenger/pref-tags.xul                                            (base/prefs/resources/content/pref-tags.xul)
     content/messenger/pref-tags.js                                             (base/prefs/resources/content/pref-tags.js)
     content/messenger/pref-viewing_messages.xul                                (base/prefs/resources/content/pref-viewing_messages.xul)
     content/messenger/pref-viewing_messages.js                                 (base/prefs/resources/content/pref-viewing_messages.js)
     content/messenger/pref-receipts.xul                                        (base/prefs/resources/content/pref-receipts.xul)
     content/messenger/pref-receipts.js                                         (base/prefs/resources/content/pref-receipts.js)
     content/messenger/pref-character_encoding.xul                              (base/prefs/resources/content/pref-character_encoding.xul)
+    content/messenger/pref-character_encoding.js                               (base/prefs/resources/content/pref-character_encoding.js)
     content/messenger/pref-offline.xul                                         (base/prefs/resources/content/pref-offline.xul)
     content/messenger/pref-offline.js                                          (base/prefs/resources/content/pref-offline.js)
 *   content/messenger/AccountWizard.xul                                        (base/prefs/resources/content/AccountWizard.xul)
     content/messenger/AccountWizard.js                                         (base/prefs/resources/content/AccountWizard.js)
     content/messenger/aw-accounttype.js                                        (base/prefs/resources/content/aw-accounttype.js)
     content/messenger/aw-identity.js                                           (base/prefs/resources/content/aw-identity.js)
     content/messenger/aw-server.js                                             (base/prefs/resources/content/aw-server.js)
     content/messenger/aw-login.js                                              (base/prefs/resources/content/aw-login.js)