widget/nsIFilePicker.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial