Source code

Revision control

Other Tools

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 mozIDOMWindowProxy;
12
interface nsISimpleEnumerator;
13
14
[scriptable, function, uuid(0d79adad-b244-49A5-9997-2a8cad93fc44)]
15
interface nsIFilePickerShownCallback : nsISupports
16
{
17
/**
18
* Callback which is called when a filepicker is shown and a result
19
* is returned.
20
*
21
* @param aResult One of returnOK, returnCancel, or returnReplace
22
*/
23
void done(in short aResult);
24
};
25
26
[scriptable, uuid(9285b984-02d3-46b4-9514-7da8c471a747)]
27
interface nsIFilePicker : nsISupports
28
{
29
const short modeOpen = 0; // Load a file or directory
30
const short modeSave = 1; // Save a file or directory
31
const short modeGetFolder = 2; // Select a folder/directory
32
const short modeOpenMultiple= 3; // Load multiple files
33
34
const short returnOK = 0; // User hit Ok, process selection
35
const short returnCancel = 1; // User hit cancel, ignore selection
36
const short returnReplace = 2; // User acknowledged file already exists so ok to replace, process selection
37
38
const long filterAll = 0x001; // *.*
39
const long filterHTML = 0x002; // *.html; *.htm
40
const long filterText = 0x004; // *.txt
41
const long filterImages = 0x008; // *.jpe; *.jpg; *.jpeg; *.gif;
42
// *.png; *.bmp; *.ico; *.svg;
43
// *.svgz; *.tif; *.tiff; *.ai;
44
// *.drw; *.pct; *.psp; *.xcf;
45
// *.psd; *.raw
46
const long filterXML = 0x010; // *.xml
47
const long filterXUL = 0x020; // *.xul
48
const long filterApps = 0x040; // Applications (per-platform implementation)
49
const long filterAllowURLs = 0x080; // Allow URLs
50
const long filterAudio = 0x100; // *.aac; *.aif; *.flac; *.iff;
51
// *.m4a; *.m4b; *.mid; *.midi;
52
// *.mp3; *.mpa; *.mpc; *.oga;
53
// *.ogg; *.ra; *.ram; *.snd;
54
// *.wav; *.wma
55
const long filterVideo = 0x200; // *.avi; *.divx; *.flv; *.m4v;
56
// *.mkv; *.mov; *.mp4; *.mpeg;
57
// *.mpg; *.ogm; *.ogv; *.ogx;
58
// *.rm; *.rmvb; *.smil; *.webm;
59
// *.wmv; *.xvid
60
61
const short captureNone = 0; // No capture target specified.
62
const short captureDefault = 1; // Missing/invalid value default.
63
const short captureUser = 2; // "user" capture target specified.
64
const short captureEnv = 3; // "environment" capture target specified.
65
66
/**
67
* Initialize the file picker widget. The file picker is not valid until this
68
* method is called.
69
*
70
* @param parent mozIDOMWindow parent. This dialog will be dependent
71
* on this parent. parent must be non-null.
72
* @param title The title for the file widget
73
* @param mode load, save, or get folder
74
*
75
*/
76
void init(in mozIDOMWindowProxy parent, in AString title, in short mode);
77
78
/**
79
* Append to the filter list with things from the predefined list
80
*
81
* @param filters mask of filters i.e. (filterAll | filterHTML)
82
*
83
*/
84
void appendFilters(in long filterMask);
85
86
/**
87
* Add a filter
88
*
89
* @param title name of the filter
90
* @param filter extensions to filter -- semicolon and space separated
91
*
92
*/
93
void appendFilter(in AString title,
94
in AString filter);
95
96
/**
97
* Add a raw filter (eg, add a MIME type without transforming it to a list of
98
* extensions).
99
*
100
* @param filter a filter taken directly from the accept attribute
101
* without processing
102
*
103
*/
104
void appendRawFilter(in AString filter);
105
106
/**
107
* The filename that should be suggested to the user as a default. This should
108
* include the extension.
109
*
110
* @throws NS_ERROR_FAILURE on attempts to get
111
*/
112
attribute AString defaultString;
113
114
/**
115
* The extension that should be associated with files of the type we
116
* want to work with. On some platforms, this extension will be
117
* automatically appended to filenames the user enters, if needed.
118
*/
119
attribute AString defaultExtension;
120
121
/**
122
* The filter which is currently selected in the File Picker dialog
123
*
124
* @return Returns the index (0 based) of the selected filter in the filter list.
125
*/
126
attribute long filterIndex;
127
128
/**
129
* Set the directory that the file open/save dialog initially displays
130
* Note that, if displaySpecialDirectory has been already set, this value will
131
* be ignored.
132
*
133
* @param displayDirectory the name of the directory
134
*
135
*/
136
attribute nsIFile displayDirectory;
137
138
/**
139
* Set the directory that the file open/save dialog initially displays using
140
* one of the special name as such as 'Desk', 'TmpD', and so on.
141
* Note that, if displayDirectory has been already set, this value will be
142
* ignored.
143
*
144
* @param displaySpecialDirectory the name of the special directory
145
*
146
*/
147
attribute AString displaySpecialDirectory;
148
149
150
/**
151
* Get the nsIFile for the file or directory.
152
*
153
* @return Returns the file currently selected
154
*/
155
readonly attribute nsIFile file;
156
157
/**
158
* Get the nsIURI for the file or directory.
159
*
160
* @return Returns the file currently selected
161
*/
162
readonly attribute nsIURI fileURL;
163
164
/**
165
* Get the enumerator for the selected files
166
* only works in the modeOpenMultiple mode
167
*
168
* @return Returns the files currently selected
169
*/
170
readonly attribute nsISimpleEnumerator files;
171
172
/**
173
* Get the DOM File or the DOM Directory
174
*
175
* @return Returns the file or directory currently selected DOM object.
176
*/
177
readonly attribute nsISupports domFileOrDirectory;
178
179
/**
180
* Get the enumerator for the selected files or directories
181
* only works in the modeOpenMultiple mode
182
*
183
* @return Returns the files/directories currently selected as DOM object.
184
*/
185
readonly attribute nsISimpleEnumerator domFileOrDirectoryEnumerator;
186
187
/**
188
* Controls whether the chosen file(s) should be added to the system's recent
189
* documents list. This attribute will be ignored if the system has no "Recent
190
* Docs" concept, or if the application is in private browsing mode (in which
191
* case the file will not be added). Defaults to true.
192
*/
193
attribute boolean addToRecentDocs;
194
195
/**
196
* Opens the file dialog asynchrounously.
197
* The passed in object's done method will be called upon completion.
198
*/
199
void open(in nsIFilePickerShownCallback aFilePickerShownCallback);
200
201
/**
202
* The picker's mode, as set by the 'mode' argument passed to init()
203
* (one of the modeOpen et. al. constants specified above).
204
*/
205
readonly attribute short mode;
206
207
/**
208
* If set to non-empty string, the nsIFilePicker implementation
209
* may use okButtonLabel as the label for the button the user uses to accept
210
* file selection.
211
*/
212
attribute AString okButtonLabel;
213
214
attribute short capture;
215
};