~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/xpfe/components/prefwindow/resources/content/pref-advanced.xul

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0"?> 
 
2
 
 
3
<!--
 
4
   The contents of this file are subject to the Netscape Public
 
5
   License Version 1.1 (the "License"); you may not use this file
 
6
   except in compliance with the License. You may obtain a copy of
 
7
   the License at http://www.mozilla.org/NPL/
 
8
    
 
9
   implied. See the License for the specific language governing
 
10
   rights and limitations under the License.
 
11
    
 
12
   The Original Code is Mozilla Communicator client code, released
 
13
   March 31, 1998.
 
14
   
 
15
   The Initial Developer of the Original Code is Netscape
 
16
   Communications Corporation. Portions created by Netscape are
 
17
   Copyright (C) 1998-1999 Netscape Communications Corporation. All
 
18
   Rights Reserved.
 
19
   
 
20
   Contributor(s): 
 
21
     Mike Kowalski <mikejk@ameritech.net>
 
22
  -->
 
23
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
 
24
 
 
25
<!DOCTYPE page [
 
26
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd">
 
27
%brandDTD;
 
28
<!ENTITY % prefAdvancedDTD SYSTEM "chrome://communicator/locale/pref/pref-advanced.dtd"> %prefAdvancedDTD;
 
29
]>
 
30
 
 
31
<page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
 
32
      onload="parent.initPanel('chrome://communicator/content/pref/pref-advanced.xul');"
 
33
      headertitle="&lHeader;">
 
34
 
 
35
  <script type="application/x-javascript">
 
36
  <![CDATA[
 
37
    var panel = "chrome://communicator/content/pref/pref-advanced.xul";
 
38
    var _elementIDs = ["advancedJavaAllow", "advancedMailFTP", "advancedMailFTPAddress", "systemPrefCheck"];
 
39
    
 
40
    function Startup() {
 
41
      ftpCheck(false);
 
42
      turboCheck();
 
43
      sysPrefCheck();
 
44
      initJVMConfigList();
 
45
    }   
 
46
    
 
47
    function ftpCheck(setFocus) {
 
48
      var checked = document.getElementById("advancedMailFTP").checked;
 
49
      var field = document.getElementById("advancedMailFTPAddress");
 
50
      field.disabled = !checked;
 
51
 
 
52
      if (!field.disabled && setFocus)
 
53
        field.focus();
 
54
    }
 
55
 
 
56
    /* 
 
57
     * Name: turboCheck()
 
58
     * 
 
59
     * Arguments: none
 
60
     *
 
61
     * Description: This function is called when the root advanced prefs panel
 
62
     * is loaded. The turbo mode setting is not exactly a preference -- setting
 
63
     * the checkbox should (on leaving the prefs with an "Ok") result in a call
 
64
     * to the backend to do the necessary win32 registry twiddling needed for
 
65
     * turbo mode to go into effect. Clearing it should undo this work. We need
 
66
     * to call the backend to determine if turbo mode is enabled (since we are 
 
67
     * required to check for it in a non-trivial way) and then explicitly set the
 
68
     * checkbox here based on what we find. Finally, we have to hide the checkbox
 
69
     * (and the group box that frames it) if we are not executing on a Win32 
 
70
     * platform.
 
71
     *
 
72
     * Return Value: void
 
73
     *
 
74
     * Original Code: syd@netscape.com 6/8/2001
 
75
     *
 
76
    */
 
77
 
 
78
    function turboCheck()
 
79
    {
 
80
      var frame = document.getElementById("perfSettings");
 
81
      if (navigator.platform != "Win32") {
 
82
        frame.hidden = true;
 
83
        return;
 
84
      }
 
85
      if (!("isTurboEnabled" in parent))
 
86
        parent.isTurboEnabled = -1;
 
87
      else {
 
88
        document.getElementById("enableTurbo").checked = parent.isTurboEnabled;
 
89
        return;
 
90
      }
 
91
      var winhooksService = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
 
92
      if (winhooksService) {
 
93
        parent.isTurboEnabled = winhooksService.isOptionEnabled("-turbo");
 
94
        document.getElementById("enableTurbo").checked = parent.isTurboEnabled;
 
95
      }
 
96
 
 
97
      parent.hPrefWindow.registerOKCallbackFunc( saveTurboSetting );
 
98
    }
 
99
 
 
100
    /* 
 
101
     * Name: saveTurboSetting()
 
102
     * 
 
103
     * Arguments: none
 
104
     *
 
105
     * Description: This function is called when the user hits the OK button in
 
106
     * the preferences panel. The function determines what the turbo "preference" 
 
107
     * setting is and performs the appropriate action to enable or disable turbo mode.
 
108
     *
 
109
     * Return Value: void
 
110
     *
 
111
     * Original Code: syd@netscape.com 6/9/2001
 
112
     *
 
113
    */
 
114
 
 
115
    function saveTurboSetting() {
 
116
      if (navigator.platform != "Win32")
 
117
        return;   
 
118
 
 
119
      var winhooksService = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
 
120
      if (winhooksService && parent.isTurboEnabled != -1) {
 
121
        if (parent.isTurboEnabled)
 
122
          winhooksService.startupAddOption("-turbo");
 
123
        else 
 
124
          winhooksService.startupRemoveOption("-turbo");
 
125
        var appShell = Components.classes['@mozilla.org/appshell/appShellService;1'].getService();
 
126
        appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService );
 
127
        var nativeAppSupport = null;
 
128
        try {
 
129
          nativeAppSupport = appShell.nativeAppSupport;
 
130
        }
 
131
        catch ( ex ) {
 
132
        }
 
133
        if (nativeAppSupport)
 
134
          nativeAppSupport.isServerMode = parent.isTurboEnabled;
 
135
        }
 
136
      }
 
137
 
 
138
    function sysPrefCheck() {
 
139
      var frame = document.getElementById("systemPrefs");
 
140
      if ("@mozilla.org/system-preference-service;1" in Components.classes)
 
141
      try {
 
142
        var appShell = Components.classes["@mozilla.org/system-preference-service;1"].getService(Components.interfaces.nsIPrefBranch);
 
143
        return;
 
144
      }
 
145
      catch(e) {}
 
146
      frame.hidden = true;
 
147
    }
 
148
 
 
149
    function sysPrefUpdate() {
 
150
      var checkObj = document.getElementById("systemPrefCheck");
 
151
      var prefstring = checkObj.getAttribute( "prefstring" );
 
152
      parent.hPrefWindow.setPref("bool", prefstring, checkObj.checked);
 
153
      parent.hPrefWindow.pagePrefChanged = true;
 
154
      parent.hPrefWindow.pagePrefUpdated = [];
 
155
    }
 
156
  ]]>
 
