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 
67 private import glib.Str;
68 private import gtk.Window;
69 private import gtk.FileChooserT;
70 private import gtk.FileChooserIF;
71 
72 
73 
74 private import gtk.Dialog;
75 
76 /**
77  * GtkFileChooserDialog is a dialog box suitable for use with
78  * "File/Open" or "File/Save as" commands. This widget works by
79  * putting a GtkFileChooserWidget inside a GtkDialog. It exposes
80  * the GtkFileChooser interface, so you can use all of the
81  * GtkFileChooser functions on the file chooser dialog as well as
82  * those for GtkDialog.
83  *
84  * Note that GtkFileChooserDialog does not have any methods of its
85  * own. Instead, you should use the functions that work on a
86  * GtkFileChooser.
87  *
88  * $(DDOC_COMMENT example)
89  *
90  * $(DDOC_COMMENT example)
91  *
92  * To use a dialog for saving, you can use this:
93  *
94  * $(DDOC_COMMENT example)
95  *
96  * Setting up a file chooser dialog
97  *
98  * There are various cases in which you may need to use a GtkFileChooserDialog:
99  *
100  * To select a file for opening, as for a
101  *  File/Open command. Use
102  *  GTK_FILE_CHOOSER_ACTION_OPEN.
103  *
104  * To save a file for the first time, as for a
105  *  File/Save command. Use
106  *  GTK_FILE_CHOOSER_ACTION_SAVE, and suggest a name such as
107  *  "Untitled" with gtk_file_chooser_set_current_name().
108  *
109  * To save a file under a different name, as for a
110  *  File/Save As command. Use
111  *  GTK_FILE_CHOOSER_ACTION_SAVE, and set the existing filename
112  *  with gtk_file_chooser_set_filename().
113  *
114  * To choose a folder instead of a file. Use
115  *  GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
116  *
117  * Note
118  *
119  * Old versions of the file chooser's documentation suggested
120  * using gtk_file_chooser_set_current_folder() in various
121  * situations, with the intention of letting the application
122  * suggest a reasonable default folder. This is no longer
123  * considered to be a good policy, as now the file chooser is
124  * able to make good suggestions on its own. In general, you
125  * should only cause the file chooser to show a specific folder
126  * when it is appropriate to use gtk_file_chooser_set_filename(),
127  * i.e. when you are doing a File/Save
128  * As command and you already
129  * have a file saved somewhere.
130  *
131  * Response Codes
132  *
133  * GtkFileChooserDialog inherits from GtkDialog, so buttons that
134  * go in its action area have response codes such as
135  * GTK_RESPONSE_ACCEPT and GTK_RESPONSE_CANCEL. For example, you
136  * could call gtk_file_chooser_dialog_new() as follows:
137  *
138  * $(DDOC_COMMENT example)
139  *
140  * This will create buttons for "Cancel" and "Open" that use stock
141  * response identifiers from GtkResponseType. For most dialog
142  * boxes you can use your own custom response codes rather than the
143  * ones in GtkResponseType, but GtkFileChooserDialog assumes that
144  * its "accept"-type action, e.g. an "Open" or "Save" button,
145  * will have one of the following response
146  * codes:
147  *
148  * GTK_RESPONSE_ACCEPT
149  * GTK_RESPONSE_OK
150  * GTK_RESPONSE_YES
151  * GTK_RESPONSE_APPLY
152  *
153  * This is because GtkFileChooserDialog must intercept responses
154  * and switch to folders if appropriate, rather than letting the
155  * dialog terminate — the implementation uses these known
156  * response codes to know which responses can be blocked if
157  * appropriate.
158  *
159  * Note
160  *
161  * To summarize, make sure you use a
162  * stock response code
163  * when you use GtkFileChooserDialog to ensure proper operation.
164  */
165 public class FileChooserDialog : Dialog, FileChooserIF
166 {
167 	
168 	/** the main Gtk struct */
169 	protected GtkFileChooserDialog* gtkFileChooserDialog;
170 	
171 	
172 	public GtkFileChooserDialog* getFileChooserDialogStruct()
173 	{
174 		return gtkFileChooserDialog;
175 	}
176 	
177 	
178 	/** the main Gtk struct as a void* */
179 	protected override void* getStruct()
180 	{
181 		return cast(void*)gtkFileChooserDialog;
182 	}
183 	
184 	/**
185 	 * Sets our main struct and passes it to the parent class
186 	 */
187 	public this (GtkFileChooserDialog* gtkFileChooserDialog)
188 	{
189 		super(cast(GtkDialog*)gtkFileChooserDialog);
190 		this.gtkFileChooserDialog = gtkFileChooserDialog;
191 	}
192 	
193 	protected override void setStruct(GObject* obj)
194 	{
195 		super.setStruct(obj);
196 		gtkFileChooserDialog = cast(GtkFileChooserDialog*)obj;
197 	}
198 	
199 	// add the FileChooser capabilities
200 	mixin FileChooserT!(GtkFileChooserDialog);
201 	
202 	/**
203 	 * Creates a new GtkFileChooserDialog. This function is analogous to
204 	 * gtk_dialog_new_with_buttons().
205 	 * Since 2.4
206 	 * Params:
207 	 *  title = Title of the dialog, or NULL
208 	 *  parent = Transient parent of the dialog, or NULL
209 	 *  action = Open or save mode for the dialog
210 	 *  buttonsText = text to go in the buttons
211 	 *  responses = response ID's for the buttons
212 	 * Throws: ConstructionException GTK+ fails to create the object.
213 	 */
214 	this(string title, Window parent, FileChooserAction action,  string[] buttonsText=null, ResponseType[] responses=null)
215 	{
216 		if ( buttonsText  is  null )
217 		{
218 			buttonsText ~= "OK";
219 			buttonsText ~= "Cancel";
220 		}
221 		if ( responses  is  null )
222 		{
223 			responses ~= ResponseType.OK;
224 			responses ~= ResponseType.CANCEL;
225 		}
226 		
227 		auto p = gtk_file_chooser_dialog_new(
228 		Str.toStringz(title),
229 		(parent is null) ? null : parent.getWindowStruct(),
230 		action,
231 		null,
232 		0);
233 		
234 		if(p is null)
235 		{
236 			throw new ConstructionException("null returned by gtk_file_chooser_dialog_new");
237 		}
238 		
239 		this(cast(GtkFileChooserDialog*) p);
240 		
241 		addButtons(buttonsText, responses);
242 	}
243 	
244 	/**
245 	 */
246 }