|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #include "nsISupports.idl" |
|
8 |
|
9 interface nsIFile; |
|
10 interface nsIURI; |
|
11 interface nsIDOMFile; |
|
12 interface nsIDOMWindow; |
|
13 interface nsISimpleEnumerator; |
|
14 |
|
15 [scriptable, function, uuid(0d79adad-b244-49A5-9997-2a8cad93fc44)] |
|
16 interface nsIFilePickerShownCallback : nsISupports |
|
17 { |
|
18 /** |
|
19 * Callback which is called when a filepicker is shown and a result |
|
20 * is returned. |
|
21 * |
|
22 * @param aResult One of returnOK, returnCancel, or returnReplace |
|
23 */ |
|
24 void done(in short aResult); |
|
25 }; |
|
26 |
|
27 [scriptable, uuid(f93509a0-0434-11e3-8ffd-0800200c9a66)] |
|
28 interface nsIFilePicker : nsISupports |
|
29 { |
|
30 const short modeOpen = 0; // Load a file or directory |
|
31 const short modeSave = 1; // Save a file or directory |
|
32 const short modeGetFolder = 2; // Select a folder/directory |
|
33 const short modeOpenMultiple= 3; // Load multiple files |
|
34 |
|
35 const short returnOK = 0; // User hit Ok, process selection |
|
36 const short returnCancel = 1; // User hit cancel, ignore selection |
|
37 const short returnReplace = 2; // User acknowledged file already exists so ok to replace, process selection |
|
38 |
|
39 const long filterAll = 0x001; // *.* |
|
40 const long filterHTML = 0x002; // *.html; *.htm |
|
41 const long filterText = 0x004; // *.txt |
|
42 const long filterImages = 0x008; // *.jpe; *.jpg; *.jpeg; *.gif; |
|
43 // *.png; *.bmp; *.ico; *.svg; |
|
44 // *.svgz; *.tif; *.tiff; *.ai; |
|
45 // *.drw; *.pct; *.psp; *.xcf; |
|
46 // *.psd; *.raw |
|
47 const long filterXML = 0x010; // *.xml |
|
48 const long filterXUL = 0x020; // *.xul |
|
49 const long filterApps = 0x040; // Applications (per-platform implementation) |
|
50 const long filterAllowURLs = 0x080; // Allow URLs |
|
51 const long filterAudio = 0x100; // *.aac; *.aif; *.flac; *.iff; |
|
52 // *.m4a; *.m4b; *.mid; *.midi; |
|
53 // *.mp3; *.mpa; *.mpc; *.oga; |
|
54 // *.ogg; *.ra; *.ram; *.snd; |
|
55 // *.wav; *.wma |
|
56 const long filterVideo = 0x200; // *.avi; *.divx; *.flv; *.m4v; |
|
57 // *.mkv; *.mov; *.mp4; *.mpeg; |
|
58 // *.mpg; *.ogm; *.ogv; *.ogx; |
|
59 // *.rm; *.rmvb; *.smil; *.webm; |
|
60 // *.wmv; *.xvid |
|
61 |
|
62 /** |
|
63 * Initialize the file picker widget. The file picker is not valid until this |
|
64 * method is called. |
|
65 * |
|
66 * @param parent nsIDOMWindow parent. This dialog will be dependent |
|
67 * on this parent. parent must be non-null. |
|
68 * @param title The title for the file widget |
|
69 * @param mode load, save, or get folder |
|
70 * |
|
71 */ |
|
72 void init(in nsIDOMWindow parent, in AString title, in short mode); |
|
73 |
|
74 /** |
|
75 * Append to the filter list with things from the predefined list |
|
76 * |
|
77 * @param filters mask of filters i.e. (filterAll | filterHTML) |
|
78 * |
|
79 */ |
|
80 void appendFilters(in long filterMask); |
|
81 |
|
82 /** |
|
83 * Add a filter |
|
84 * |
|
85 * @param title name of the filter |
|
86 * @param filter extensions to filter -- semicolon and space separated |
|
87 * |
|
88 */ |
|
89 void appendFilter(in AString title, |
|
90 in AString filter); |
|
91 |
|
92 /** |
|
93 * The filename that should be suggested to the user as a default. This should |
|
94 * include the extension. |
|
95 * |
|
96 * @throws NS_ERROR_FAILURE on attempts to get |
|
97 */ |
|
98 attribute AString defaultString; |
|
99 |
|
100 /** |
|
101 * The extension that should be associated with files of the type we |
|
102 * want to work with. On some platforms, this extension will be |
|
103 * automatically appended to filenames the user enters, if needed. |
|
104 */ |
|
105 attribute AString defaultExtension; |
|
106 |
|
107 /** |
|
108 * The filter which is currently selected in the File Picker dialog |
|
109 * |
|
110 * @return Returns the index (0 based) of the selected filter in the filter list. |
|
111 */ |
|
112 attribute long filterIndex; |
|
113 |
|
114 /** |
|
115 * Set the directory that the file open/save dialog initially displays |
|
116 * |
|
117 * @param displayDirectory the name of the directory |
|
118 * |
|
119 */ |
|
120 attribute nsIFile displayDirectory; |
|
121 |
|
122 |
|
123 /** |
|
124 * Get the nsIFile for the file or directory. |
|
125 * |
|
126 * @return Returns the file currently selected |
|
127 */ |
|
128 readonly attribute nsIFile file; |
|
129 |
|
130 /** |
|
131 * Get the nsIURI for the file or directory. |
|
132 * |
|
133 * @return Returns the file currently selected |
|
134 */ |
|
135 readonly attribute nsIURI fileURL; |
|
136 |
|
137 /** |
|
138 * Get the enumerator for the selected files |
|
139 * only works in the modeOpenMultiple mode |
|
140 * |
|
141 * @return Returns the files currently selected |
|
142 */ |
|
143 readonly attribute nsISimpleEnumerator files; |
|
144 |
|
145 /** |
|
146 * Get the nsIDOMFile for the file. |
|
147 * |
|
148 * @return Returns the file currently selected as DOMFile |
|
149 */ |
|
150 readonly attribute nsIDOMFile domfile; |
|
151 |
|
152 /** |
|
153 * Get the enumerator for the selected files |
|
154 * only works in the modeOpenMultiple mode |
|
155 * |
|
156 * @return Returns the files currently selected as DOMFiles |
|
157 */ |
|
158 readonly attribute nsISimpleEnumerator domfiles; |
|
159 |
|
160 /** |
|
161 * Controls whether the chosen file(s) should be added to the system's recent |
|
162 * documents list. This attribute will be ignored if the system has no "Recent |
|
163 * Docs" concept, or if the application is in private browsing mode (in which |
|
164 * case the file will not be added). Defaults to true. |
|
165 */ |
|
166 attribute boolean addToRecentDocs; |
|
167 |
|
168 /** |
|
169 * Show File Dialog. The dialog is displayed modally. |
|
170 * |
|
171 * @return returnOK if the user selects OK, returnCancel if the user selects cancel |
|
172 * |
|
173 */ |
|
174 [deprecated] short show(); |
|
175 |
|
176 |
|
177 /** |
|
178 * Opens the file dialog asynchrounously. |
|
179 * The passed in object's done method will be called upon completion. |
|
180 */ |
|
181 void open(in nsIFilePickerShownCallback aFilePickerShownCallback); |
|
182 |
|
183 /** |
|
184 * The picker's mode, as set by the 'mode' argument passed to init() |
|
185 * (one of the modeOpen et. al. constants specified above). |
|
186 */ |
|
187 readonly attribute short mode; |
|
188 }; |