157
  </script>
 
158
 
 
159
  <groupbox id="advancedSettings" align="start">
 
160
    <caption label="&advancedTitle.label;"/>
 
161
    <vbox align="start" id="contentEnablingBox">
 
162
      <checkbox id="advancedJavaAllow" label="&enbJavaCheck.label;" accesskey="&enbJavaCheck.accesskey;"
 
163
                prefstring="security.enable_java"
 
164
                oncommand="javaCheck(true)"/>
 
165
    </vbox>
 
166
    <vbox>
 
167
    <vbox align="start">
 
168
      <checkbox id="advancedMailFTP" label="&sendAddFtpCheck.label;" accesskey="&sendAddFtpCheck.accesskey;"
 
169
                prefstring="advanced.mailftp"
 
170
                oncommand="ftpCheck(true);"/>
 
171
    </vbox>
 
172
    <hbox class="indent">
 
173
      <textbox id="advancedMailFTPAddress"
 
174
               preftype="string" prefstring="network.ftp.anonymous_password" class="uri-element"
 
175
               flex="2"/>
 
176
    </hbox>
 
177
    </vbox>
 
178
    <separator/>
 
179
  </groupbox>
 
180
 
 
181
  <script type="application/x-javascript">
 
182
  <![CDATA[
 
183
    function javaCheck(setFocus) {
 
184
      if (!jvmConfigList) return;
 
185
      var checked = document.getElementById("advancedJavaAllow").checked;
 
186
      setVisible(checked);
 
187
    }
 
188
 
 
189
    const nsIJVMConfig = Components.interfaces.nsIJVMConfig;
 
190
    var jvmConfigMgr;
 
191
    var jvmConfigList = getJVMConfigList();
 
192
    const currentJVMPluginPath = getCurrentJVMPluginPath();
 
193
    var oldJVMConfig = null;
 
194
 
 
195
    function getJVMConfigMgr() {
 
196
      return "@mozilla.org/oji/jvm-config-mgr;1" in Components.classes
 
197
             && Components.classes["@mozilla.org/oji/jvm-config-mgr;1"]
 
198
                          .getService(Components.interfaces.nsIJVMConfigManager);
 
199
    }
 
200
 
 
201
    function getJVMConfigList() {
 
202
      if (!jvmConfigMgr)
 
203
        jvmConfigMgr = getJVMConfigMgr();
 
204
 
 
205
      return jvmConfigMgr && jvmConfigMgr.getJVMConfigList();
 
206
    }
 
207
 
 
208
    function getCurrentJVMPluginPath() {
 
209
      var result = "";
 
210
      if ("application/x-java-vm" in navigator.mimeTypes)
 
211
      try {
 
212
        var prefs = Components.classes["@mozilla.org/preferences-service;1"]
 
213
                              .getService(Components.interfaces.nsIPrefBranch);
 
214
 
 
215
        // Since we don't have a fullPath attribute in nsIDOMPlugin,
 
216
        // we have to set the set pref "plugin.expose_full_path"
 
217
        // to true and then get it. Related bug is 204476
 
218
        var oldValue = prefs.getBoolPref("plugin.expose_full_path");
 
219
        if (!oldValue)
 
220
          prefs.setBoolPref("plugin.expose_full_path", true);
 
221
 
 
222
        try {
 
223
          result = navigator.mimeTypes["application/x-java-vm"]
 
224
                            .enabledPlugin.filename;
 
225
        } catch (e) {};
 
226
 
 
227
        // Set the pref to original value.
 
228
        if (!oldValue)
 
229
          prefs.setBoolPref("plugin.expose_full_path", oldValue);
 
230
      } catch (e) {}
 
231
 
 
232
      return result;
 
233
    }
 
234
 
 
235
    const jvmConfigListView = {
 
236
      currentJVMConfig : null,
 
237
 
 
238
      rowCount : 0,
 
239
 
 
240
      setTree : function(tree) {},
 
241
      getImageSrc : function(row, column) {},
 
242
      getProgressMode : function(row, column) {},
 
243
      getCellValue : function(row, column) {},
 
244
      isSeparator : function(index) {return false;},
 
245
      isSorted: function() { return false; },
 
246
      isContainer : function(index) {return false;},
 
247
      cycleHeader : function(aColId, aElt) {},
 
248
      getRowProperties : function(row, column, prop) {},
 
249
      getColumnProperties : function(column, columnElement, prop) {},
 
250
      getCellProperties : function(row, prop) {},
 
251
 
 
252
      getCellText : function(row,column) {
 
253
        if (jvmConfigList) {
 
254
          var jvmConfig = jvmConfigList.queryElementAt(row, nsIJVMConfig);
 
255
          if (column == "name")
 
256
            return jvmConfig.version;
 
257
          if (column == "home")
 
258
            return jvmConfig.path.path;
 
259
        }
 
260
        return "";
 
261
      },
 
262
 
 
263
      refresh : function(jvmConfigListObj) {
 
264
        if (jvmConfigList) {
 
265
          this.rowCount = jvmConfigList.length;
 
266
          var currentIndex = -1;
 
267
          for (i = 0; i < this.rowCount; i++) {
 
268
            var jvmConfig = jvmConfigList.queryElementAt(i, nsIJVMConfig)
 
269
            var jvmHome = jvmConfig.path.path;
 
270
            if (currentJVMPluginPath.indexOf(jvmHome + "/") >= 0) {
 
271
              this.currentJVMConfig = jvmConfig;
 
272
              currentIndex = i;
 
273
            }
 
274
          }
 
275
          // Only show the panel if we have the choice.
 
276
          if (jvmConfigList.length == 0 ||
 
277
             (jvmConfigList.length == 1 && currentIndex >= 0)) {
 
278
            setVisible(false);
 
279
            return;
 
280
          }
 
281
          jvmConfigListObj.treeBoxObject.view = this;
 
282
          if (currentIndex >= 0)
 
283
            jvmConfigListView.selection.select(currentIndex);
 
284
        } else {
 
285
          this.rowCount = 0;
 
286
        }
 
287
      },
 
288
 
 
289
      getCurrentJVMConfig : function() {
 
290
        return this.currentJVMConfig;
 
291
      }
 
292
    };
 
293
 
 
294
    function setVisible(visible) {
 
295
      var javaConfigPanel = document.getElementById("javaPluginSettings");
 
296
      javaConfigPanel.hidden = !visible;
 
297
    }
 
298
 
 
299
    function initJVMConfigList() {
 
300
      var javaChecked = document.getElementById("advancedJavaAllow").checked;
 
301
      if (jvmConfigList) {
 
302
        var jvmConfigListObj = document.getElementById("jvmConfigListObj");
 
303
        if (jvmConfigListObj) {
 
304
          jvmConfigListView.refresh(jvmConfigListObj);
 
305
          oldJVMConfig = jvmConfigListView.getCurrentJVMConfig();
 
306
          parent.hPrefWindow.registerOKCallbackFunc(switchJVM);
 
307
        }
 
308
        if (!javaChecked) setVisible(false);
 
309
      } else {
 
310
        setVisible(false);
 
311
      }
 
312
    }
 
313
 
 
314
    function switchJVM() {
 
315
      var currentIndex = jvmConfigListView.selection.currentIndex;
 
316
      if (currentIndex >= 0 && jvmConfigMgr && jvmConfigList) {
 
317
        var currentJVMConfig =
 
318
              jvmConfigList.queryElementAt(currentIndex, nsIJVMConfig);
 
319
        if (currentJVMConfig && currentJVMConfig != oldJVMConfig) {
 
320
          var promptService =
 
321
                Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
 
322
                  .getService(Components.interfaces.nsIPromptService);
 
323
 
 
324
          var navbundle = document.getElementById("navBundle");
 
325
          var brandbundle = document.getElementById("brandBundle");
 
326
          var dialogTitle = navbundle.getString("switchJVMTitle");
 
327
 
 
328
          try {
 
329
            jvmConfigMgr.setCurrentJVMConfig(currentJVMConfig);
 
330
          } catch (e) {
 
331
            errorMsg =  navbundle.getString("switchJVMFailed");
 
332
            promptService.alert(window, dialogTitle, errorMsg);
 
333
            return;
 
334
          }
 
335
 
 
336
          oldJVMConfig = currentJVMConfig;
 
337
        }
 
338
      }
 
339
    }
 
340
  ]]>
 
