1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #include
"nsISupports.idl"
11 interface nsIDOMWindow
;
12 interface nsISimpleEnumerator
;
14 [scriptable
, function
, uuid(0d79adad
-b244
-49A5
-9997-2a8cad93fc44
)]
15 interface nsIFilePickerShownCallback
: nsISupports
18 * Callback which is called when a filepicker is shown and a result
21 * @param aResult One of returnOK, returnCancel, or returnReplace
23 void done
(in short aResult
);
26 [scriptable
, uuid(60e2dfb6
-3fc7
-4A2C
-8137-16bef44536fc
)]
27 interface nsIFilePicker
: nsISupports
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
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
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;
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;
55 const long filterVideo
= 0x200; // *.avi; *.divx; *.flv; *.m4v;
56 // *.mkv; *.mov; *.mp4; *.mpeg;
57 // *.mpg; *.ogm; *.ogv; *.ogx;
58 // *.rm; *.rmvb; *.smil; *.webm;
62 * Initialize the file picker widget. The file picker is not valid until this
65 * @param parent nsIDOMWindow parent. This dialog will be dependent
66 * on this parent. parent must be non-null.
67 * @param title The title for the file widget
68 * @param mode load, save, or get folder
71 void init
(in nsIDOMWindow parent
, in AString title
, in short mode
);
74 * Append to the filter list with things from the predefined list
76 * @param filters mask of filters i.e. (filterAll | filterHTML)
79 void appendFilters
(in long filterMask
);
84 * @param title name of the filter
85 * @param filter extensions to filter -- semicolon and space separated
88 void appendFilter
(in AString title
,
92 * The filename that should be suggested to the user as a default. This should
93 * include the extension.
95 * @throws NS_ERROR_FAILURE on attempts to get
97 attribute AString defaultString
;
100 * The extension that should be associated with files of the type we
101 * want to work with. On some platforms, this extension will be
102 * automatically appended to filenames the user enters, if needed.
104 attribute AString defaultExtension
;
107 * The filter which is currently selected in the File Picker dialog
109 * @return Returns the index (0 based) of the selected filter in the filter list.
111 attribute
long filterIndex
;
114 * Set the directory that the file open/save dialog initially displays
116 * @param displayDirectory the name of the directory
119 attribute nsIFile displayDirectory
;
123 * Get the nsIFile for the file or directory.
125 * @return Returns the file currently selected
127 readonly attribute nsIFile file
;
130 * Get the nsIURI for the file or directory.
132 * @return Returns the file currently selected
134 readonly attribute nsIURI fileURL
;
137 * Get the enumerator for the selected files
138 * only works in the modeOpenMultiple mode
140 * @return Returns the files currently selected
142 readonly attribute nsISimpleEnumerator files
;
145 * Controls whether the chosen file(s) should be added to the system's recent
146 * documents list. This attribute will be ignored if the system has no "Recent
147 * Docs" concept, or if the application is in private browsing mode (in which
148 * case the file will not be added). Defaults to true.
150 attribute
boolean addToRecentDocs
;
153 * Show File Dialog. The dialog is displayed modally.
155 * @return returnOK if the user selects OK, returnCancel if the user selects cancel
158 [deprecated
] short show
();
162 * Opens the file dialog asynchrounously.
163 * The passed in object's done method will be called upon completion.
165 void open
(in nsIFilePickerShownCallback aFilePickerShownCallback
);