annotate dwt/browser.old/FilePicker.d @ 288:4ee8c4237614

old branches... commit by mistake
author John Reimer<terminal.node@gmail.com>
date Tue, 05 Aug 2008 18:00:50 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
288
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
1 /*******************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2003, 2007 IBM Corporation and others.
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
7 *
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
8 * Contributors:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
10 * Port to the D programming language:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
11 * John Reimer <terminal.node@gmail.com>
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
12 *******************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
13
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
14 module dwt.browser.FilePicker;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
15
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
16 import tango.io.model.IFile;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
17 import Utf = tango.text.convert.Utf;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
18
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
19 import dwt.dwthelper.utils;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
20
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
21 import dwt.DWT;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
22
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
23 import XPCOM = dwt.internal.mozilla.nsXPCOM;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
24
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
25 import dwt.browser.Mozilla;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
26 import dwt.browser.MozillaDelegate;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
27
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
28 import dwt.internal.mozilla.nsEmbedString;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
29 import dwt.internal.mozilla.nsIDOMWindow;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
30 import dwt.internal.mozilla.nsID;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
31 import dwt.internal.mozilla.nsIFilePicker;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
32 import dwt.internal.mozilla.nsILocalFile;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
33 import dwt.internal.mozilla.nsISupports;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
34 import dwt.internal.mozilla.nsSimpleEnumerator;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
35 import dwt.internal.mozilla.nsStringAPI;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
36 import dwt.internal.mozilla.nsError;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
37
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
38 import dwt.widgets.DirectoryDialog;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
39 import dwt.widgets.Display;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
40 import dwt.widgets.FileDialog;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
41 import dwt.widgets.Shell;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
42
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
43
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
44 class FilePicker : nsISupports, nsIFilePicker
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
45 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
46 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
47
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
48 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
49
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
50 private
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
51 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
52 int _refCount = 0;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
53 short _mode;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
54
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
55 nsIDOMWindow _parent;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
56
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
57 String[] _files;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
58 String _masks;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
59 String _defaultFilename,
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
60 _directory,
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
61 _title;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
62 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
63 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
64
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
65 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
66
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
67 static final String SEPARATOR = FileConst.FileSeparatorChar;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
68
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
69 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
70
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
71 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
72
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
73 this ()
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
74 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
75 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
76
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
77 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
78
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
79 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
80
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
81 nsrefcnt AddRef ()
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
82 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
83 _refCount++;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
84 return _refCount;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
85 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
86
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
87 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
88
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
89 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
90
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
91 nsresult QueryInterface ( inout nsID riid, void** ppvObject)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
92 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
93 if (riid is null || ppvObject is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
94 return NS_ERROR_NO_INTERFACE;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
95
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
96 if (riid == nsISupports.IID)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
97 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
98 *ppvObject = cast(void*)cast(nsISupports) this;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
99 AddRef ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
100 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
101 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
102
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
103 if (riid == nsIFilePicker.IID))
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
104 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
105 *ppvObject = cast(void*)cast(nsIFilePicker) this;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
106 AddRef ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
107 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
108 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
109
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
110 if (riid == nsIFilePicker_1_8.IID)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
111 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
112 *ppvObject = cast(void*)cast(nsIFilePicker_1_8) this;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
113 AddRef ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
114 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
115 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
116
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
117 *ppvObject = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
118 return NS_ERROR_NO_INTERFACE;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
119 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
120
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
121 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
122
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
123 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
124
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
125 nsrefcnt Release ()
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
126 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
127 _refCount--;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
128
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
129 if (_refCount is 0)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
130 // No big deal here; just allow the GC to reap this object
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
131 // once all references are expired. -JJR
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
132 // delete this;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
133 return 0;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
134
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
135 return _refCount;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
136 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
137
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
138 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
139
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
140 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
141
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
142 /* SWT Comment:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
143 *
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
144 * As of Mozilla 1.8 some of nsIFilePicker's string arguments changed type. This method
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
145 * answers a java string based on the type of string that is appropriate for the Mozilla
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
146 * version being used.
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
147 */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
148
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
149 override String parseAString (nsEmbedString str)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
150 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
151 return null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
152 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
153
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
154 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
155
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
156 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
157
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
158 /* nsIFilePicker */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
159
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
160 nsresult Init (nsIDOMWindow parent, nsAString* title, PRInt16 mode)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
161 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
162 _parent = parent;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
163 _mode = mode;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
164 _title = parseAString (title);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
165 return XPCOM;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
166 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
167
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
168 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
169
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
170 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
171
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
172 nsresult Show (PRUint32* retval)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
173 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
174 if (_mode is nsIFilePicker.modeGetFolder)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
175 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
176 /* picking a directory */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
177 int result = this.showDirectoryPicker ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
178 *retval = result;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
179 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
180 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
181
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
182 /* picking a file */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
183 int style = _mode is nsIFilePicker.modeSave ? DWT.SAVE : DWT.OPEN;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
184
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
185 if (_mode is nsIFilePicker.modeOpenMultiple)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
186 style |= DWT.MULTI;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
187
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
188 Display display = Display.getCurrent ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
189 Shell parent = null; // TODO compute parent
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
190
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
191 if (parent is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
192 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
193 parent = new Shell (display);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
194 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
195
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
196 FileDialog dialog = new FileDialog (parent, style);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
197
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
198 if (_title !is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
199 dialog.setText (_title);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
200
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
201 if (_directory !is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
202 dialog.setFilterPath (_directory);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
203
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
204 if (_masks !is null) {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
205 String[] str ~= _masks;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
206 dialog.setFilterExtensions ( str );
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
207 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
208
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
209 if (_defaultFilename !is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
210 dialog.setFileName (_defaultFilename);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
211
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
212 String filename = dialog.open ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
213 files = dialog.getFileNames ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
214 _directory = dialog.getFilterPath ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
215 _title = _defaultFilename = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
216 _masks = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
217 int result = filename is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
218 *retval = result;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
219 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
220 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
221
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
222 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
223
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
224 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
225
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
226 int showDirectoryPicker ()
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
227 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
228 Display display = Display.getCurrent ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
229 Shell parent = null; // TODO compute parent
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
230
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
231 if (parent is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
232 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
233 parent = new Shell (display);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
234 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
235
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
236 DirectoryDialog dialog = new DirectoryDialog (parent, DWT.NONE);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
237
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
238 if (_title !is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
239 dialog.setText (_title);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
240 if (_directory !is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
241 dialog.setFilterPath (_directory);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
242 _directory = dialog.open ();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
243 _title = _defaultFilename = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
244 _files = _masks = null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
245 return _directory is null ? nsIFilePicker.returnCancel : nsIFilePicker.returnOK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
246 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
247
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
248 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
249
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
250 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
251
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
252 nsresult GetFiles ( nsISimpleEnumerator* aFiles)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
253 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
254 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
255 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
256
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
257 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
258
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
259 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
260
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
261 nsresult GetFileURL (nsIFileURL aFileURL)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
262 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
263 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
264 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
265
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
266 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
267
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
268 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
269
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
270 nsresult GetFile (nsILocalFile* aFile)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
271 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
272 String filename = ""; //$NON-NLS-1$
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
273
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
274 if (_directory !is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
275 filename ~= _directory ~ SEPARATOR;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
276 if (_files !is null && _files.length > 0)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
277 filename ~= _files[0];
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
278
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
279 // Create a nsEmbedString which will be automatically disposed
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
280 // at the end of scope.
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
281 scope auto path = new nsEmbedString( filename );
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
282
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
283 nsresult rc = XPCOM.NS_NewLocalFile ( cast(nsAString*)path, 1, aFile);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
284
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
285 if (rc !is NS_OK)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
286 Mozilla.error (rc);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
287 if (aFile is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
288 Mozilla.error (NS_ERROR_NULL_POINTER);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
289
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
290 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
291 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
292
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
293 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
294
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
295 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
296
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
297 nsresult SetDisplayDirectory (nsILocalFile aDisplayDirectory)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
298 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
299 if (aDisplayDirectory is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
300 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
301
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
302 scope auto pathname = new nsEmbedCString;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
303 aDisplayDirectory.GetNativePath ( cast(nsACString*)pathname );
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
304 // TODO: CHECK IF THIS DOES CORRECT STRING CONVERSION -JJR
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
305 char[] buffer = pathname.toString();
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
306 char[] chars = MozillaDelegate.mbcsToWcs (null, buffer);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
307 // "buffer" contains a dup'ed string so we can safely reuse
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
308 // it's memory for the _directory member. -JJR
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
309 _directory = buffer;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
310 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
311 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
312
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
313 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
314
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
315 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
316
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
317 nsresult GetDisplayDirectory (nsILocalFile* aDisplayDirectory)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
318 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
319 String directoryName = _directory !is null ? _directory : ""; //$NON-NLS-1$
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
320 scope auto path = new nsEmbedString (directoryName);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
321 nsresult rc = XPCOM.NS_NewLocalFile ( cast(nsAString*)path, 1, aDisplayDirectory);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
322
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
323 if (rc !is NS_OK)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
324 Mozilla.error (rc);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
325 if (aDisplayDirectory is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
326 Mozilla.error (NS_ERROR_NULL_POINTER);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
327 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
328 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
329
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
330 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
331
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
332 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
333
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
334 nsresult SetFilterIndex (PRInt32 aFilterIndex)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
335 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
336 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
337 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
338
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
339 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
340
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
341 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
342
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
343 nresult GetFilterIndex (PRInt32* aFilterIndex)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
344 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
345 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
346 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
347
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
348 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
349
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
350 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
351
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
352 int SetDefaultExtension (nsAString* aDefaultExtension)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
353 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
354 /* note that the type of argument 1 changed as of Mozilla 1.8 */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
355 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
356 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
357
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
358 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
359
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
360 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
361
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
362 int GetDefaultExtension (nsAString* aDefaultExtension)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
363 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
364 /* note that the type of argument 1 changed as of Mozilla 1.8 */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
365 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
366 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
367
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
368 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
369
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
370 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
371
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
372 nresult SetDefaultString (nsAString* aDefaultString)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
373 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
374 defaultFilename = parseAString (aDefaultString);
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
375 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
376 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
377
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
378 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
379
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
380 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
381
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
382 nresult GetDefaultString (nsAString* aDefaultString)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
383 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
384 /* note that the type of argument 1 changed as of Mozilla 1.8 */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
385 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
386 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
387
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
388 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
389
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
390 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
391
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
392 nresult AppendFilter (nsAString* title, nsAString* filter)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
393 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
394 /* note that the type of arguments 1 and 2 changed as of Mozilla 1.8 */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
395 return NS_ERROR_NOT_IMPLEMENTED;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
396 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
397
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
398 /**************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
399
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
400 **************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
401
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
402 nresult AppendFilters (PRInt32 filterMask)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
403 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
404 String addFilters;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
405
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
406 switch (filterMask)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
407 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
408 case nsIFilePicker.filterAll:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
409 case nsIFilePicker.filterApps:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
410 _masks = null; /* this is equivalent to no filter */
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
411 break;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
412 case nsIFilePicker.filterHTML:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
413 addFilters = "*.htm;*.html" ;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
414 break;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
415 case nsIFilePicker.filterImages:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
416 addFilters = "*.gif;*.jpeg;*.jpg;*.png";
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
417 break;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
418 case nsIFilePicker.filterText:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
419 addFilters = "*.txt";
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
420 break;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
421 case nsIFilePicker.filterXML:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
422 addFilters = "*.xml";
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
423 break;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
424 case nsIFilePicker.filterXUL:
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
425 addFilters = "*.xul";
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
426 break;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
427 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
428
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
429 if (_masks is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
430 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
431 _masks = addFilters;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
432 } else {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
433 if (addFilters !is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
434 _masks ~= addFilters;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
435 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
436 return NS_OK;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
437 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
438
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
439 /******************************************************************************
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
440
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
441 FilePicker for Mozilla Version 1.8
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
442
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
443 ******************************************************************************/
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
444
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
445 class FilePicker_1_8 : FilePicker
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
446 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
447 String parseAString (nsEmbedString str)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
448 {
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
449 if (str is null)
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
450 return null;
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
451 return Utf.toString( str.toString16() );
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
452 }
4ee8c4237614 old branches... commit by mistake
John Reimer<terminal.node@gmail.com>
parents:
diff changeset
453 }