341
  </script>
 
342
  <stringbundle id="navBundle"
 
343
                src="chrome://navigator/locale/navigator.properties"/>
 
344
  <stringbundle id="brandBundle"
 
345
                src="chrome://global/locale/brand.properties"/>
 
346
  <groupbox id="javaPluginSettings" align="start">
 
347
    <caption label="&jvm.configuration;"/>
 
348
    <tree id="jvmConfigListObj" style="width: 60em; height: 10em"
 
349
          hidecolumnpicker="true">
 
350
      <treecols>
 
351
        <treecol id="name" label="&jvm.name;" flex="2"/>
 
352
        <splitter class="tree-splitter"/>
 
353
        <treecol id="home" label="&jvm.home;" flex="13"/>
 
354
      </treecols>
 
355
      <treechildren/>
 
356
    </tree>
 
357
  </groupbox>
 
358
 
 
359
  <groupbox id="perfSettings">
 
360
    <caption id="perfLabel" label="&perfTitle.label;"/>
 
361
    <vbox id="perfBox" align="start">
 
362
      <checkbox id="enableTurbo" label="&enableTurbo.label;" accesskey="&enableTurboCheck.accesskey;"
 
363
                oncommand="parent.isTurboEnabled = this.checked;"/>
 
364
      <vbox class="indent" flex="1">
 
365
        <description>&perfdescription.label;</description>
 
366
      </vbox>
 
367
    </vbox>
 
368
  </groupbox>
 
369
  <groupbox id="systemPrefs">
 
370
    <caption id="systemPrefCaption" label="&systemPrefCaption.label;"/>
 
371
    <vbox id="systemPrefBox" align="start">
 
372
      <checkbox id="systemPrefCheck" label="&systemPrefCheck.label;" accesskey="&systemPrefCheck.accesskey;"
 
373
                prefstring="config.use_system_prefs"
 
374
                oncommand="sysPrefUpdate();"/>
 
375
      <vbox class="indent" flex="1">
 
376
        <description>&systemPrefDescription.label;</description>
 
377
      </vbox>
 
378
    </vbox>
 
379
  </groupbox>
 
380
  
 
381
</page>