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 = GtkFileChooser.html
27 * outFile = FileChooser
28 * strct = GtkFileChooser
52 * - GtkFileFilter* -> FileFilter
53 * - GtkWidget* -> Widget
54 * - GtkWindow* -> Window
59 module gtk
.FileChooser
;
65 import tango
.io
.Stdout
; // use the tango loging?
69 private import gtkc
.gtktypes
;
71 private import gtkc
.gtk
;
74 private import glib
.Str
;
75 private import gtk
.Window
;
76 private import glib
.ListSG
;
77 private import gtk
.Widget
;
78 private import gtk
.FileFilter
;
85 * GtkFileChooser is an interface that can be implemented by file
86 * selection widgets. In GTK+, the main objects that implement this
87 * interface are GtkFileChooserWidget, GtkFileChooserDialog, and
88 * GtkFileChooserButton. You do not need to write an object that
89 * implements the GtkFileChooser interface unless you are trying to
90 * adapt an existing file selector to expose a standard programming
92 * GtkFileChooser allows for shortcuts to various places in the filesystem.
93 * In the default implementation these are displayed in the left pane. It
94 * may be a bit confusing at first taht these shortcuts come from various
95 * sources and in various flavours, so lets explain the terminology here:
97 * are created by the user, by dragging folders from the
98 * right pane to the left pane, or by using the "Add". Bookmarks
99 * can be renamed and deleted by the user.
101 * can be provided by the application or by the underlying filesystem
102 * abstraction (e.g. both the gnome-vfs and the Windows filesystems
103 * provide "Desktop" shortcuts). Shortcuts cannot be modified by the
106 * are provided by the underlying filesystem abstraction. They are
107 * the "roots" of the filesystem.
108 * File Names and Encodings
109 * When the user is finished selecting files in a
110 * GtkFileChooser, your program can get the selected names
111 * either as filenames or as URIs. For URIs, the normal escaping
112 * rules are applied if the URI contains non-ASCII characters.
113 * However, filenames are always returned in
114 * the character set specified by the
115 * G_FILENAME_ENCODING environment variable.
116 * Please see the Glib documentation for more details about this
119 * This means that while you can pass the result of
120 * gtk_file_chooser_get_filename() to
122 * fopen(3), you may not be able to
123 * directly set it as the text of a GtkLabel widget unless you
124 * convert it first to UTF-8, which all GTK+ widgets expect.
125 * You should use g_filename_to_utf8() to convert filenames
126 * into strings that can be passed to GTK+ widgets.
128 * Adding a Preview Widget
129 * You can add a custom preview widget to a file chooser and then
130 * get notification about when the preview needs to be updated.
131 * To install a preview widget, use
132 * gtk_file_chooser_set_preview_widget(). Then, connect to the
133 * GtkFileChooser::update-preview signal to get notified when
134 * you need to update the contents of the preview.
135 * Your callback should use
136 * gtk_file_chooser_get_preview_filename() to see what needs
137 * previewing. Once you have generated the preview for the
138 * corresponding file, you must call
139 * gtk_file_chooser_set_preview_widget_active() with a boolean
140 * flag that indicates whether your callback could successfully
141 * generate a preview.
142 * Example2.Sample Usage
146 * preview = gtk_image_new ();
147 * gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
148 * g_signal_connect (my_file_chooser, "update-preview",
149 * G_CALLBACK (update_preview_cb), preview);
152 * update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
154 * GtkWidget *preview;
157 * gboolean have_preview;
158 * preview = GTK_WIDGET (data);
159 * filename = gtk_file_chooser_get_preview_filename (file_chooser);
160 * pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
161 * have_preview = (pixbuf != NULL);
163 * gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
165 * gobject_unref (pixbuf);
166 * gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
169 * Adding Extra Widgets
170 * You can add extra widgets to a file chooser to provide options
171 * that are not present in the default design. For example, you
172 * can add a toggle button to give the user the option to open a
173 * file in read-only mode. You can use
174 * gtk_file_chooser_set_extra_widget() to insert additional
175 * widgets in a file chooser.
176 * Example3.Sample Usage
180 * toggle = gtk_check_button_new_with_label ("Open file read-only");
181 * gtk_widget_show (toggle);
182 * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
185 * If you want to set more than one extra widget in the file
186 * chooser, you can a container such as a GtkVBox or a GtkTable
187 * and include your widgets in it. Then, set the container as
188 * the whole extra widget.
191 * Internally, GTK+ implements a file chooser's graphical user
192 * interface with the private
193 * GtkFileChooserDefaultClass. This
194 * widget has several key
195 * bindings and their associated signals. This section
196 * describes the available key binding signals.
197 * Example4.GtkFileChooser key binding example
198 * The default keys that activate the key-binding signals in
199 * GtkFileChooserDefaultClass are as
202 * Default key combinations
204 * Control-L (empty path);
205 * / (path of "/")[a];
218 * Alt-1 through Alt-0
220 * Both the individual / key and the
221 * numeric keypad's "divide" key are supported.
223 * Both the individual Up key and the numeric
224 * keypad's Up key are supported.
225 * You can change these defaults to something else. For
226 * example, to add a Shift modifier to a few
227 * of the default bindings, you can include the following
228 * fragment in your .gtkrc-2.0 file:
229 * binding "my-own-gtkfilechooser-bindings" {
230 * bind "<Alt><Shift>Up" {
233 * bind "<Alt><Shift>Down" {
236 * bind "<Alt><Shift>Home" {
240 * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings"
241 * The "GtkFileChooserDefault::location-popup" signal
242 * void user_function (GtkFileChooserDefault *chooser,
244 * gpointer user_data);
245 * This is used to make the file chooser show a "Location"
246 * dialog which the user can use to manually type the name of
247 * the file he wishes to select. The
248 * path argument is a string that gets
249 * put in the text entry for the file name. By default this is bound to
251 * with a path string of "" (the empty
252 * string). It is also bound to / with a
254 * (a slash): this lets you type / and
255 * immediately type a path name. On Unix systems, this is bound to
256 * ~ (tilde) with a path string
257 * of "~" itself for access to home directories.
259 * the object which received the signal.
261 * default contents for the text entry for the file name
263 * user data set when the signal handler was connected.
265 * You can create your own bindings for the
266 * location-popup signal with custom
267 * path strings, and have a crude form
268 * of easily-to-type bookmarks. For example, say you access
269 * the path /home/username/misc very
270 * frequently. You could then create an Alt-M
271 * shortcut by including the following in your
273 * binding "misc-shortcut" {
275 * "location-popup" ("/home/username/misc")
278 * class "GtkFileChooserDefault" binding "misc-shortcut"
279 * The "GtkFileChooserDefault::up-folder" signal
280 * void user_function (GtkFileChooserDefault *chooser,
281 * gpointer user_data);
282 * This is used to make the file chooser go to the parent of
283 * the current folder in the file hierarchy. By default this
284 * is bound to Backspace and
286 * (the Up key in the numeric keypad also works).
288 * the object which received the signal.
290 * user data set when the signal handler was connected.
291 * The "GtkFileChooserDefault::down-folder" signal
292 * void user_function (GtkFileChooserDefault *chooser,
293 * gpointer user_data);
294 * This is used to make the file chooser go to a child of the
295 * current folder in the file hierarchy. The subfolder that
296 * will be used is displayed in the path bar widget of the file
297 * chooser. For example, if the path bar is showing
298 * "/foo/bar/baz", then this will cause
299 * the file chooser to switch to the "baz" subfolder. By
300 * default this is bound to
302 * (the Down key in the numeric keypad also works).
304 * the object which received the signal.
306 * user data set when the signal handler was connected.
307 * The "GtkFileChooserDefault::home-folder" signal
308 * void user_function (GtkFileChooserDefault *chooser,
309 * gpointer user_data);
310 * This is used to make the file chooser show the user's home
311 * folder in the file list. By default this is bound to
313 * (the Home key in the numeric keypad also works).
315 * the object which received the signal.
317 * user data set when the signal handler was connected.
318 * The "GtkFileChooserDefault::desktop-folder" signal
319 * void user_function (GtkFileChooserDefault *chooser,
320 * gpointer user_data);
321 * This is used to make the file chooser show the user's Desktop
322 * folder in the file list. By default this is bound to
325 * the object which received the signal.
327 * user data set when the signal handler was connected.
328 * The "GtkFileChooserDefault::quick-bookmark" signal
329 * void user_function (GtkFileChooserDefault *chooser,
330 * gint bookmark_index,
331 * gpointer user_data);
332 * This is used to make the file chooser switch to the bookmark
333 * specified in the bookmark_index parameter.
334 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
335 * this signal to switch to each of them, respectively. By default this is bound to
340 * that in the default binding,
342 * actually defined to switch to the bookmark at index 0, and so on
345 * defined to switch to the bookmark at index 10.
347 * the object which received the signal.
349 * index of the bookmark to switch to; the indices start at 0.
351 * user data set when the signal handler was connected.
353 public class FileChooser
356 /** the main Gtk struct */
357 protected GtkFileChooser
* gtkFileChooser
;
360 public GtkFileChooser
* getFileChooserStruct()
362 return gtkFileChooser
;
366 /** the main Gtk struct as a void* */
367 protected void* getStruct()
369 return cast(void*)gtkFileChooser
;
373 * Sets our main struct and passes it to the parent class
375 public this (GtkFileChooser
* gtkFileChooser
)
379 if ( gtkFileChooser
is null )
384 Stdout("struct gtkFileChooser is null on constructor").newline
;
388 printf("struct gtkFileChooser is null on constructor");
395 assert(gtkFileChooser
!is null, "struct gtkFileChooser is null on constructor");
397 this.gtkFileChooser
= gtkFileChooser
;
403 // imports for the signal processing
404 private import gobject
.Signals
;
405 private import gtkc
.gdktypes
;
406 int[char[]] connectedSignals
;
408 GtkFileChooserConfirmation
delegate(FileChooser
)[] onConfirmOverwriteListeners
;
409 void addOnConfirmOverwrite(GtkFileChooserConfirmation
delegate(FileChooser
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
411 if ( !("confirm-overwrite" in connectedSignals
) )
416 cast(GCallback
)&callBackConfirmOverwrite
,
420 connectedSignals
["confirm-overwrite"] = 1;
422 onConfirmOverwriteListeners
~= dlg
;
424 extern(C
) static void callBackConfirmOverwrite(GtkFileChooser
* filechooserStruct
, FileChooser fileChooser
)
426 bool consumed
= false;
428 foreach ( GtkFileChooserConfirmation
delegate(FileChooser
) dlg
; fileChooser
.onConfirmOverwriteListeners
)
436 void delegate(FileChooser
)[] onCurrentFolderChangedListeners
;
437 void addOnCurrentFolderChanged(void delegate(FileChooser
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
439 if ( !("current-folder-changed" in connectedSignals
) )
443 "current-folder-changed",
444 cast(GCallback
)&callBackCurrentFolderChanged
,
448 connectedSignals
["current-folder-changed"] = 1;
450 onCurrentFolderChangedListeners
~= dlg
;
452 extern(C
) static void callBackCurrentFolderChanged(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
454 bool consumed
= false;
456 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onCurrentFolderChangedListeners
)
464 void delegate(FileChooser
)[] onFileActivatedListeners
;
465 void addOnFileActivated(void delegate(FileChooser
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
467 if ( !("file-activated" in connectedSignals
) )
472 cast(GCallback
)&callBackFileActivated
,
476 connectedSignals
["file-activated"] = 1;
478 onFileActivatedListeners
~= dlg
;
480 extern(C
) static void callBackFileActivated(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
482 bool consumed
= false;
484 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onFileActivatedListeners
)
492 void delegate(FileChooser
)[] onSelectionChangedListeners
;
493 void addOnSelectionChanged(void delegate(FileChooser
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
495 if ( !("selection-changed" in connectedSignals
) )
500 cast(GCallback
)&callBackSelectionChanged
,
504 connectedSignals
["selection-changed"] = 1;
506 onSelectionChangedListeners
~= dlg
;
508 extern(C
) static void callBackSelectionChanged(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
510 bool consumed
= false;
512 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onSelectionChangedListeners
)
520 void delegate(FileChooser
)[] onUpdatePreviewListeners
;
521 void addOnUpdatePreview(void delegate(FileChooser
) dlg
, ConnectFlags connectFlags
=cast(ConnectFlags
)0)
523 if ( !("update-preview" in connectedSignals
) )
528 cast(GCallback
)&callBackUpdatePreview
,
532 connectedSignals
["update-preview"] = 1;
534 onUpdatePreviewListeners
~= dlg
;
536 extern(C
) static void callBackUpdatePreview(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
538 bool consumed
= false;
540 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onUpdatePreviewListeners
)
555 * Sets the type of operation that the chooser is performing; the
556 * user interface is adapted to suit the selected action. For example,
557 * an option to create a new folder might be shown if the action is
558 * GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
559 * GTK_FILE_CHOOSER_ACTION_OPEN.
563 * the action that the file selector is performing
566 public void setAction(GtkFileChooserAction action
)
568 // void gtk_file_chooser_set_action (GtkFileChooser *chooser, GtkFileChooserAction action);
569 gtk_file_chooser_set_action(gtkFileChooser
, action
);
573 * Gets the type of operation that the file chooser is performing; see
574 * gtk_file_chooser_set_action().
578 * the action that the file selector is performing
581 public GtkFileChooserAction
getAction()
583 // GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser);
584 return gtk_file_chooser_get_action(gtkFileChooser
);
588 * Sets whether only local files can be selected in the
589 * file selector. If local_only is TRUE (the default),
590 * then the selected file are files are guaranteed to be
591 * accessible through the operating systems native file
592 * file system and therefore the application only
593 * needs to worry about the filename functions in
594 * GtkFileChooser, like gtk_file_chooser_get_filename(),
595 * rather than the URI functions like
596 * gtk_file_chooser_get_uri(),
600 * TRUE if only local files can be selected
603 public void setLocalOnly(int localOnly
)
605 // void gtk_file_chooser_set_local_only (GtkFileChooser *chooser, gboolean local_only);
606 gtk_file_chooser_set_local_only(gtkFileChooser
, localOnly
);
610 * Gets whether only local files can be selected in the
611 * file selector. See gtk_file_chooser_set_local_only()
615 * TRUE if only local files can be selected.
618 public int getLocalOnly()
620 // gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser);
621 return gtk_file_chooser_get_local_only(gtkFileChooser
);
625 * Sets whether multiple files can be selected in the file selector. This is
626 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
627 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
631 * TRUE if multiple files can be selected.
634 public void setSelectMultiple(int selectMultiple
)
636 // void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser, gboolean select_multiple);
637 gtk_file_chooser_set_select_multiple(gtkFileChooser
, selectMultiple
);
641 * Gets whether multiple files can be selected in the file
642 * selector. See gtk_file_chooser_set_select_multiple().
646 * TRUE if multiple files can be selected.
649 public int getSelectMultiple()
651 // gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);
652 return gtk_file_chooser_get_select_multiple(gtkFileChooser
);
656 * Sets whether hidden files and folders are displayed in the file selector.
660 * TRUE if hidden files and folders should be displayed.
663 public void setShowHidden(int showHidden
)
665 // void gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser, gboolean show_hidden);
666 gtk_file_chooser_set_show_hidden(gtkFileChooser
, showHidden
);
670 * Gets whether hidden files and folders are displayed in the file selector.
671 * See gtk_file_chooser_set_show_hidden().
675 * TRUE if hidden files and folders are displayed.
678 public int getShowHidden()
680 // gboolean gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser);
681 return gtk_file_chooser_get_show_hidden(gtkFileChooser
);
685 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
686 * a confirmation dialog if the user types a file name that already exists. This
687 * is FALSE by default.
688 * Regardless of this setting, the chooser will emit the "confirm-overwrite"
689 * signal when appropriate.
690 * If all you need is the stock confirmation dialog, set this property to TRUE.
691 * You can override the way confirmation is done by actually handling the
692 * "confirm-overwrite" signal; please refer to its documentation for the
696 * do_overwrite_confirmation:
697 * whether to confirm overwriting in save mode
700 public void setDoOverwriteConfirmation(int doOverwriteConfirmation
)
702 // void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
703 gtk_file_chooser_set_do_overwrite_confirmation(gtkFileChooser
, doOverwriteConfirmation
);
707 * Queries whether a file chooser is set to confirm for overwriting when the user
708 * types a file name that already exists.
712 * TRUE if the file chooser will present a confirmation dialog;
716 public int getDoOverwriteConfirmation()
718 // gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser);
719 return gtk_file_chooser_get_do_overwrite_confirmation(gtkFileChooser
);
723 * Sets the current name in the file selector, as if entered
724 * by the user. Note that the name passed in here is a UTF-8
725 * string rather than a filename. This function is meant for
726 * such uses as a suggested name in a "Save As..." dialog.
727 * If you want to preselect a particular existing file, you should use
728 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
729 * Please see the documentation for those functions for an example of using
730 * gtk_file_chooser_set_current_name() as well.
734 * the filename to use, as a UTF-8 string
737 public void setCurrentName(char[] name
)
739 // void gtk_file_chooser_set_current_name (GtkFileChooser *chooser, const gchar *name);
740 gtk_file_chooser_set_current_name(gtkFileChooser
, Str
.toStringz(name
));
744 * Gets the filename for the currently selected file in
745 * the file selector. If multiple files are selected,
746 * one of the filenames will be returned at random.
747 * If the file chooser is in folder mode, this function returns the selected
752 * The currently selected filename, or NULL
753 * if no file is selected, or the selected file can't
754 * be represented with a local filename. Free with g_free().
757 public char[] getFilename()
759 // gchar* gtk_file_chooser_get_filename (GtkFileChooser *chooser);
760 return Str
.toString(gtk_file_chooser_get_filename(gtkFileChooser
) );
764 * Sets filename as the current filename for the file chooser, by changing
765 * to the file's parent folder and actually selecting the file in list. If
766 * the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
767 * will also appear in the dialog's file name entry.
768 * If the file name isn't in the current folder of chooser, then the current
769 * folder of chooser will be changed to the folder containing filename. This
770 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
771 * gtk_file_chooser_select_filename().
772 * Note that the file must exist, or nothing will be done except
773 * for the directory change.
774 * If you are implementing a File/Save As... dialog, you
775 * should use this function if you already have a file name to which the user may save; for example,
776 * when the user opens an existing file and then does File/Save As...
777 * on it. If you don't have a file name already for example, if the user just created
778 * a new file and is saving it for the first time, do not call this function. Instead, use
779 * something similar to this:
780 * if (document_is_new)
782 * /+* the user just created a new document +/
783 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
784 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
788 * /+* the user edited an existing document +/
789 * gtk_file_chooser_set_filename (chooser, existing_filename);
794 * the filename to set as current
796 * TRUE if both the folder could be changed and the file was
797 * selected successfully, FALSE otherwise.
800 public int setFilename(char[] filename
)
802 // gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser, const char *filename);
803 return gtk_file_chooser_set_filename(gtkFileChooser
, Str
.toStringz(filename
));
807 * Selects a filename. If the file name isn't in the current
808 * folder of chooser, then the current folder of chooser will
809 * be changed to the folder containing filename.
813 * the filename to select
815 * TRUE if both the folder could be changed and the file was
816 * selected successfully, FALSE otherwise.
819 public int selectFilename(char[] filename
)
821 // gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser, const char *filename);
822 return gtk_file_chooser_select_filename(gtkFileChooser
, Str
.toStringz(filename
));
826 * Unselects a currently selected filename. If the filename
827 * is not in the current directory, does not exist, or
828 * is otherwise not currently selected, does nothing.
832 * the filename to unselect
835 public void unselectFilename(char[] filename
)
837 // void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser, const char *filename);
838 gtk_file_chooser_unselect_filename(gtkFileChooser
, Str
.toStringz(filename
));
842 * Selects all the files in the current folder of a file chooser.
847 public void selectAll()
849 // void gtk_file_chooser_select_all (GtkFileChooser *chooser);
850 gtk_file_chooser_select_all(gtkFileChooser
);
854 * Unselects all the files in the current folder of a file chooser.
859 public void unselectAll()
861 // void gtk_file_chooser_unselect_all (GtkFileChooser *chooser);
862 gtk_file_chooser_unselect_all(gtkFileChooser
);
866 * Lists all the selected files and subfolders in the current folder of
867 * chooser. The returned names are full absolute paths. If files in the current
868 * folder cannot be represented as local filenames they will be ignored. (See
869 * gtk_file_chooser_get_uris())
873 * a GSList containing the filenames of all selected
874 * files and subfolders in the current folder. Free the returned list
875 * with g_slist_free(), and the filenames with g_free().
878 public ListSG
getFilenames()
880 // GSList* gtk_file_chooser_get_filenames (GtkFileChooser *chooser);
881 return new ListSG( gtk_file_chooser_get_filenames(gtkFileChooser
) );
885 * Sets the current folder for chooser from a local filename.
886 * The user will be shown the full contents of the current folder,
887 * plus user interface elements for navigating to other folders.
891 * the full path of the new current folder
893 * TRUE if the folder could be changed successfully, FALSE
897 public int setCurrentFolder(char[] filename
)
899 // gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser, const gchar *filename);
900 return gtk_file_chooser_set_current_folder(gtkFileChooser
, Str
.toStringz(filename
));
904 * Gets the current folder of chooser as a local filename.
905 * See gtk_file_chooser_set_current_folder().
906 * Note that this is the folder that the file chooser is currently displaying
907 * (e.g. "/home/username/Documents"), which is not the same
908 * as the currently-selected folder if the chooser is in
909 * GTK_FILE_CHOOSER_SELECT_FOLDER mode
910 * (e.g. "/home/username/Documents/selected-folder/". To get the
911 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
912 * usual way to get the selection.
916 * the full path of the current folder, or NULL if the current
917 * path cannot be represented as a local filename. Free with g_free(). This
918 * function will also return NULL if the file chooser was unable to load the
919 * last folder that was requested from it; for example, as would be for calling
920 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
923 public char[] getCurrentFolder()
925 // gchar* gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
926 return Str
.toString(gtk_file_chooser_get_current_folder(gtkFileChooser
) );
930 * Gets the URI for the currently selected file in
931 * the file selector. If multiple files are selected,
932 * one of the filenames will be returned at random.
933 * If the file chooser is in folder mode, this function returns the selected
938 * The currently selected URI, or NULL
939 * if no file is selected. Free with g_free()
942 public char[] getUri()
944 // gchar* gtk_file_chooser_get_uri (GtkFileChooser *chooser);
945 return Str
.toString(gtk_file_chooser_get_uri(gtkFileChooser
) );
949 * Sets the file referred to by uri as the current file for the file chooser,
950 * by changing to the URI's parent folder and actually selecting the URI in the
951 * list. If the chooser is GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
952 * name will also appear in the dialog's file name entry.
953 * If the URI isn't in the current folder of chooser, then the current folder
954 * of chooser will be changed to the folder containing uri. This is equivalent
955 * to a sequence of gtk_file_chooser_unselect_all() followed by
956 * gtk_file_chooser_select_uri().
957 * Note that the URI must exist, or nothing will be done except
958 * for the directory change.
959 * If you are implementing a File/Save As... dialog, you
960 * should use this function if you already have a file name to which the user may save; for example,
961 * when the user opens an existing file and then does File/Save As...
962 * on it. If you don't have a file name already for example, if the user just created
963 * a new file and is saving it for the first time, do not call this function. Instead, use
964 * something similar to this:
965 * if (document_is_new)
967 * /+* the user just created a new document +/
968 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
969 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
973 * /+* the user edited an existing document +/
974 * gtk_file_chooser_set_uri (chooser, existing_uri);
979 * the URI to set as current
981 * TRUE if both the folder could be changed and the URI was
982 * selected successfully, FALSE otherwise.
985 public int setUri(char[] uri
)
987 // gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, const char *uri);
988 return gtk_file_chooser_set_uri(gtkFileChooser
, Str
.toStringz(uri
));
992 * Selects the file to by uri. If the URI doesn't refer to a
993 * file in the current folder of chooser, then the current folder of
994 * chooser will be changed to the folder containing filename.
1000 * TRUE if both the folder could be changed and the URI was
1001 * selected successfully, FALSE otherwise.
1004 public int selectUri(char[] uri
)
1006 // gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser, const char *uri);
1007 return gtk_file_chooser_select_uri(gtkFileChooser
, Str
.toStringz(uri
));
1011 * Unselects the file referred to by uri. If the file
1012 * is not in the current directory, does not exist, or
1013 * is otherwise not currently selected, does nothing.
1017 * the URI to unselect
1020 public void unselectUri(char[] uri
)
1022 // void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser, const char *uri);
1023 gtk_file_chooser_unselect_uri(gtkFileChooser
, Str
.toStringz(uri
));
1027 * Lists all the selected files and subfolders in the current folder of
1028 * chooser. The returned names are full absolute URIs.
1032 * a GSList containing the URIs of all selected
1033 * files and subfolders in the current folder. Free the returned list
1034 * with g_slist_free(), and the filenames with g_free().
1037 public ListSG
getUris()
1039 // GSList* gtk_file_chooser_get_uris (GtkFileChooser *chooser);
1040 return new ListSG( gtk_file_chooser_get_uris(gtkFileChooser
) );
1044 * Sets the current folder for chooser from an URI.
1045 * The user will be shown the full contents of the current folder,
1046 * plus user interface elements for navigating to other folders.
1050 * the URI for the new current folder
1052 * TRUE if the folder could be changed successfully, FALSE
1056 public int setCurrentFolderUri(char[] uri
)
1058 // gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser, const gchar *uri);
1059 return gtk_file_chooser_set_current_folder_uri(gtkFileChooser
, Str
.toStringz(uri
));
1063 * Gets the current folder of chooser as an URI.
1064 * See gtk_file_chooser_set_current_folder_uri().
1065 * Note that this is the folder that the file chooser is currently displaying
1066 * (e.g. "file:///home/username/Documents"), which is not the same
1067 * as the currently-selected folder if the chooser is in
1068 * GTK_FILE_CHOOSER_SELECT_FOLDER mode
1069 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1070 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1071 * usual way to get the selection.
1075 * the URI for the current folder. Free with g_free(). This
1076 * function will also return NULL if the file chooser was unable to load the
1077 * last folder that was requested from it; for example, as would be for calling
1078 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1081 public char[] getCurrentFolderUri()
1083 // gchar* gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
1084 return Str
.toString(gtk_file_chooser_get_current_folder_uri(gtkFileChooser
) );
1088 * Sets an application-supplied widget to use to display a custom preview
1089 * of the currently selected file. To implement a preview, after setting the
1090 * preview widget, you connect to the ::update-preview
1091 * signal, and call gtk_file_chooser_get_preview_filename() or
1092 * gtk_file_chooser_get_preview_uri() on each change. If you can
1093 * display a preview of the new file, update your widget and
1094 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1095 * Otherwise, set the preview inactive.
1096 * When there is no application-supplied preview widget, or the
1097 * application-supplied preview widget is not active, the file chooser
1098 * may display an internally generated preview of the current file or
1099 * it may display no preview at all.
1103 * widget for displaying preview.
1106 public void setPreviewWidget(Widget previewWidget
)
1108 // void gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser, GtkWidget *preview_widget);
1109 gtk_file_chooser_set_preview_widget(gtkFileChooser
, (previewWidget
is null) ?
null : previewWidget
.getWidgetStruct());
1113 * Gets the current preview widget; see
1114 * gtk_file_chooser_set_preview_widget().
1118 * the current preview widget, or NULL
1121 public Widget
getPreviewWidget()
1123 // GtkWidget* gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser);
1124 return new Widget( gtk_file_chooser_get_preview_widget(gtkFileChooser
) );
1128 * Sets whether the preview widget set by
1129 * gtk_file_chooser_set_preview_widget() should be shown for the
1130 * current filename. When active is set to false, the file chooser
1131 * may display an internally generated preview of the current file
1132 * or it may display no preview at all. See
1133 * gtk_file_chooser_set_preview_widget() for more details.
1137 * whether to display the user-specified preview widget
1140 public void setPreviewWidgetActive(int active
)
1142 // void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser, gboolean active);
1143 gtk_file_chooser_set_preview_widget_active(gtkFileChooser
, active
);
1147 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1148 * should be shown for the current filename. See
1149 * gtk_file_chooser_set_preview_widget_active().
1153 * TRUE if the preview widget is active for the current filename.
1156 public int getPreviewWidgetActive()
1158 // gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
1159 return gtk_file_chooser_get_preview_widget_active(gtkFileChooser
);
1163 * Sets whether the file chooser should display a stock label with the name of
1164 * the file that is being previewed; the default is TRUE. Applications that
1165 * want to draw the whole preview area themselves should set this to FALSE and
1166 * display the name themselves in their preview widget.
1167 * See also: gtk_file_chooser_set_preview_widget()
1171 * whether to display a stock label with the name of the previewed file
1174 public void setUsePreviewLabel(int useLabel
)
1176 // void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser, gboolean use_label);
1177 gtk_file_chooser_set_use_preview_label(gtkFileChooser
, useLabel
);
1181 * Gets whether a stock label should be drawn with the name of the previewed
1182 * file. See gtk_file_chooser_set_use_preview_label().
1186 * TRUE if the file chooser is set to display a label with the
1187 * name of the previewed file, FALSE otherwise.
1189 public int getUsePreviewLabel()
1191 // gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser);
1192 return gtk_file_chooser_get_use_preview_label(gtkFileChooser
);
1196 * Gets the filename that should be previewed in a custom preview
1197 * widget. See gtk_file_chooser_set_preview_widget().
1201 * the filename to preview, or NULL if no file
1202 * is selected, or if the selected file cannot be represented
1203 * as a local filename. Free with g_free()
1206 public char[] getPreviewFilename()
1208 // char* gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
1209 return Str
.toString(gtk_file_chooser_get_preview_filename(gtkFileChooser
) );
1213 * Gets the URI that should be previewed in a custom preview
1214 * widget. See gtk_file_chooser_set_preview_widget().
1218 * the URI for the file to preview, or NULL if no file is
1219 * selected. Free with g_free().
1222 public char[] getPreviewUri()
1224 // char* gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser);
1225 return Str
.toString(gtk_file_chooser_get_preview_uri(gtkFileChooser
) );
1229 * Sets an application-supplied widget to provide extra options to the user.
1233 * widget for extra options
1236 public void setExtraWidget(Widget extraWidget
)
1238 // void gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser, GtkWidget *extra_widget);
1239 gtk_file_chooser_set_extra_widget(gtkFileChooser
, (extraWidget
is null) ?
null : extraWidget
.getWidgetStruct());
1243 * Gets the current preview widget; see
1244 * gtk_file_chooser_set_extra_widget().
1248 * the current extra widget, or NULL
1251 public Widget
getExtraWidget()
1253 // GtkWidget* gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
1254 return new Widget( gtk_file_chooser_get_extra_widget(gtkFileChooser
) );
1258 * Adds filter to the list of filters that the user can select between.
1259 * When a filter is selected, only files that are passed by that
1260 * filter are displayed.
1261 * Note that the chooser takes ownership of the filter, so you have to
1262 * ref and sink it if you want to keep a reference.
1269 public void addFilter(FileFilter filter
)
1271 // void gtk_file_chooser_add_filter (GtkFileChooser *chooser, GtkFileFilter *filter);
1272 gtk_file_chooser_add_filter(gtkFileChooser
, (filter
is null) ?
null : filter
.getFileFilterStruct());
1276 * Removes filter from the list of filters that the user can select between.
1283 public void removeFilter(FileFilter filter
)
1285 // void gtk_file_chooser_remove_filter (GtkFileChooser *chooser, GtkFileFilter *filter);
1286 gtk_file_chooser_remove_filter(gtkFileChooser
, (filter
is null) ?
null : filter
.getFileFilterStruct());
1290 * Lists the current set of user-selectable filters; see
1291 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1295 * a GSList containing the current set of
1296 * user selectable filters. The contents of the list are
1297 * owned by GTK+, but you must free the list itself with
1298 * g_slist_free() when you are done with it.
1301 public ListSG
listFilters()
1303 // GSList* gtk_file_chooser_list_filters (GtkFileChooser *chooser);
1304 return new ListSG( gtk_file_chooser_list_filters(gtkFileChooser
) );
1308 * Sets the current filter; only the files that pass the
1309 * filter will be displayed. If the user-selectable list of filters
1310 * is non-empty, then the filter should be one of the filters
1311 * in that list. Setting the current filter when the list of
1312 * filters is empty is useful if you want to restrict the displayed
1313 * set of files without letting the user change it.
1320 public void setFilter(FileFilter filter
)
1322 // void gtk_file_chooser_set_filter (GtkFileChooser *chooser, GtkFileFilter *filter);
1323 gtk_file_chooser_set_filter(gtkFileChooser
, (filter
is null) ?
null : filter
.getFileFilterStruct());
1327 * Gets the current filter; see gtk_file_chooser_set_filter().
1331 * the current filter, or NULL
1334 public FileFilter
getFilter()
1336 // GtkFileFilter* gtk_file_chooser_get_filter (GtkFileChooser *chooser);
1337 return new FileFilter( gtk_file_chooser_get_filter(gtkFileChooser
) );
1341 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1342 * Note that shortcut folders do not get saved, as they are provided by the
1343 * application. For example, you can use this to add a
1344 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1348 * filename of the folder to add
1350 * location to store error, or NULL
1352 * TRUE if the folder could be added successfully, FALSE
1353 * otherwise. In the latter case, the error will be set as appropriate.
1356 public int addShortcutFolder(char[] folder
, GError
** error
)
1358 // gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser, const char *folder, GError **error);
1359 return gtk_file_chooser_add_shortcut_folder(gtkFileChooser
, Str
.toStringz(folder
), error
);
1363 * Removes a folder from a file chooser's list of shortcut folders.
1367 * filename of the folder to remove
1369 * location to store error, or NULL
1371 * TRUE if the operation succeeds, FALSE otherwise.
1372 * In the latter case, the error will be set as appropriate.
1373 * See also: gtk_file_chooser_add_shortcut_folder()
1376 public int removeShortcutFolder(char[] folder
, GError
** error
)
1378 // gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, const char *folder, GError **error);
1379 return gtk_file_chooser_remove_shortcut_folder(gtkFileChooser
, Str
.toStringz(folder
), error
);
1383 * Queries the list of shortcut folders in the file chooser, as set by
1384 * gtk_file_chooser_add_shortcut_folder().
1388 * A list of folder filenames, or NULL if there are no shortcut
1389 * folders. Free the returned list with g_slist_free(), and the filenames with
1393 public ListSG
listShortcutFolders()
1395 // GSList* gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser);
1396 return new ListSG( gtk_file_chooser_list_shortcut_folders(gtkFileChooser
) );
1400 * Adds a folder URI to be displayed with the shortcut folders in a file
1401 * chooser. Note that shortcut folders do not get saved, as they are provided
1402 * by the application. For example, you can use this to add a
1403 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1407 * URI of the folder to add
1409 * location to store error, or NULL
1411 * TRUE if the folder could be added successfully, FALSE
1412 * otherwise. In the latter case, the error will be set as appropriate.
1415 public int addShortcutFolderUri(char[] uri
, GError
** error
)
1417 // gboolean gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser, const char *uri, GError **error);
1418 return gtk_file_chooser_add_shortcut_folder_uri(gtkFileChooser
, Str
.toStringz(uri
), error
);
1422 * Removes a folder URI from a file chooser's list of shortcut folders.
1426 * URI of the folder to remove
1428 * location to store error, or NULL
1430 * TRUE if the operation succeeds, FALSE otherwise.
1431 * In the latter case, the error will be set as appropriate.
1432 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1435 public int removeShortcutFolderUri(char[] uri
, GError
** error
)
1437 // gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser, const char *uri, GError **error);
1438 return gtk_file_chooser_remove_shortcut_folder_uri(gtkFileChooser
, Str
.toStringz(uri
), error
);
1442 * Queries the list of shortcut folders in the file chooser, as set by
1443 * gtk_file_chooser_add_shortcut_folder_uri().
1447 * A list of folder URIs, or NULL if there are no shortcut
1448 * folders. Free the returned list with g_slist_free(), and the URIs with
1452 * The "action" property
1453 * "action" GtkFileChooserAction : Read / Write
1454 * The type of operation that the file selector is performing.
1455 * Default value: GTK_FILE_CHOOSER_ACTION_OPEN
1457 public ListSG
listShortcutFolderUris()
1459 // GSList* gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser);
1460 return new ListSG( gtk_file_chooser_list_shortcut_folder_uris(gtkFileChooser
) );