widget/nsIFilePicker.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/nsIFilePicker.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,188 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsISupports.idl"
    1.11 +
    1.12 +interface nsIFile;
    1.13 +interface nsIURI;
    1.14 +interface nsIDOMFile;
    1.15 +interface nsIDOMWindow;
    1.16 +interface nsISimpleEnumerator;
    1.17 +
    1.18 +[scriptable, function, uuid(0d79adad-b244-49A5-9997-2a8cad93fc44)]
    1.19 +interface nsIFilePickerShownCallback : nsISupports
    1.20 +{
    1.21 + /**
    1.22 +  * Callback which is called when a filepicker is shown and a result
    1.23 +  * is returned.
    1.24 +  *
    1.25 +  * @param aResult One of returnOK, returnCancel, or returnReplace
    1.26 +  */
    1.27 +  void done(in short aResult);
    1.28 +};
    1.29 +
    1.30 +[scriptable, uuid(f93509a0-0434-11e3-8ffd-0800200c9a66)]
    1.31 +interface nsIFilePicker : nsISupports
    1.32 +{
    1.33 +  const short modeOpen        = 0;              // Load a file or directory
    1.34 +  const short modeSave        = 1;              // Save a file or directory
    1.35 +  const short modeGetFolder   = 2;              // Select a folder/directory
    1.36 +  const short modeOpenMultiple= 3;              // Load multiple files
    1.37 +
    1.38 +  const short returnOK        = 0;              // User hit Ok, process selection
    1.39 +  const short returnCancel    = 1;              // User hit cancel, ignore selection
    1.40 +  const short returnReplace   = 2;              // User acknowledged file already exists so ok to replace, process selection
    1.41 +
    1.42 +  const long filterAll        = 0x001;          // *.*
    1.43 +  const long filterHTML       = 0x002;          // *.html; *.htm
    1.44 +  const long filterText       = 0x004;          // *.txt
    1.45 +  const long filterImages     = 0x008;          // *.jpe; *.jpg; *.jpeg; *.gif;
    1.46 +                                                // *.png; *.bmp; *.ico; *.svg;
    1.47 +                                                // *.svgz; *.tif; *.tiff; *.ai;
    1.48 +                                                // *.drw; *.pct; *.psp; *.xcf;
    1.49 +                                                // *.psd; *.raw
    1.50 +  const long filterXML        = 0x010;          // *.xml
    1.51 +  const long filterXUL        = 0x020;          // *.xul
    1.52 +  const long filterApps       = 0x040;          // Applications (per-platform implementation)
    1.53 +  const long filterAllowURLs  = 0x080;          // Allow URLs
    1.54 +  const long filterAudio      = 0x100;          // *.aac; *.aif; *.flac; *.iff;
    1.55 +                                                // *.m4a; *.m4b; *.mid; *.midi;
    1.56 +                                                // *.mp3; *.mpa; *.mpc; *.oga;
    1.57 +                                                // *.ogg; *.ra; *.ram; *.snd;
    1.58 +                                                // *.wav; *.wma
    1.59 +  const long filterVideo      = 0x200;          // *.avi; *.divx; *.flv; *.m4v;
    1.60 +                                                // *.mkv; *.mov; *.mp4; *.mpeg;
    1.61 +                                                // *.mpg; *.ogm; *.ogv; *.ogx;
    1.62 +                                                // *.rm; *.rmvb; *.smil; *.webm;
    1.63 +                                                // *.wmv; *.xvid
    1.64 +
    1.65 + /**
    1.66 +  * Initialize the file picker widget.  The file picker is not valid until this
    1.67 +  * method is called.
    1.68 +  *
    1.69 +  * @param      parent   nsIDOMWindow parent.  This dialog will be dependent
    1.70 +  *                      on this parent. parent must be non-null.
    1.71 +  * @param      title    The title for the file widget
    1.72 +  * @param      mode     load, save, or get folder
    1.73 +  *
    1.74 +  */
    1.75 +  void init(in nsIDOMWindow parent, in AString title, in short mode);
    1.76 +
    1.77 + /**
    1.78 +  * Append to the  filter list with things from the predefined list
    1.79 +  *
    1.80 +  * @param      filters  mask of filters i.e. (filterAll | filterHTML)
    1.81 +  *
    1.82 +  */
    1.83 +  void appendFilters(in long filterMask);
    1.84 +
    1.85 + /**
    1.86 +  * Add a filter
    1.87 +  *
    1.88 +  * @param      title    name of the filter
    1.89 +  * @param      filter   extensions to filter -- semicolon and space separated
    1.90 +  *
    1.91 +  */
    1.92 +  void appendFilter(in AString title,
    1.93 +                    in AString filter);
    1.94 +
    1.95 + /**
    1.96 +  * The filename that should be suggested to the user as a default. This should
    1.97 +  * include the extension.
    1.98 +  *
    1.99 +  * @throws NS_ERROR_FAILURE on attempts to get
   1.100 +  */
   1.101 +  attribute AString defaultString;
   1.102 +
   1.103 + /**
   1.104 +  * The extension that should be associated with files of the type we
   1.105 +  * want to work with.  On some platforms, this extension will be
   1.106 +  * automatically appended to filenames the user enters, if needed.  
   1.107 +  */
   1.108 +  attribute AString defaultExtension;
   1.109 +  
   1.110 + /**
   1.111 +  * The filter which is currently selected in the File Picker dialog
   1.112 +  *
   1.113 +  * @return Returns the index (0 based) of the selected filter in the filter list. 
   1.114 +  */
   1.115 +  attribute long filterIndex;
   1.116 +
   1.117 + /**
   1.118 +  * Set the directory that the file open/save dialog initially displays
   1.119 +  *
   1.120 +  * @param      displayDirectory  the name of the directory
   1.121 +  *
   1.122 +  */
   1.123 +  attribute nsIFile displayDirectory;
   1.124 +
   1.125 +
   1.126 + /**
   1.127 +  * Get the nsIFile for the file or directory.
   1.128 +  *
   1.129 +  * @return Returns the file currently selected
   1.130 +  */
   1.131 +  readonly attribute nsIFile file;
   1.132 +
   1.133 + /**
   1.134 +  * Get the nsIURI for the file or directory.
   1.135 +  *
   1.136 +  * @return Returns the file currently selected
   1.137 +  */
   1.138 +  readonly attribute nsIURI fileURL;
   1.139 +
   1.140 + /**
   1.141 +  * Get the enumerator for the selected files
   1.142 +  * only works in the modeOpenMultiple mode
   1.143 +  *
   1.144 +  * @return Returns the files currently selected
   1.145 +  */
   1.146 +  readonly attribute nsISimpleEnumerator files;
   1.147 +
   1.148 + /**
   1.149 +  * Get the nsIDOMFile for the file.
   1.150 +  *
   1.151 +  * @return Returns the file currently selected as DOMFile
   1.152 +  */
   1.153 +  readonly attribute nsIDOMFile domfile;
   1.154 +
   1.155 + /**
   1.156 +  * Get the enumerator for the selected files
   1.157 +  * only works in the modeOpenMultiple mode
   1.158 +  *
   1.159 +  * @return Returns the files currently selected as DOMFiles
   1.160 +  */
   1.161 +  readonly attribute nsISimpleEnumerator domfiles;
   1.162 +
   1.163 + /**
   1.164 +  * Controls whether the chosen file(s) should be added to the system's recent
   1.165 +  * documents list. This attribute will be ignored if the system has no "Recent
   1.166 +  * Docs" concept, or if the application is in private browsing mode (in which
   1.167 +  * case the file will not be added). Defaults to true.
   1.168 +  */
   1.169 +  attribute boolean addToRecentDocs;
   1.170 +
   1.171 + /**
   1.172 +  * Show File Dialog. The dialog is displayed modally.
   1.173 +  *
   1.174 +  * @return returnOK if the user selects OK, returnCancel if the user selects cancel
   1.175 +  *
   1.176 +  */
   1.177 +  [deprecated] short show();
   1.178 +
   1.179 +
   1.180 + /**
   1.181 +  * Opens the file dialog asynchrounously.
   1.182 +  * The passed in object's done method will be called upon completion.
   1.183 +  */
   1.184 +  void open(in nsIFilePickerShownCallback aFilePickerShownCallback);
   1.185 +
   1.186 + /**
   1.187 +  * The picker's mode, as set by the 'mode' argument passed to init()
   1.188 +  * (one of the modeOpen et. al. constants specified above).
   1.189 +  */
   1.190 +  readonly attribute short mode;
   1.191 +};

mercurial