2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkFileChooserDialog.html
27 * outFile = FileChooserDialog
28 * strct = GtkFileChooserDialog
31 * clss = FileChooserDialog
39 * - gtk_file_chooser_dialog_
44 * - gtk_file_chooser_dialog_new
45 * - gtk_file_chooser_dialog_new_with_backend
55 * - GtkWindow* -> Window
59 module gtk
.FileChooserDialog
;
61 private import gtk
.gtktypes
;
63 private import lib
.gtk
;
65 private import glib
.Str
;
66 private import gtk
.Window
;
67 private import glib
.ListSG
;;
68 private import gtk
.Widget
;;
69 private import gtk
.FileFilter
;;
70 private import gtk
.FileChooser
;;
71 private import glib
.Str
;
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 GtkFileChooserIface interface, so you can use all of the
79 * GtkFileChooser functions on the file chooser dialog as well as
80 * those for GtkDialog.
81 * Note that GtkFileChooserDialog does not have any methods of its
82 * own. Instead, you should use the functions that work on a
84 * Example7.Typical usage
85 * In the simplest of cases, you can the following code to use
86 * GtkFileChooserDialog to select a file for opening:
88 * dialog = gtk_file_chooser_dialog_new ("Open File",
90 * GTK_FILE_CHOOSER_ACTION_OPEN,
91 * GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
92 * GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
94 * if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
97 * filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
98 * open_file (filename);
101 * gtk_widget_destroy (dialog);
102 * To use a dialog for saving, you can use this:
104 * dialog = gtk_file_chooser_dialog_new ("Save File",
106 * GTK_FILE_CHOOSER_ACTION_SAVE,
107 * GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
108 * GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
110 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
111 * if (user_edited_a_new_document)
113 * gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), default_folder_for_saving);
114 * gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "Untitled document");
117 * gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filename_for_existing_document);
118 * if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
121 * filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
122 * save_to_file (filename);
125 * gtk_widget_destroy (dialog);
127 * GtkFileChooserDialog inherits from GtkDialog, so buttons that
128 * go in its action area have response codes such as
129 * GTK_RESPONSE_ACCEPT and GTK_RESPONSE_CANCEL. For example, you
130 * could call gtk_file_chooser_dialog_new() as follows:
132 * dialog = gtk_file_chooser_dialog_new ("Open File",
134 * GTK_FILE_CHOOSER_ACTION_OPEN,
135 * GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
136 * GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
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
145 * GTK_RESPONSE_ACCEPT
149 * This is because GtkFileChooserDialog must intercept responses
150 * and switch to folders if appropriate, rather than letting the
151 * dialog terminate the implementation uses these known
152 * response codes to know which responses can be blocked if
155 * To summarize, make sure you use a stock response
156 * code when you use GtkFileChooserDialog to ensure
159 private import gtk
.Dialog
;
160 public class FileChooserDialog
: Dialog
163 /** the main Gtk struct */
164 protected GtkFileChooserDialog
* gtkFileChooserDialog
;
167 public GtkFileChooserDialog
* getFileChooserDialogStruct()
169 return gtkFileChooserDialog
;
173 /** the main Gtk struct as a void* */
174 protected void* getStruct()
176 return cast(void*)gtkFileChooserDialog
;
180 * Sets our main struct and passes it to the parent class
182 public this (GtkFileChooserDialog
* gtkFileChooserDialog
)
184 super(cast(GtkDialog
*)gtkFileChooserDialog
);
185 this.gtkFileChooserDialog
= gtkFileChooserDialog
;
188 private FileChooser fileChooser
;
190 public FileChooser
getFileChooser()
192 if ( fileChooser
is null )
194 fileChooser
= new FileChooser(cast(GtkFileChooser
*)getFileChooserDialogStruct());
200 * Creates a new GtkFileChooserDialog. This function is analogous to
201 * gtk_dialog_new_with_buttons().
203 * Title of the dialog, or NULL
205 * Transient parent of the dialog, or NULL
207 * Open or save mode for the dialog
209 * stock ID or text to go in the first button, or NULL
211 * response ID for the first button, then additional (button, id) pairs, ending with NULL
213 * a new GtkFileChooserDialog
216 this(char[] title
, Window parent
, FileChooserAction action
, char[][] buttonsText
=null, ResponseType
[] responses
=null)
218 if ( buttonsText
is null )
221 buttonsText
~= "Cancel";
223 if ( responses
is null )
225 responses
~= ResponseType
.GTK_RESPONSE_OK
;
226 responses
~= ResponseType
.GTK_RESPONSE_CANCEL
;
230 cast(GtkFileChooserDialog
*)gtk_file_chooser_dialog_new(
231 Str
.toStringz(title
),
232 parent
.getWindowStruct(),
236 addButtons(buttonsText
, responses
);
240 * Creates a new GtkFileChooserDialog with a specified backend. This is
241 * especially useful if you use gtk_file_chooser_set_local_only() to allow
242 * non-local files and you use a more expressive vfs, such as gnome-vfs,
245 * Title of the dialog, or NULL
247 * Transient parent of the dialog, or NULL
249 * Open or save mode for the dialog
251 * The name of the specific filesystem backend to use.
253 * stock ID or text to go in the first button, or NULL
255 * response ID for the first button, then additional (button, id) pairs, ending with NULL
257 * a new GtkFileChooserDialog
260 * GtkFileChooser, GtkDialog
262 public this (char[] title
, Window parent
, GtkFileChooserAction action
, char[] backend
, char[][] buttonsText
=null, ResponseType
[] responses
=null)
264 // GtkWidget* gtk_file_chooser_dialog_new_with_backend (const gchar *title, GtkWindow *parent, GtkFileChooserAction action, const gchar *backend, const gchar *first_button_text, ...);
266 cast(GtkFileChooserDialog
*)gtk_file_chooser_dialog_new_with_backend(
267 Str
.toStringz(title
),
268 parent
.getWindowStruct(),
270 Str
.toStringz(backend
),
274 if ( buttonsText
is null )
277 buttonsText
~= "Cancel";
279 if ( responses
is null )
281 responses
~= ResponseType
.GTK_RESPONSE_OK
;
282 responses
~= ResponseType
.GTK_RESPONSE_CANCEL
;
285 addButtons(buttonsText
, responses
);
288 // this(char[] title, Window parent, FileChooserAction action, StockID[] buttons=null, ResponseType[] responses=null)
290 // if ( buttons is null )
292 // buttons ~= STOCK_OK;
293 // buttons ~= STOCK_CANCEL;
295 // if ( responses is null )
297 // responses ~= ResponseType.GTK_RESPONSE_OK;
298 // responses ~= ResponseType.GTK_RESPONSE_CANCEL;
301 // this(gtk_file_chooser_dialog_new(
302 // title.toStringz(),
303 // parent.getWindowStruct(),
307 // addButtons(buttons, responses);