1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GtkFileChooserDialog.html 27 * outPack = gtk 28 * outFile = FileChooserDialog 29 * strct = GtkFileChooserDialog 30 * realStrct= 31 * ctorStrct= 32 * clss = FileChooserDialog 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - FileChooserIF 40 * prefixes: 41 * - gtk_file_chooser_dialog_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * - gtk_file_chooser_dialog_new 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - gtk.Window 50 * - gtk.FileChooserT 51 * - gtk.FileChooserIF 52 * structWrap: 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gtk.FileChooserDialog; 59 60 public import gtkc.gtktypes; 61 62 private import gtkc.gtk; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 private import glib.Str; 67 private import gtk.Window; 68 private import gtk.FileChooserT; 69 private import gtk.FileChooserIF; 70 71 72 private import gtk.Dialog; 73 74 /** 75 * GtkFileChooserDialog is a dialog box suitable for use with 76 * "File/Open" or "File/Save as" commands. This widget works by 77 * putting a GtkFileChooserWidget inside a GtkDialog. It exposes 78 * the GtkFileChooser interface, so you can use all of the 79 * GtkFileChooser functions on the file chooser dialog as well as 80 * those for GtkDialog. 81 * 82 * Note that GtkFileChooserDialog does not have any methods of its 83 * own. Instead, you should use the functions that work on a 84 * GtkFileChooser. 85 * 86 * $(DDOC_COMMENT example) 87 * 88 * $(DDOC_COMMENT example) 89 * 90 * To use a dialog for saving, you can use this: 91 * 92 * $(DDOC_COMMENT example) 93 * 94 * Setting up a file chooser dialog 95 * 96 * There are various cases in which you may need to use a GtkFileChooserDialog: 97 * 98 * To select a file for opening, as for a 99 * File/Open command. Use 100 * GTK_FILE_CHOOSER_ACTION_OPEN. 101 * 102 * To save a file for the first time, as for a 103 * File/Save command. Use 104 * GTK_FILE_CHOOSER_ACTION_SAVE, and suggest a name such as 105 * "Untitled" with gtk_file_chooser_set_current_name(). 106 * 107 * To save a file under a different name, as for a 108 * File/Save As command. Use 109 * GTK_FILE_CHOOSER_ACTION_SAVE, and set the existing filename 110 * with gtk_file_chooser_set_filename(). 111 * 112 * To choose a folder instead of a file. Use 113 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER. 114 * 115 * Note 116 * 117 * Old versions of the file chooser's documentation suggested 118 * using gtk_file_chooser_set_current_folder() in various 119 * situations, with the intention of letting the application 120 * suggest a reasonable default folder. This is no longer 121 * considered to be a good policy, as now the file chooser is 122 * able to make good suggestions on its own. In general, you 123 * should only cause the file chooser to show a specific folder 124 * when it is appropriate to use gtk_file_chooser_set_filename(), 125 * i.e. when you are doing a File/Save 126 * As command and you already 127 * have a file saved somewhere. 128 * 129 * Response Codes 130 * 131 * GtkFileChooserDialog inherits from GtkDialog, so buttons that 132 * go in its action area have response codes such as 133 * GTK_RESPONSE_ACCEPT and GTK_RESPONSE_CANCEL. For example, you 134 * could call gtk_file_chooser_dialog_new() as follows: 135 * 136 * $(DDOC_COMMENT example) 137 * 138 * This will create buttons for "Cancel" and "Open" that use stock 139 * response identifiers from GtkResponseType. For most dialog 140 * boxes you can use your own custom response codes rather than the 141 * ones in GtkResponseType, but GtkFileChooserDialog assumes that 142 * its "accept"-type action, e.g. an "Open" or "Save" button, 143 * will have one of the following response 144 * codes: 145 * 146 * GTK_RESPONSE_ACCEPT 147 * GTK_RESPONSE_OK 148 * GTK_RESPONSE_YES 149 * GTK_RESPONSE_APPLY 150 * 151 * This is because GtkFileChooserDialog must intercept responses 152 * and switch to folders if appropriate, rather than letting the 153 * dialog terminate — the implementation uses these known 154 * response codes to know which responses can be blocked if 155 * appropriate. 156 * 157 * Note 158 * 159 * To summarize, make sure you use a 160 * stock response code 161 * when you use GtkFileChooserDialog to ensure proper operation. 162 */ 163 public class FileChooserDialog : Dialog, FileChooserIF 164 { 165 166 /** the main Gtk struct */ 167 protected GtkFileChooserDialog* gtkFileChooserDialog; 168 169 170 /** Get the main Gtk struct */ 171 public GtkFileChooserDialog* getFileChooserDialogStruct() 172 { 173 return gtkFileChooserDialog; 174 } 175 176 177 /** the main Gtk struct as a void* */ 178 protected override void* getStruct() 179 { 180 return cast(void*)gtkFileChooserDialog; 181 } 182 183 /** 184 * Sets our main struct and passes it to the parent class 185 */ 186 public this (GtkFileChooserDialog* gtkFileChooserDialog) 187 { 188 super(cast(GtkDialog*)gtkFileChooserDialog); 189 this.gtkFileChooserDialog = gtkFileChooserDialog; 190 } 191 192 protected override void setStruct(GObject* obj) 193 { 194 super.setStruct(obj); 195 gtkFileChooserDialog = cast(GtkFileChooserDialog*)obj; 196 } 197 198 // add the FileChooser capabilities 199 mixin FileChooserT!(GtkFileChooserDialog); 200 201 /** 202 * Creates a new GtkFileChooserDialog. This function is analogous to 203 * gtk_dialog_new_with_buttons(). 204 * Since 2.4 205 * Params: 206 * title = Title of the dialog, or NULL 207 * parent = Transient parent of the dialog, or NULL 208 * action = Open or save mode for the dialog 209 * buttonsText = text to go in the buttons 210 * responses = response ID's for the buttons 211 * Throws: ConstructionException GTK+ fails to create the object. 212 */ 213 this(string title, Window parent, FileChooserAction action, string[] buttonsText=null, ResponseType[] responses=null) 214 { 215 if ( buttonsText is null ) 216 { 217 buttonsText ~= "OK"; 218 buttonsText ~= "Cancel"; 219 } 220 if ( responses is null ) 221 { 222 responses ~= ResponseType.OK; 223 responses ~= ResponseType.CANCEL; 224 } 225 226 auto p = gtk_file_chooser_dialog_new( 227 Str.toStringz(title), 228 (parent is null) ? null : parent.getWindowStruct(), 229 action, 230 null, 231 0); 232 233 if(p is null) 234 { 235 throw new ConstructionException("null returned by gtk_file_chooser_dialog_new"); 236 } 237 238 this(cast(GtkFileChooserDialog*) p); 239 240 addButtons(buttonsText, responses); 241 } 242 243 /** 244 */ 245 }