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 * - gtk_ 43 * omit structs: 44 * omit prefixes: 45 * omit code: 46 * - gtk_file_chooser_dialog_new 47 * - gtk_file_chooser_dialog_new_with_backend 48 * omit signals: 49 * imports: 50 * - glib.Str 51 * - gtk.Window 52 * - gtk.FileChooserT 53 * - gtk.FileChooserIF 54 * structWrap: 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.FileChooserDialog; 61 62 public import gtkc.gtktypes; 63 64 private import gtkc.gtk; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 69 private import glib.Str; 70 private import gtk.Window; 71 private import gtk.FileChooserT; 72 private import gtk.FileChooserIF; 73 74 75 76 private import gtk.Dialog; 77 78 /** 79 * Description 80 * GtkFileChooserDialog is a dialog box suitable for use with 81 * "File/Open" or "File/Save as" commands. This widget works by 82 * putting a GtkFileChooserWidget inside a GtkDialog. It exposes 83 * the GtkFileChooserIface interface, so you can use all of the 84 * GtkFileChooser functions on the file chooser dialog as well as 85 * those for GtkDialog. 86 * Note that GtkFileChooserDialog does not have any methods of its 87 * own. Instead, you should use the functions that work on a 88 * GtkFileChooser. 89 * $(DDOC_COMMENT example) 90 * Response Codes 91 * GtkFileChooserDialog inherits from GtkDialog, so buttons that 92 * go in its action area have response codes such as 93 * GTK_RESPONSE_ACCEPT and GTK_RESPONSE_CANCEL. For example, you 94 * could call gtk_file_chooser_dialog_new() as follows: 95 * GtkWidget *dialog; 96 * dialog = gtk_file_chooser_dialog_new ("Open File", 97 * parent_window, 98 * GTK_FILE_CHOOSER_ACTION_OPEN, 99 * GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 100 * GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 101 * NULL); 102 * This will create buttons for "Cancel" and "Open" that use stock 103 * response identifiers from GtkResponseType. For most dialog 104 * boxes you can use your own custom response codes rather than the 105 * ones in GtkResponseType, but GtkFileChooserDialog assumes that 106 * its "accept"-type action, e.g. an "Open" or "Save" button, 107 * will have one of the following response 108 * codes: 109 * GTK_RESPONSE_ACCEPT 110 * GTK_RESPONSE_OK 111 * GTK_RESPONSE_YES 112 * GTK_RESPONSE_APPLY 113 * This is because GtkFileChooserDialog must intercept responses 114 * and switch to folders if appropriate, rather than letting the 115 * dialog terminate — the implementation uses these known 116 * response codes to know which responses can be blocked if 117 * appropriate. 118 * Note 119 * To summarize, make sure you use a stock response 120 * code when you use GtkFileChooserDialog to ensure 121 * proper operation. 122 */ 123 public class FileChooserDialog : Dialog, FileChooserIF 124 { 125 126 /** the main Gtk struct */ 127 protected GtkFileChooserDialog* gtkFileChooserDialog; 128 129 130 public GtkFileChooserDialog* getFileChooserDialogStruct() 131 { 132 return gtkFileChooserDialog; 133 } 134 135 136 /** the main Gtk struct as a void* */ 137 protected override void* getStruct() 138 { 139 return cast(void*)gtkFileChooserDialog; 140 } 141 142 /** 143 * Sets our main struct and passes it to the parent class 144 */ 145 public this (GtkFileChooserDialog* gtkFileChooserDialog) 146 { 147 super(cast(GtkDialog*)gtkFileChooserDialog); 148 this.gtkFileChooserDialog = gtkFileChooserDialog; 149 } 150 151 protected override void setStruct(GObject* obj) 152 { 153 super.setStruct(obj); 154 gtkFileChooserDialog = cast(GtkFileChooserDialog*)obj; 155 } 156 157 // add the FileChooser capabilities 158 mixin FileChooserT!(GtkFileChooserDialog); 159 160 /** 161 * Creates a new GtkFileChooserDialog. This function is analogous to 162 * gtk_dialog_new_with_buttons(). 163 * Since 2.4 164 * Params: 165 * title = Title of the dialog, or NULL 166 * parent = Transient parent of the dialog, or NULL 167 * action = Open or save mode for the dialog 168 * buttonsText = text to go in the buttons 169 * responses = response ID's for the buttons 170 * Throws: ConstructionException GTK+ fails to create the object. 171 */ 172 this(string title, Window parent, FileChooserAction action, string[] buttonsText=null, ResponseType[] responses=null) 173 { 174 if ( buttonsText is null ) 175 { 176 buttonsText ~= "OK"; 177 buttonsText ~= "Cancel"; 178 } 179 if ( responses is null ) 180 { 181 responses ~= ResponseType.OK; 182 responses ~= ResponseType.CANCEL; 183 } 184 185 auto p = gtk_file_chooser_dialog_new( 186 Str.toStringz(title), 187 parent.getWindowStruct(), 188 action, 189 null, 190 0); 191 192 if(p is null) 193 { 194 throw new ConstructionException("null returned by gtk_file_chooser_dialog_new"); 195 } 196 197 this(cast(GtkFileChooserDialog*) p); 198 199 addButtons(buttonsText, responses); 200 } 201 202 /** 203 * Creates a new GtkFileChooserDialog with a specified backend. This is 204 * especially useful if you use gtk_file_chooser_set_local_only() to allow 205 * non-local files and you use a more expressive vfs, such as gnome-vfs, 206 * to load files. 207 * Since 2.4 208 * Params: 209 * title = Title of the dialog, or NULL 210 * parent = Transient parent of the dialog, or NULL 211 * action = Open or save mode for the dialog 212 * backend = The name of the specific filesystem backend to use. 213 * buttonsText = text to go in the buttons 214 * responses = response ID's for the buttons 215 * See_Also: 216 * GtkFileChooser, GtkDialog 217 * Throws: ConstructionException GTK+ fails to create the object. 218 */ 219 public this (string title, Window parent, GtkFileChooserAction action, string backend, string[] buttonsText=null, ResponseType[] responses=null) 220 { 221 // GtkWidget* gtk_file_chooser_dialog_new_with_backend (const gchar *title, GtkWindow *parent, GtkFileChooserAction action, const gchar *backend, const gchar *first_button_text, ...); 222 auto p = gtk_file_chooser_dialog_new_with_backend( 223 Str.toStringz(title), 224 parent.getWindowStruct(), 225 action, 226 Str.toStringz(backend), 227 null, 228 0 229 ); 230 231 if(p is null) 232 { 233 throw new ConstructionException("null returned by gtk_file_chooser_dialog_new_with_backend"); 234 } 235 236 this(cast(GtkFileChooserDialog*) p); 237 238 if ( buttonsText is null ) 239 { 240 buttonsText ~= "OK"; 241 buttonsText ~= "Cancel"; 242 } 243 if ( responses is null ) 244 { 245 responses ~= ResponseType.OK; 246 responses ~= ResponseType.CANCEL; 247 } 248 249 addButtons(buttonsText, responses); 250 } 251 252 /** 253 */ 254 }