gecko/widget/public/nsIFilePicker.idl

159 lines
5.5 KiB
Plaintext
Raw Normal View History

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsILocalFile;
interface nsIURI;
interface nsIDOMWindow;
interface nsISimpleEnumerator;
[scriptable, uuid(d24ef0aa-d555-4117-84af-9cbbb7406909)]
interface nsIFilePicker : nsISupports
{
const short modeOpen = 0; // Load a file or directory
const short modeSave = 1; // Save a file or directory
const short modeGetFolder = 2; // Select a folder/directory
const short modeOpenMultiple= 3; // Load multiple files
const short returnOK = 0; // User hit Ok, process selection
const short returnCancel = 1; // User hit cancel, ignore selection
const short returnReplace = 2; // User acknowledged file already exists so ok to replace, process selection
const long filterAll = 0x01; // *.*
const long filterHTML = 0x02; // *.html; *.htm
const long filterText = 0x04; // *.txt
const long filterImages = 0x08; // *.png; *.gif; *.jpg; *.jpeg
const long filterXML = 0x10; // *.xml
const long filterXUL = 0x20; // *.xul
const long filterApps = 0x40; // Applications (per-platform implementation)
const long filterAllowURLs = 0x80; // Allow URLs
/**
* Initialize the file picker widget. The file picker is not valid until this
* method is called.
*
* @param parent nsIDOMWindow parent. This dialog will be dependent
* on this parent. parent must be non-null.
* @param title The title for the file widget
* @param mode load, save, or get folder
*
*/
void init(in nsIDOMWindow parent, in AString title, in short mode);
/**
* Append to the filter list with things from the predefined list
*
* @param filters mask of filters i.e. (filterAll | filterHTML)
*
*/
void appendFilters(in long filterMask);
/**
* Add a filter
*
* @param title name of the filter
* @param filter extensions to filter -- semicolon and space separated
*
*/
void appendFilter(in AString title,
in AString filter);
/**
* The filename that should be suggested to the user as a default. This should
* include the extension.
*
* @throws NS_ERROR_FAILURE on attempts to get
*/
attribute AString defaultString;
/**
* The extension that should be associated with files of the type we
* want to work with. On some platforms, this extension will be
* automatically appended to filenames the user enters, if needed.
*/
attribute AString defaultExtension;
/**
* The filter which is currently selected in the File Picker dialog
*
* @return Returns the index (0 based) of the selected filter in the filter list.
*/
attribute long filterIndex;
/**
* Set the directory that the file open/save dialog initially displays
*
* @param displayDirectory the name of the directory
*
*/
attribute nsILocalFile displayDirectory;
/**
* Get the nsILocalFile for the file or directory.
*
* @return Returns the file currently selected
*/
readonly attribute nsILocalFile file;
/**
* Get the nsIURI for the file or directory.
*
* @return Returns the file currently selected
*/
readonly attribute nsIURI fileURL;
/**
* Get the enumerator for the selected files
* only works in the modeOpenMultiple mode
*
* @return Returns the files currently selected
*/
readonly attribute nsISimpleEnumerator files;
/**
* Show File Dialog. The dialog is displayed modally.
*
* @return returnOK if the user selects OK, returnCancel if the user selects cancel
*
*/
short show();
};