alternative to assert
[gtkD.git] / src / gtk / FileSelection.d
bloba799b0c1a51d96faacb38235dc4d24a7f11c5d7e
1 /*
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 = 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 * local aliases:
50 module gtk.FileSelection;
52 private import gtk.gtktypes;
54 private import lib.gtk;
56 private import glib.Str;
58 /**
59 * Description
60 * GtkFileSelection should be used to retrieve file or directory names from
61 * the user. It will create a new dialog window containing a directory list,
62 * and a file list corresponding to the current working directory. The filesystem
63 * can be navigated using the directory list or the drop-down history menu.
64 * Alternatively, the TAB key can be used to navigate using filename
65 * completion - common in text based editors such as emacs and jed.
66 * File selection dialogs are created with a call to gtk_file_selection_new().
67 * The default filename can be set using gtk_file_selection_set_filename() and the selected filename retrieved using gtk_file_selection_get_filename().
68 * Use gtk_file_selection_complete() to display files and directories
69 * that match a given pattern. This can be used for example, to show only
70 * *.txt files, or only files beginning with gtk*.
71 * 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().
72 * Example1.Getting a filename from the user.
73 * /+* The file selection widget and the string to store the chosen filename +/
74 * void store_filename (GtkWidget *widget, gpointer user_data) {
75 * GtkWidget *file_selector = GTK_WIDGET (user_data);
76 * const gchar *selected_filename;
77 * selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (file_selector));
78 * g_print ("Selected filename: %s\n", selected_filename);
79 * }
80 * void create_file_selection (void) {
81 * GtkWidget *file_selector;
82 * /+* Create the selector +/
83 * file_selector = gtk_file_selection_new ("Please select a file for editing.");
84 * g_signal_connect (GTK_FILE_SELECTION (file_selector)->ok_button,
85 * "clicked",
86 * G_CALLBACK (store_filename),
87 * file_selector);
88 * /+* Ensure that the dialog box is destroyed when the user clicks a button. +/
89 * g_signal_connect_swapped (GTK_FILE_SELECTION (file_selector)->ok_button,
90 * "clicked",
91 * G_CALLBACK (gtk_widget_destroy),
92 * file_selector);
93 * g_signal_connect_swapped (GTK_FILE_SELECTION (file_selector)->cancel_button,
94 * "clicked",
95 * G_CALLBACK (gtk_widget_destroy),
96 * file_selector);
97 * /+* Display that dialog +/
98 * gtk_widget_show (file_selector);
99 * }
101 private import gtk.Dialog;
102 public class FileSelection : Dialog
105 /** the main Gtk struct */
106 protected GtkFileSelection* gtkFileSelection;
109 public GtkFileSelection* getFileSelectionStruct()
111 return gtkFileSelection;
115 /** the main Gtk struct as a void* */
116 protected void* getStruct()
118 return cast(void*)gtkFileSelection;
122 * Sets our main struct and passes it to the parent class
124 public this (GtkFileSelection* gtkFileSelection)
126 super(cast(GtkDialog*)gtkFileSelection);
127 this.gtkFileSelection = gtkFileSelection;
135 * 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.
136 * title:
137 * a message that will be placed in the file requestor's titlebar.
138 * Returns:
139 * the new file selection.
141 public this (char[] title)
143 // GtkWidget* gtk_file_selection_new (const gchar *title);
144 this(cast(GtkFileSelection*)gtk_file_selection_new(Str.toStringz(title)) );
148 * Sets a default path for the file requestor. If filename includes a
149 * directory path, then the requestor will open with that path as its
150 * current working directory.
151 * This has the consequence that in order to open the requestor with a
152 * working directory and an empty filename, filename must have a trailing
153 * directory separator.
154 * The encoding of filename is preferred GLib file name encoding, which
155 * may not be UTF-8. See g_filename_from_utf8().
156 * filesel:
157 * a GtkFileSelection.
158 * filename:
159 * a string to set as the default file name.
161 public void setFilename(char[] filename)
163 // void gtk_file_selection_set_filename (GtkFileSelection *filesel, const gchar *filename);
164 gtk_file_selection_set_filename(gtkFileSelection, Str.toStringz(filename));
168 * This function returns the selected filename in the GLib file name
169 * encoding. To convert to UTF-8, call g_filename_to_utf8(). The
170 * returned string points to a statically allocated buffer and should
171 * be copied if you plan to keep it around.
172 * If no file is selected then the selected directory path is returned.
173 * filesel:
174 * a GtkFileSelection
175 * Returns:
176 * currently-selected filename in the on-disk encoding.
178 public char[] getFilename()
180 // const gchar* gtk_file_selection_get_filename (GtkFileSelection *filesel);
181 return Str.toString(gtk_file_selection_get_filename(gtkFileSelection) );
185 * 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.
186 * If a partial match can be made, the "Files" list will contain those
187 * file names which have been partially matched, and the "Folders"
188 * list those directories which have been partially matched.
189 * filesel:
190 * a GtkFileSelection.
191 * pattern:
192 * a string of characters which may or may not match any filenames in the current directory.
194 public void complete(char[] pattern)
196 // void gtk_file_selection_complete (GtkFileSelection *filesel, const gchar *pattern);
197 gtk_file_selection_complete(gtkFileSelection, Str.toStringz(pattern));
201 * Shows the file operation buttons, if they have previously been hidden. The rest of the widgets in the dialog will be resized accordingly.
202 * filesel:
203 * a GtkFileSelection.
205 public void showFileopButtons()
207 // void gtk_file_selection_show_fileop_buttons (GtkFileSelection *filesel);
208 gtk_file_selection_show_fileop_buttons(gtkFileSelection);
212 * 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.
213 * filesel:
214 * a GtkFileSelection.
216 public void hideFileopButtons()
218 // void gtk_file_selection_hide_fileop_buttons (GtkFileSelection *filesel);
219 gtk_file_selection_hide_fileop_buttons(gtkFileSelection);
223 * Retrieves the list of file selections the user has made in the dialog box.
224 * This function is intended for use when the user can select multiple files
225 * in the file list.
226 * The filenames are in the GLib file name encoding. To convert to
227 * UTF-8, call g_filename_to_utf8() on each string.
228 * filesel:
229 * a GtkFileSelection
230 * Returns:
231 * a newly-allocated NULL-terminated array of strings. Use
232 * g_strfreev() to free it.
234 public char** getSelections()
236 // gchar** gtk_file_selection_get_selections (GtkFileSelection *filesel);
237 return gtk_file_selection_get_selections(gtkFileSelection);
241 * Sets whether the user is allowed to select multiple files in the file list.
242 * Use gtk_file_selection_get_selections() to get the list of selected files.
243 * filesel:
244 * a GtkFileSelection
245 * select_multiple:
246 * whether or not the user is allowed to select multiple
247 * files in the file list.
249 public void setSelectMultiple(int selectMultiple)
251 // void gtk_file_selection_set_select_multiple (GtkFileSelection *filesel, gboolean select_multiple);
252 gtk_file_selection_set_select_multiple(gtkFileSelection, selectMultiple);
256 * Determines whether or not the user is allowed to select multiple files in
257 * the file list. See gtk_file_selection_set_select_multiple().
258 * filesel:
259 * a GtkFileSelection
260 * Returns:
261 * TRUE if the user is allowed to select multiple files in the
262 * file list
263 * Property Details
264 * The "filename" property
265 * "filename" gchararray : Read / Write
266 * The currently selected filename.
267 * Default value: NULL
269 public int getSelectMultiple()
271 // gboolean gtk_file_selection_get_select_multiple (GtkFileSelection *filesel);
272 return gtk_file_selection_get_select_multiple(gtkFileSelection);