michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsIFile; michael@0: interface nsIURI; michael@0: interface nsIDOMFile; michael@0: interface nsIDOMWindow; michael@0: interface nsISimpleEnumerator; michael@0: michael@0: [scriptable, function, uuid(0d79adad-b244-49A5-9997-2a8cad93fc44)] michael@0: interface nsIFilePickerShownCallback : nsISupports michael@0: { michael@0: /** michael@0: * Callback which is called when a filepicker is shown and a result michael@0: * is returned. michael@0: * michael@0: * @param aResult One of returnOK, returnCancel, or returnReplace michael@0: */ michael@0: void done(in short aResult); michael@0: }; michael@0: michael@0: [scriptable, uuid(f93509a0-0434-11e3-8ffd-0800200c9a66)] michael@0: interface nsIFilePicker : nsISupports michael@0: { michael@0: const short modeOpen = 0; // Load a file or directory michael@0: const short modeSave = 1; // Save a file or directory michael@0: const short modeGetFolder = 2; // Select a folder/directory michael@0: const short modeOpenMultiple= 3; // Load multiple files michael@0: michael@0: const short returnOK = 0; // User hit Ok, process selection michael@0: const short returnCancel = 1; // User hit cancel, ignore selection michael@0: const short returnReplace = 2; // User acknowledged file already exists so ok to replace, process selection michael@0: michael@0: const long filterAll = 0x001; // *.* michael@0: const long filterHTML = 0x002; // *.html; *.htm michael@0: const long filterText = 0x004; // *.txt michael@0: const long filterImages = 0x008; // *.jpe; *.jpg; *.jpeg; *.gif; michael@0: // *.png; *.bmp; *.ico; *.svg; michael@0: // *.svgz; *.tif; *.tiff; *.ai; michael@0: // *.drw; *.pct; *.psp; *.xcf; michael@0: // *.psd; *.raw michael@0: const long filterXML = 0x010; // *.xml michael@0: const long filterXUL = 0x020; // *.xul michael@0: const long filterApps = 0x040; // Applications (per-platform implementation) michael@0: const long filterAllowURLs = 0x080; // Allow URLs michael@0: const long filterAudio = 0x100; // *.aac; *.aif; *.flac; *.iff; michael@0: // *.m4a; *.m4b; *.mid; *.midi; michael@0: // *.mp3; *.mpa; *.mpc; *.oga; michael@0: // *.ogg; *.ra; *.ram; *.snd; michael@0: // *.wav; *.wma michael@0: const long filterVideo = 0x200; // *.avi; *.divx; *.flv; *.m4v; michael@0: // *.mkv; *.mov; *.mp4; *.mpeg; michael@0: // *.mpg; *.ogm; *.ogv; *.ogx; michael@0: // *.rm; *.rmvb; *.smil; *.webm; michael@0: // *.wmv; *.xvid michael@0: michael@0: /** michael@0: * Initialize the file picker widget. The file picker is not valid until this michael@0: * method is called. michael@0: * michael@0: * @param parent nsIDOMWindow parent. This dialog will be dependent michael@0: * on this parent. parent must be non-null. michael@0: * @param title The title for the file widget michael@0: * @param mode load, save, or get folder michael@0: * michael@0: */ michael@0: void init(in nsIDOMWindow parent, in AString title, in short mode); michael@0: michael@0: /** michael@0: * Append to the filter list with things from the predefined list michael@0: * michael@0: * @param filters mask of filters i.e. (filterAll | filterHTML) michael@0: * michael@0: */ michael@0: void appendFilters(in long filterMask); michael@0: michael@0: /** michael@0: * Add a filter michael@0: * michael@0: * @param title name of the filter michael@0: * @param filter extensions to filter -- semicolon and space separated michael@0: * michael@0: */ michael@0: void appendFilter(in AString title, michael@0: in AString filter); michael@0: michael@0: /** michael@0: * The filename that should be suggested to the user as a default. This should michael@0: * include the extension. michael@0: * michael@0: * @throws NS_ERROR_FAILURE on attempts to get michael@0: */ michael@0: attribute AString defaultString; michael@0: michael@0: /** michael@0: * The extension that should be associated with files of the type we michael@0: * want to work with. On some platforms, this extension will be michael@0: * automatically appended to filenames the user enters, if needed. michael@0: */ michael@0: attribute AString defaultExtension; michael@0: michael@0: /** michael@0: * The filter which is currently selected in the File Picker dialog michael@0: * michael@0: * @return Returns the index (0 based) of the selected filter in the filter list. michael@0: */ michael@0: attribute long filterIndex; michael@0: michael@0: /** michael@0: * Set the directory that the file open/save dialog initially displays michael@0: * michael@0: * @param displayDirectory the name of the directory michael@0: * michael@0: */ michael@0: attribute nsIFile displayDirectory; michael@0: michael@0: michael@0: /** michael@0: * Get the nsIFile for the file or directory. michael@0: * michael@0: * @return Returns the file currently selected michael@0: */ michael@0: readonly attribute nsIFile file; michael@0: michael@0: /** michael@0: * Get the nsIURI for the file or directory. michael@0: * michael@0: * @return Returns the file currently selected michael@0: */ michael@0: readonly attribute nsIURI fileURL; michael@0: michael@0: /** michael@0: * Get the enumerator for the selected files michael@0: * only works in the modeOpenMultiple mode michael@0: * michael@0: * @return Returns the files currently selected michael@0: */ michael@0: readonly attribute nsISimpleEnumerator files; michael@0: michael@0: /** michael@0: * Get the nsIDOMFile for the file. michael@0: * michael@0: * @return Returns the file currently selected as DOMFile michael@0: */ michael@0: readonly attribute nsIDOMFile domfile; michael@0: michael@0: /** michael@0: * Get the enumerator for the selected files michael@0: * only works in the modeOpenMultiple mode michael@0: * michael@0: * @return Returns the files currently selected as DOMFiles michael@0: */ michael@0: readonly attribute nsISimpleEnumerator domfiles; michael@0: michael@0: /** michael@0: * Controls whether the chosen file(s) should be added to the system's recent michael@0: * documents list. This attribute will be ignored if the system has no "Recent michael@0: * Docs" concept, or if the application is in private browsing mode (in which michael@0: * case the file will not be added). Defaults to true. michael@0: */ michael@0: attribute boolean addToRecentDocs; michael@0: michael@0: /** michael@0: * Show File Dialog. The dialog is displayed modally. michael@0: * michael@0: * @return returnOK if the user selects OK, returnCancel if the user selects cancel michael@0: * michael@0: */ michael@0: [deprecated] short show(); michael@0: michael@0: michael@0: /** michael@0: * Opens the file dialog asynchrounously. michael@0: * The passed in object's done method will be called upon completion. michael@0: */ michael@0: void open(in nsIFilePickerShownCallback aFilePickerShownCallback); michael@0: michael@0: /** michael@0: * The picker's mode, as set by the 'mode' argument passed to init() michael@0: * (one of the modeOpen et. al. constants specified above). michael@0: */ michael@0: readonly attribute short mode; michael@0: };