alternative to assert
[gtkD.git] / gtkD / src / gtk / FileSelection.d
blob3d80030a805379e493e2df29f7268926b8bd674d
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 = GtkFileSelection.html
26 * outPack = gtk
27 * outFile = FileSelection
28 * strct = GtkFileSelection
29 * realStrct=
30 * ctorStrct=
31 * clss = FileSelection
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_file_selection_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * structWrap:
47 * module aliases:
48 * local aliases:
51 module gtk.FileSelection;
53 version(noAssert)
55 version(Tango)
57 import tango.io.Stdout; // use the tango loging?
61 private import gtkc.gtktypes;
63 private import gtkc.gtk;
66 private import glib.Str;
71 /**
72 * Description
73 * GtkFileSelection has been superseded by the newer GtkFileChooser family
74 * of widgets.
75 * GtkFileSelection should be used to retrieve file or directory names from
76 * the user. It will create a new dialog window containing a directory list,
77 * and a file list corresponding to the current working directory. The filesystem
78 * can be navigated using the directory list or the drop-down history menu.
79 * Alternatively, the TAB key can be used to navigate using filename
80 * completion - common in text based editors such as emacs and jed.
81 * File selection dialogs are created with a call to gtk_file_selection_new().
82 * The default filename can be set using gtk_file_selection_set_filename() and the selected filename retrieved using gtk_file_selection_get_filename().
83 * Use gtk_file_selection_complete() to display files and directories
84 * that match a given pattern. This can be used for example, to show only
85 * *.txt files, or only files beginning with gtk*.
86 * Simple file operations; create directory, delete file, and rename file, are available from buttons at the top of the dialog. These can be hidden using gtk_file_selection_hide_fileop_buttons() and shown again using gtk_file_selection_show_fileop_buttons().
87 * Example1.Getting a filename from the user.
88 * /+* The file selection widget and the string to store the chosen filename +/
89 * void store_filename (GtkWidget *widget, gpointer user_data) {
90 * GtkWidget *file_selector = GTK_WIDGET (user_data);
91 * const gchar *selected_filename;
92 * selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selector));
93 * g_print ("Selected filename: %s\n", selected_filename);
94 * }
95 * void create_file_selection (void) {
96 * GtkWidget *file_selector;
97 * /+* Create the selector +/
98 * file_selector = gtk_file_selection_new ("Please select a file for editing.");
99 * g_signal_connect (GTK_FILE_SELECTION (file_selector)->ok_button,
100 * "clicked",
101 * G_CALLBACK (store_filename),
102 * file_selector);
103 * /+* Ensure that the dialog box is destroyed when the user clicks a button. +/
104 * g_signal_connect_swapped (GTK_FILE_SELECTION (file_selector)->ok_button,
105 * "clicked",
106 * G_CALLBACK (gtk_widget_destroy),
107 * file_selector);
108 * g_signal_connect_swapped (GTK_FILE_SELECTION (file_selector)->cancel_button,
109 * "clicked",
110 * G_CALLBACK (gtk_widget_destroy),
111 * file_selector);
112 * /+* Display that dialog +/
113 * gtk_widget_show (file_selector);
116 private import gtk.Dialog;
117 public class FileSelection : Dialog
120 /** the main Gtk struct */
121 protected GtkFileSelection* gtkFileSelection;
124 public GtkFileSelection* getFileSelectionStruct()
126 return gtkFileSelection;
130 /** the main Gtk struct as a void* */
131 protected void* getStruct()
133 return cast(void*)gtkFileSelection;
137 * Sets our main struct and passes it to the parent class
139 public this (GtkFileSelection* gtkFileSelection)
141 version(noAssert)
143 if ( gtkFileSelection is null )
145 int zero = 0;
146 version(Tango)
148 Stdout("struct gtkFileSelection is null on constructor").newline;
150 else
152 printf("struct gtkFileSelection is null on constructor");
154 zero = zero / zero;
157 else
159 assert(gtkFileSelection !is null, "struct gtkFileSelection is null on constructor");
161 super(cast(GtkDialog*)gtkFileSelection);
162 this.gtkFileSelection = gtkFileSelection;
170 * Warning
171 * gtk_file_selection_new is deprecated and should not be used in newly-written code. Use gtk_file_chooser_dialog_new() instead
172 * Creates a new file selection dialog box. By default it will contain a GtkTreeView of the application's current working directory, and a file listing. Operation buttons that allow the user to create a directory, delete files and rename files, are also present.
173 * title:
174 * a message that will be placed in the file requestor's titlebar.
175 * Returns:
176 * the new file selection.
178 public this (char[] title)
180 // GtkWidget* gtk_file_selection_new (const gchar *title);
181 this(cast(GtkFileSelection*)gtk_file_selection_new(Str.toStringz(title)) );
185 * Warning
186 * gtk_file_selection_set_filename is deprecated and should not be used in newly-written code.
187 * Sets a default path for the file requestor. If filename includes a
188 * directory path, then the requestor will open with that path as its
189 * current working directory.
190 * This has the consequence that in order to open the requestor with a
191 * working directory and an empty filename, filename must have a trailing
192 * directory separator.
193 * The encoding of filename is preferred GLib file name encoding, which
194 * may not be UTF-8. See g_filename_from_utf8().
195 * filesel:
196 * a GtkFileSelection.
197 * filename:
198 * a string to set as the default file name.
200 public void setFilename(char[] filename)
202 // void gtk_file_selection_set_filename (GtkFileSelection *filesel, const gchar *filename);
203 gtk_file_selection_set_filename(gtkFileSelection, Str.toStringz(filename));
207 * Warning
208 * gtk_file_selection_get_filename is deprecated and should not be used in newly-written code.
209 * This function returns the selected filename in the GLib file name
210 * encoding. To convert to UTF-8, call g_filename_to_utf8(). The
211 * returned string points to a statically allocated buffer and should
212 * be copied if you plan to keep it around.
213 * If no file is selected then the selected directory path is returned.
214 * filesel:
215 * a GtkFileSelection
216 * Returns:
217 * currently-selected filename in the on-disk encoding.
219 public char[] getFilename()
221 // const gchar* gtk_file_selection_get_filename (GtkFileSelection *filesel);
222 return Str.toString(gtk_file_selection_get_filename(gtkFileSelection) );
226 * Warning
227 * gtk_file_selection_complete is deprecated and should not be used in newly-written code.
228 * Will attempt to match pattern to a valid filenames or subdirectories in the current directory. If a match can be made, the matched filename will appear in the text entry field of the file selection dialog.
229 * If a partial match can be made, the "Files" list will contain those
230 * file names which have been partially matched, and the "Folders"
231 * list those directories which have been partially matched.
232 * filesel:
233 * a GtkFileSelection.
234 * pattern:
235 * a string of characters which may or may not match any filenames in the current directory.
237 public void complete(char[] pattern)
239 // void gtk_file_selection_complete (GtkFileSelection *filesel, const gchar *pattern);
240 gtk_file_selection_complete(gtkFileSelection, Str.toStringz(pattern));
244 * Warning
245 * gtk_file_selection_show_fileop_buttons is deprecated and should not be used in newly-written code.
246 * Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
247 * filesel:
248 * a GtkFileSelection.
250 public void showFileopButtons()
252 // void gtk_file_selection_show_fileop_buttons (GtkFileSelection *filesel);
253 gtk_file_selection_show_fileop_buttons(gtkFileSelection);
257 * Warning
258 * gtk_file_selection_hide_fileop_buttons is deprecated and should not be used in newly-written code.
259 * Hides the file operation buttons that normally appear at the top of the dialog. Useful if you wish to create a custom file selector, based on GtkFileSelection.
260 * filesel:
261 * a GtkFileSelection.
263 public void hideFileopButtons()
265 // void gtk_file_selection_hide_fileop_buttons (GtkFileSelection *filesel);
266 gtk_file_selection_hide_fileop_buttons(gtkFileSelection);
270 * Warning
271 * gtk_file_selection_get_selections is deprecated and should not be used in newly-written code.
272 * Retrieves the list of file selections the user has made in the dialog box.
273 * This function is intended for use when the user can select multiple files
274 * in the file list.
275 * The filenames are in the GLib file name encoding. To convert to
276 * UTF-8, call g_filename_to_utf8() on each string.
277 * filesel:
278 * a GtkFileSelection
279 * Returns:
280 * a newly-allocated NULL-terminated array of strings. Use
281 * g_strfreev() to free it.
283 public char** getSelections()
285 // gchar** gtk_file_selection_get_selections (GtkFileSelection *filesel);
286 return gtk_file_selection_get_selections(gtkFileSelection);
290 * Warning
291 * gtk_file_selection_set_select_multiple is deprecated and should not be used in newly-written code.
292 * Sets whether the user is allowed to select multiple files in the file list.
293 * Use gtk_file_selection_get_selections() to get the list of selected files.
294 * filesel:
295 * a GtkFileSelection
296 * select_multiple:
297 * whether or not the user is allowed to select multiple
298 * files in the file list.
300 public void setSelectMultiple(int selectMultiple)
302 // void gtk_file_selection_set_select_multiple (GtkFileSelection *filesel, gboolean select_multiple);
303 gtk_file_selection_set_select_multiple(gtkFileSelection, selectMultiple);
307 * Warning
308 * gtk_file_selection_get_select_multiple is deprecated and should not be used in newly-written code.
309 * Determines whether or not the user is allowed to select multiple files in
310 * the file list. See gtk_file_selection_set_select_multiple().
311 * filesel:
312 * a GtkFileSelection
313 * Returns:
314 * TRUE if the user is allowed to select multiple files in the
315 * file list
316 * Property Details
317 * The "filename" property
318 * "filename" gchararray : Read / Write
319 * The currently selected filename.
320 * Default value: NULL
322 public int getSelectMultiple()
324 // gboolean gtk_file_selection_get_select_multiple (GtkFileSelection *filesel);
325 return gtk_file_selection_get_select_multiple(gtkFileSelection);