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 = GtkFileChooser.html
27 * outFile = FileChooser
28 * strct = GtkFileChooser
52 * - GtkFileFilter* -> FileFilter
53 * - GtkWidget* -> Widget
54 * - GtkWindow* -> Window
58 module gtk
.FileChooser
;
60 private import gtk
.gtktypes
;
62 private import lib
.gtk
;
64 private import glib
.Str
;
65 private import gtk
.Window
;
66 private import glib
.ListSG
;
67 private import gtk
.Widget
;
68 private import gtk
.FileFilter
;
72 * GtkFileChooser is an interface that can be implemented by file
73 * selection widgets. In GTK+, the main objects that implement this
74 * interface are GtkFileChooserWidget, GtkFileChooserDialog, and
75 * GtkFileChooserButton. You do not need to write an object that
76 * implements the GtkFileChooser interface unless you are trying to
77 * adapt an existing file selector to expose a standard programming
79 * GtkFileChooser allows for shortcuts to various places in the filesystem.
80 * In the default implementation these are displayed in the left pane. It
81 * may be a bit confusing at first taht these shortcuts come from various
82 * sources and in various flavours, so lets explain the terminology here:
84 * are created by the user, by dragging folders from the
85 * right pane to the left pane, or by using the "Add". Bookmarks
86 * can be renamed and deleted by the user.
88 * can be provided by the application or by the underlying filesystem
89 * abstraction (e.g. both the gnome-vfs and the Windows filesystems
90 * provide "Desktop" shortcuts). Shortcuts cannot be modified by the
93 * are provided by the underlying filesystem abstraction. They are
94 * the "roots" of the filesystem.
95 * File Names and Encodings
96 * When the user is finished selecting files in a
97 * GtkFileChooser, your program can get the selected names
98 * either as filenames or as URIs. For URIs, the normal escaping
99 * rules are applied if the URI contains non-ASCII characters.
100 * However, filenames are always returned in
101 * the character set specified by the
102 * G_FILENAME_ENCODING environment variable.
103 * Please see the Glib documentation for more details about this
106 * This means that while you can pass the result of
107 * gtk_file_chooser_get_filename() to
109 * fopen(3), you may not be able to
110 * directly set it as the text of a GtkLabel widget unless you
111 * convert it first to UTF-8, which all GTK+ widgets expect.
112 * You should use g_filename_to_utf8() to convert filenames
113 * into strings that can be passed to GTK+ widgets.
115 * Adding a Preview Widget
116 * You can add a custom preview widget to a file chooser and then
117 * get notification about when the preview needs to be updated.
118 * To install a preview widget, use
119 * gtk_file_chooser_set_preview_widget(). Then, connect to the
120 * GtkFileChooser::update-preview signal to get notified when
121 * you need to update the contents of the preview.
122 * Your callback should use
123 * gtk_file_chooser_get_preview_filename() to see what needs
124 * previewing. Once you have generated the preview for the
125 * corresponding file, you must call
126 * gtk_file_chooser_set_preview_widget_active() with a boolean
127 * flag that indicates whether your callback could successfully
128 * generate a preview.
129 * Example2.Sample Usage
133 * preview = gtk_image_new ();
134 * gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
135 * g_signal_connect (my_file_chooser, "update-preview",
136 * G_CALLBACK (update_preview_cb), preview);
139 * update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
141 * GtkWidget *preview;
144 * gboolean have_preview;
145 * preview = GTK_WIDGET (data);
146 * filename = gtk_file_chooser_get_preview_filename (file_chooser);
147 * pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
148 * have_preview = (pixbuf != NULL);
150 * gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
152 * gobject_unref (pixbuf);
153 * gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
156 * Adding Extra Widgets
157 * You can add extra widgets to a file chooser to provide options
158 * that are not present in the default design. For example, you
159 * can add a toggle button to give the user the option to open a
160 * file in read-only mode. You can use
161 * gtk_file_chooser_set_extra_widget() to insert additional
162 * widgets in a file chooser.
163 * Example3.Sample Usage
167 * toggle = gtk_check_button_new_with_label ("Open file read-only");
168 * gtk_widget_show (toggle);
169 * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
172 * If you want to set more than one extra widget in the file
173 * chooser, you can a container such as a GtkVBox or a GtkTable
174 * and include your widgets in it. Then, set the container as
175 * the whole extra widget.
178 * Internally, GTK+ implements a file chooser's graphical user
179 * interface with the private
180 * GtkFileChooserDefaultClass. This
181 * widget has several key
182 * bindings and their associated signals. This section
183 * describes the available key binding signals.
184 * Example4.GtkFileChooser key binding example
185 * The default keys that activate the key-binding signals in
186 * GtkFileChooserDefaultClass are as
189 * Default key combinations
191 * Control-L (empty path);
192 * / (path of "/")[a];
205 * Alt-1 through Alt-0
207 * Both the individual / key and the
208 * numeric keypad's "divide" key are supported.
210 * Both the individual Up key and the numeric
211 * keypad's Up key are supported.
212 * You can change these defaults to something else. For
213 * example, to add a Shift modifier to a few
214 * of the default bindings, you can include the following
215 * fragment in your .gtkrc-2.0 file:
216 * binding "my-own-gtkfilechooser-bindings" {
217 * bind "<Alt><Shift>Up" {
220 * bind "<Alt><Shift>Down" {
223 * bind "<Alt><Shift>Home" {
227 * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings"
228 * The "GtkFileChooserDefault::location-popup" signal
229 * void user_function (GtkFileChooserDefault *chooser,
231 * gpointer user_data);
232 * This is used to make the file chooser show a "Location"
233 * dialog which the user can use to manually type the name of
234 * the file he wishes to select. The
235 * path argument is a string that gets
236 * put in the text entry for the file name. By default this is bound to
238 * with a path string of "" (the empty
239 * string). It is also bound to / with a
241 * (a slash): this lets you type / and
242 * immediately type a path name. On Unix systems, this is bound to
243 * ~ (tilde) with a path string
244 * of "~" itself for access to home directories.
246 * the object which received the signal.
248 * default contents for the text entry for the file name
250 * user data set when the signal handler was connected.
252 * You can create your own bindings for the
253 * location-popup signal with custom
254 * path strings, and have a crude form
255 * of easily-to-type bookmarks. For example, say you access
256 * the path /home/username/misc very
257 * frequently. You could then create an Alt-M
258 * shortcut by including the following in your
260 * binding "misc-shortcut" {
262 * "location-popup" ("/home/username/misc")
265 * class "GtkFileChooserDefault" binding "misc-shortcut"
266 * The "GtkFileChooserDefault::up-folder" signal
267 * void user_function (GtkFileChooserDefault *chooser,
268 * gpointer user_data);
269 * This is used to make the file chooser go to the parent of
270 * the current folder in the file hierarchy. By default this
271 * is bound to Backspace and
273 * (the Up key in the numeric keypad also works).
275 * the object which received the signal.
277 * user data set when the signal handler was connected.
278 * The "GtkFileChooserDefault::down-folder" signal
279 * void user_function (GtkFileChooserDefault *chooser,
280 * gpointer user_data);
281 * This is used to make the file chooser go to a child of the
282 * current folder in the file hierarchy. The subfolder that
283 * will be used is displayed in the path bar widget of the file
284 * chooser. For example, if the path bar is showing
285 * "/foo/bar/baz", then this will cause
286 * the file chooser to switch to the "baz" subfolder. By
287 * default this is bound to
289 * (the Down key in the numeric keypad also works).
291 * the object which received the signal.
293 * user data set when the signal handler was connected.
294 * The "GtkFileChooserDefault::home-folder" signal
295 * void user_function (GtkFileChooserDefault *chooser,
296 * gpointer user_data);
297 * This is used to make the file chooser show the user's home
298 * folder in the file list. By default this is bound to
300 * (the Home key in the numeric keypad also works).
302 * the object which received the signal.
304 * user data set when the signal handler was connected.
305 * The "GtkFileChooserDefault::desktop-folder" signal
306 * void user_function (GtkFileChooserDefault *chooser,
307 * gpointer user_data);
308 * This is used to make the file chooser show the user's Desktop
309 * folder in the file list. By default this is bound to
312 * the object which received the signal.
314 * user data set when the signal handler was connected.
315 * The "GtkFileChooserDefault::quick-bookmark" signal
316 * void user_function (GtkFileChooserDefault *chooser,
317 * gint bookmark_index,
318 * gpointer user_data);
319 * This is used to make the file chooser switch to the bookmark
320 * specified in the bookmark_index parameter.
321 * For example, if you have three bookmarks, you can pass 0, 1, 2 to
322 * this signal to switch to each of them, respectively. By default this is bound to
327 * that in the default binding,
329 * actually defined to switch to the bookmark at index 0, and so on
332 * defined to switch to the bookmark at index 10.
334 * the object which received the signal.
336 * index of the bookmark to switch to; the indices start at 0.
338 * user data set when the signal handler was connected.
340 public class FileChooser
343 /** the main Gtk struct */
344 protected GtkFileChooser
* gtkFileChooser
;
347 public GtkFileChooser
* getFileChooserStruct()
349 return gtkFileChooser
;
353 /** the main Gtk struct as a void* */
354 protected void* getStruct()
356 return cast(void*)gtkFileChooser
;
360 * Sets our main struct and passes it to the parent class
362 public this (GtkFileChooser
* gtkFileChooser
)
364 this.gtkFileChooser
= gtkFileChooser
;
370 // imports for the signal processing
371 private import gobject
.Signals
;
372 private import gdk
.gdktypes
;
373 int[char[]] connectedSignals
;
375 GtkFileChooserConfirmation
delegate(FileChooser
)[] onConfirmOverwriteListeners
;
376 void addOnConfirmOverwrite(GtkFileChooserConfirmation
delegate(FileChooser
) dlg
)
378 if ( !("confirm-overwrite" in connectedSignals
) )
383 cast(GCallback
)&callBackConfirmOverwrite
,
386 cast(ConnectFlags
)0);
387 connectedSignals
["confirm-overwrite"] = 1;
389 onConfirmOverwriteListeners
~= dlg
;
391 extern(C
) static void callBackConfirmOverwrite(GtkFileChooser
* filechooserStruct
, FileChooser fileChooser
)
393 bit consumed
= false;
395 foreach ( GtkFileChooserConfirmation
delegate(FileChooser
) dlg
; fileChooser
.onConfirmOverwriteListeners
)
403 void delegate(FileChooser
)[] onCurrentFolderChangedListeners
;
404 void addOnCurrentFolderChanged(void delegate(FileChooser
) dlg
)
406 if ( !("current-folder-changed" in connectedSignals
) )
410 "current-folder-changed",
411 cast(GCallback
)&callBackCurrentFolderChanged
,
414 cast(ConnectFlags
)0);
415 connectedSignals
["current-folder-changed"] = 1;
417 onCurrentFolderChangedListeners
~= dlg
;
419 extern(C
) static void callBackCurrentFolderChanged(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
421 bit consumed
= false;
423 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onCurrentFolderChangedListeners
)
431 void delegate(FileChooser
)[] onFileActivatedListeners
;
432 void addOnFileActivated(void delegate(FileChooser
) dlg
)
434 if ( !("file-activated" in connectedSignals
) )
439 cast(GCallback
)&callBackFileActivated
,
442 cast(ConnectFlags
)0);
443 connectedSignals
["file-activated"] = 1;
445 onFileActivatedListeners
~= dlg
;
447 extern(C
) static void callBackFileActivated(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
449 bit consumed
= false;
451 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onFileActivatedListeners
)
459 void delegate(FileChooser
)[] onSelectionChangedListeners
;
460 void addOnSelectionChanged(void delegate(FileChooser
) dlg
)
462 if ( !("selection-changed" in connectedSignals
) )
467 cast(GCallback
)&callBackSelectionChanged
,
470 cast(ConnectFlags
)0);
471 connectedSignals
["selection-changed"] = 1;
473 onSelectionChangedListeners
~= dlg
;
475 extern(C
) static void callBackSelectionChanged(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
477 bit consumed
= false;
479 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onSelectionChangedListeners
)
487 void delegate(FileChooser
)[] onUpdatePreviewListeners
;
488 void addOnUpdatePreview(void delegate(FileChooser
) dlg
)
490 if ( !("update-preview" in connectedSignals
) )
495 cast(GCallback
)&callBackUpdatePreview
,
498 cast(ConnectFlags
)0);
499 connectedSignals
["update-preview"] = 1;
501 onUpdatePreviewListeners
~= dlg
;
503 extern(C
) static void callBackUpdatePreview(GtkFileChooser
* chooserStruct
, FileChooser fileChooser
)
505 bit consumed
= false;
507 foreach ( void delegate(FileChooser
) dlg
; fileChooser
.onUpdatePreviewListeners
)
522 * Sets the type of operation that the chooser is performing; the
523 * user interface is adapted to suit the selected action. For example,
524 * an option to create a new folder might be shown if the action is
525 * GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is
526 * GTK_FILE_CHOOSER_ACTION_OPEN.
530 * the action that the file selector is performing
533 public void setAction(GtkFileChooserAction action
)
535 // void gtk_file_chooser_set_action (GtkFileChooser *chooser, GtkFileChooserAction action);
536 gtk_file_chooser_set_action(gtkFileChooser
, action
);
540 * Gets the type of operation that the file chooser is performing; see
541 * gtk_file_chooser_set_action().
545 * the action that the file selector is performing
548 public GtkFileChooserAction
getAction()
550 // GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser);
551 return gtk_file_chooser_get_action(gtkFileChooser
);
555 * Sets whether only local files can be selected in the
556 * file selector. If local_only is TRUE (the default),
557 * then the selected file are files are guaranteed to be
558 * accessible through the operating systems native file
559 * file system and therefore the application only
560 * needs to worry about the filename functions in
561 * GtkFileChooser, like gtk_file_chooser_get_filename(),
562 * rather than the URI functions like
563 * gtk_file_chooser_get_uri(),
567 * TRUE if only local files can be selected
570 public void setLocalOnly(int localOnly
)
572 // void gtk_file_chooser_set_local_only (GtkFileChooser *chooser, gboolean local_only);
573 gtk_file_chooser_set_local_only(gtkFileChooser
, localOnly
);
577 * Gets whether only local files can be selected in the
578 * file selector. See gtk_file_chooser_set_local_only()
582 * TRUE if only local files can be selected.
585 public int getLocalOnly()
587 // gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser);
588 return gtk_file_chooser_get_local_only(gtkFileChooser
);
592 * Sets whether multiple files can be selected in the file selector. This is
593 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or
594 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
598 * TRUE if multiple files can be selected.
601 public void setSelectMultiple(int selectMultiple
)
603 // void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser, gboolean select_multiple);
604 gtk_file_chooser_set_select_multiple(gtkFileChooser
, selectMultiple
);
608 * Gets whether multiple files can be selected in the file
609 * selector. See gtk_file_chooser_set_select_multiple().
613 * TRUE if multiple files can be selected.
616 public int getSelectMultiple()
618 // gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);
619 return gtk_file_chooser_get_select_multiple(gtkFileChooser
);
623 * Sets whether hidden files and folders are displayed in the file selector.
627 * TRUE if hidden files and folders should be displayed.
630 public void setShowHidden(int showHidden
)
632 // void gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser, gboolean show_hidden);
633 gtk_file_chooser_set_show_hidden(gtkFileChooser
, showHidden
);
637 * Gets whether hidden files and folders are displayed in the file selector.
638 * See gtk_file_chooser_set_show_hidden().
642 * TRUE if hidden files and folders are displayed.
645 public int getShowHidden()
647 // gboolean gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser);
648 return gtk_file_chooser_get_show_hidden(gtkFileChooser
);
652 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present
653 * a confirmation dialog if the user types a file name that already exists. This
654 * is FALSE by default.
655 * Regardless of this setting, the chooser will emit the "confirm-overwrite"
656 * signal when appropriate.
657 * If all you need is the stock confirmation dialog, set this property to TRUE.
658 * You can override the way confirmation is done by actually handling the
659 * "confirm-overwrite" signal; please refer to its documentation for the
663 * do_overwrite_confirmation:
664 * whether to confirm overwriting in save mode
667 public void setDoOverwriteConfirmation(int doOverwriteConfirmation
)
669 // void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
670 gtk_file_chooser_set_do_overwrite_confirmation(gtkFileChooser
, doOverwriteConfirmation
);
674 * Queries whether a file chooser is set to confirm for overwriting when the user
675 * types a file name that already exists.
679 * TRUE if the file chooser will present a confirmation dialog;
683 public int getDoOverwriteConfirmation()
685 // gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser);
686 return gtk_file_chooser_get_do_overwrite_confirmation(gtkFileChooser
);
690 * Sets the current name in the file selector, as if entered
691 * by the user. Note that the name passed in here is a UTF-8
692 * string rather than a filename. This function is meant for
693 * such uses as a suggested name in a "Save As..." dialog.
694 * If you want to preselect a particular existing file, you should use
695 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead.
696 * Please see the documentation for those functions for an example of using
697 * gtk_file_chooser_set_current_name() as well.
701 * the filename to use, as a UTF-8 string
704 public void setCurrentName(char[] name
)
706 // void gtk_file_chooser_set_current_name (GtkFileChooser *chooser, const gchar *name);
707 gtk_file_chooser_set_current_name(gtkFileChooser
, Str
.toStringz(name
));
711 * Gets the filename for the currently selected file in
712 * the file selector. If multiple files are selected,
713 * one of the filenames will be returned at random.
714 * If the file chooser is in folder mode, this function returns the selected
719 * The currently selected filename, or NULL
720 * if no file is selected, or the selected file can't
721 * be represented with a local filename. Free with g_free().
724 public char[] getFilename()
726 // gchar* gtk_file_chooser_get_filename (GtkFileChooser *chooser);
727 return Str
.toString(gtk_file_chooser_get_filename(gtkFileChooser
) );
731 * Sets filename as the current filename for the file chooser, by changing
732 * to the file's parent folder and actually selecting the file in list. If
733 * the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name
734 * will also appear in the dialog's file name entry.
735 * If the file name isn't in the current folder of chooser, then the current
736 * folder of chooser will be changed to the folder containing filename. This
737 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by
738 * gtk_file_chooser_select_filename().
739 * Note that the file must exist, or nothing will be done except
740 * for the directory change.
741 * If you are implementing a File/Save As... dialog, you
742 * should use this function if you already have a file name to which the user may save; for example,
743 * when the user opens an existing file and then does File/Save As...
744 * on it. If you don't have a file name already for example, if the user just created
745 * a new file and is saving it for the first time, do not call this function. Instead, use
746 * something similar to this:
747 * if (document_is_new)
749 * /+* the user just created a new document +/
750 * gtk_file_chooser_set_current_folder (chooser, default_folder_for_saving);
751 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
755 * /+* the user edited an existing document +/
756 * gtk_file_chooser_set_filename (chooser, existing_filename);
761 * the filename to set as current
763 * TRUE if both the folder could be changed and the file was
764 * selected successfully, FALSE otherwise.
767 public int setFilename(char[] filename
)
769 // gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser, const char *filename);
770 return gtk_file_chooser_set_filename(gtkFileChooser
, Str
.toStringz(filename
));
774 * Selects a filename. If the file name isn't in the current
775 * folder of chooser, then the current folder of chooser will
776 * be changed to the folder containing filename.
780 * the filename to select
782 * TRUE if both the folder could be changed and the file was
783 * selected successfully, FALSE otherwise.
786 public int selectFilename(char[] filename
)
788 // gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser, const char *filename);
789 return gtk_file_chooser_select_filename(gtkFileChooser
, Str
.toStringz(filename
));
793 * Unselects a currently selected filename. If the filename
794 * is not in the current directory, does not exist, or
795 * is otherwise not currently selected, does nothing.
799 * the filename to unselect
802 public void unselectFilename(char[] filename
)
804 // void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser, const char *filename);
805 gtk_file_chooser_unselect_filename(gtkFileChooser
, Str
.toStringz(filename
));
809 * Selects all the files in the current folder of a file chooser.
814 public void selectAll()
816 // void gtk_file_chooser_select_all (GtkFileChooser *chooser);
817 gtk_file_chooser_select_all(gtkFileChooser
);
821 * Unselects all the files in the current folder of a file chooser.
826 public void unselectAll()
828 // void gtk_file_chooser_unselect_all (GtkFileChooser *chooser);
829 gtk_file_chooser_unselect_all(gtkFileChooser
);
833 * Lists all the selected files and subfolders in the current folder of
834 * chooser. The returned names are full absolute paths. If files in the current
835 * folder cannot be represented as local filenames they will be ignored. (See
836 * gtk_file_chooser_get_uris())
840 * a GSList containing the filenames of all selected
841 * files and subfolders in the current folder. Free the returned list
842 * with g_slist_free(), and the filenames with g_free().
845 public ListSG
getFilenames()
847 // GSList* gtk_file_chooser_get_filenames (GtkFileChooser *chooser);
848 return new ListSG( gtk_file_chooser_get_filenames(gtkFileChooser
) );
852 * Sets the current folder for chooser from a local filename.
853 * The user will be shown the full contents of the current folder,
854 * plus user interface elements for navigating to other folders.
858 * the full path of the new current folder
860 * TRUE if the folder could be changed successfully, FALSE
864 public int setCurrentFolder(char[] filename
)
866 // gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser, const gchar *filename);
867 return gtk_file_chooser_set_current_folder(gtkFileChooser
, Str
.toStringz(filename
));
871 * Gets the current folder of chooser as a local filename.
872 * See gtk_file_chooser_set_current_folder().
873 * Note that this is the folder that the file chooser is currently displaying
874 * (e.g. "/home/username/Documents"), which is not the same
875 * as the currently-selected folder if the chooser is in
876 * GTK_FILE_CHOOSER_SELECT_FOLDER mode
877 * (e.g. "/home/username/Documents/selected-folder/". To get the
878 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
879 * usual way to get the selection.
883 * the full path of the current folder, or NULL if the current
884 * path cannot be represented as a local filename. Free with g_free(). This
885 * function will also return NULL if the file chooser was unable to load the
886 * last folder that was requested from it; for example, as would be for calling
887 * gtk_file_chooser_set_current_folder() on a nonexistent folder.
890 public char[] getCurrentFolder()
892 // gchar* gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
893 return Str
.toString(gtk_file_chooser_get_current_folder(gtkFileChooser
) );
897 * Gets the URI for the currently selected file in
898 * the file selector. If multiple files are selected,
899 * one of the filenames will be returned at random.
900 * If the file chooser is in folder mode, this function returns the selected
905 * The currently selected URI, or NULL
906 * if no file is selected. Free with g_free()
909 public char[] getUri()
911 // gchar* gtk_file_chooser_get_uri (GtkFileChooser *chooser);
912 return Str
.toString(gtk_file_chooser_get_uri(gtkFileChooser
) );
916 * Sets the file referred to by uri as the current file for the file chooser,
917 * by changing to the URI's parent folder and actually selecting the URI in the
918 * list. If the chooser is GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base
919 * name will also appear in the dialog's file name entry.
920 * If the URI isn't in the current folder of chooser, then the current folder
921 * of chooser will be changed to the folder containing uri. This is equivalent
922 * to a sequence of gtk_file_chooser_unselect_all() followed by
923 * gtk_file_chooser_select_uri().
924 * Note that the URI must exist, or nothing will be done except
925 * for the directory change.
926 * If you are implementing a File/Save As... dialog, you
927 * should use this function if you already have a file name to which the user may save; for example,
928 * when the user opens an existing file and then does File/Save As...
929 * on it. If you don't have a file name already for example, if the user just created
930 * a new file and is saving it for the first time, do not call this function. Instead, use
931 * something similar to this:
932 * if (document_is_new)
934 * /+* the user just created a new document +/
935 * gtk_file_chooser_set_current_folder_uri (chooser, default_folder_for_saving);
936 * gtk_file_chooser_set_current_name (chooser, "Untitled document");
940 * /+* the user edited an existing document +/
941 * gtk_file_chooser_set_uri (chooser, existing_uri);
946 * the URI to set as current
948 * TRUE if both the folder could be changed and the URI was
949 * selected successfully, FALSE otherwise.
952 public int setUri(char[] uri
)
954 // gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, const char *uri);
955 return gtk_file_chooser_set_uri(gtkFileChooser
, Str
.toStringz(uri
));
959 * Selects the file to by uri. If the URI doesn't refer to a
960 * file in the current folder of chooser, then the current folder of
961 * chooser will be changed to the folder containing filename.
967 * TRUE if both the folder could be changed and the URI was
968 * selected successfully, FALSE otherwise.
971 public int selectUri(char[] uri
)
973 // gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser, const char *uri);
974 return gtk_file_chooser_select_uri(gtkFileChooser
, Str
.toStringz(uri
));
978 * Unselects the file referred to by uri. If the file
979 * is not in the current directory, does not exist, or
980 * is otherwise not currently selected, does nothing.
984 * the URI to unselect
987 public void unselectUri(char[] uri
)
989 // void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser, const char *uri);
990 gtk_file_chooser_unselect_uri(gtkFileChooser
, Str
.toStringz(uri
));
994 * Lists all the selected files and subfolders in the current folder of
995 * chooser. The returned names are full absolute URIs.
999 * a GSList containing the URIs of all selected
1000 * files and subfolders in the current folder. Free the returned list
1001 * with g_slist_free(), and the filenames with g_free().
1004 public ListSG
getUris()
1006 // GSList* gtk_file_chooser_get_uris (GtkFileChooser *chooser);
1007 return new ListSG( gtk_file_chooser_get_uris(gtkFileChooser
) );
1011 * Sets the current folder for chooser from an URI.
1012 * The user will be shown the full contents of the current folder,
1013 * plus user interface elements for navigating to other folders.
1017 * the URI for the new current folder
1019 * TRUE if the folder could be changed successfully, FALSE
1023 public int setCurrentFolderUri(char[] uri
)
1025 // gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser, const gchar *uri);
1026 return gtk_file_chooser_set_current_folder_uri(gtkFileChooser
, Str
.toStringz(uri
));
1030 * Gets the current folder of chooser as an URI.
1031 * See gtk_file_chooser_set_current_folder_uri().
1032 * Note that this is the folder that the file chooser is currently displaying
1033 * (e.g. "file:///home/username/Documents"), which is not the same
1034 * as the currently-selected folder if the chooser is in
1035 * GTK_FILE_CHOOSER_SELECT_FOLDER mode
1036 * (e.g. "file:///home/username/Documents/selected-folder/". To get the
1037 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the
1038 * usual way to get the selection.
1042 * the URI for the current folder. Free with g_free(). This
1043 * function will also return NULL if the file chooser was unable to load the
1044 * last folder that was requested from it; for example, as would be for calling
1045 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder.
1048 public char[] getCurrentFolderUri()
1050 // gchar* gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
1051 return Str
.toString(gtk_file_chooser_get_current_folder_uri(gtkFileChooser
) );
1055 * Sets an application-supplied widget to use to display a custom preview
1056 * of the currently selected file. To implement a preview, after setting the
1057 * preview widget, you connect to the ::update-preview
1058 * signal, and call gtk_file_chooser_get_preview_filename() or
1059 * gtk_file_chooser_get_preview_uri() on each change. If you can
1060 * display a preview of the new file, update your widget and
1061 * set the preview active using gtk_file_chooser_set_preview_widget_active().
1062 * Otherwise, set the preview inactive.
1063 * When there is no application-supplied preview widget, or the
1064 * application-supplied preview widget is not active, the file chooser
1065 * may display an internally generated preview of the current file or
1066 * it may display no preview at all.
1070 * widget for displaying preview.
1073 public void setPreviewWidget(Widget previewWidget
)
1075 // void gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser, GtkWidget *preview_widget);
1076 gtk_file_chooser_set_preview_widget(gtkFileChooser
, (previewWidget
is null) ?
null : previewWidget
.getWidgetStruct());
1080 * Gets the current preview widget; see
1081 * gtk_file_chooser_set_preview_widget().
1085 * the current preview widget, or NULL
1088 public Widget
getPreviewWidget()
1090 // GtkWidget* gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser);
1091 return new Widget( gtk_file_chooser_get_preview_widget(gtkFileChooser
) );
1095 * Sets whether the preview widget set by
1096 * gtk_file_chooser_set_preview_widget() should be shown for the
1097 * current filename. When active is set to false, the file chooser
1098 * may display an internally generated preview of the current file
1099 * or it may display no preview at all. See
1100 * gtk_file_chooser_set_preview_widget() for more details.
1104 * whether to display the user-specified preview widget
1107 public void setPreviewWidgetActive(int active
)
1109 // void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser, gboolean active);
1110 gtk_file_chooser_set_preview_widget_active(gtkFileChooser
, active
);
1114 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget()
1115 * should be shown for the current filename. See
1116 * gtk_file_chooser_set_preview_widget_active().
1120 * TRUE if the preview widget is active for the current filename.
1123 public int getPreviewWidgetActive()
1125 // gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
1126 return gtk_file_chooser_get_preview_widget_active(gtkFileChooser
);
1130 * Sets whether the file chooser should display a stock label with the name of
1131 * the file that is being previewed; the default is TRUE. Applications that
1132 * want to draw the whole preview area themselves should set this to FALSE and
1133 * display the name themselves in their preview widget.
1134 * See also: gtk_file_chooser_set_preview_widget()
1138 * whether to display a stock label with the name of the previewed file
1141 public void setUsePreviewLabel(int useLabel
)
1143 // void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser, gboolean use_label);
1144 gtk_file_chooser_set_use_preview_label(gtkFileChooser
, useLabel
);
1148 * Gets whether a stock label should be drawn with the name of the previewed
1149 * file. See gtk_file_chooser_set_use_preview_label().
1153 * TRUE if the file chooser is set to display a label with the
1154 * name of the previewed file, FALSE otherwise.
1156 public int getUsePreviewLabel()
1158 // gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser);
1159 return gtk_file_chooser_get_use_preview_label(gtkFileChooser
);
1163 * Gets the filename that should be previewed in a custom preview
1164 * widget. See gtk_file_chooser_set_preview_widget().
1168 * the filename to preview, or NULL if no file
1169 * is selected, or if the selected file cannot be represented
1170 * as a local filename. Free with g_free()
1173 public char[] getPreviewFilename()
1175 // char* gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
1176 return Str
.toString(gtk_file_chooser_get_preview_filename(gtkFileChooser
) );
1180 * Gets the URI that should be previewed in a custom preview
1181 * widget. See gtk_file_chooser_set_preview_widget().
1185 * the URI for the file to preview, or NULL if no file is
1186 * selected. Free with g_free().
1189 public char[] getPreviewUri()
1191 // char* gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser);
1192 return Str
.toString(gtk_file_chooser_get_preview_uri(gtkFileChooser
) );
1196 * Sets an application-supplied widget to provide extra options to the user.
1200 * widget for extra options
1203 public void setExtraWidget(Widget extraWidget
)
1205 // void gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser, GtkWidget *extra_widget);
1206 gtk_file_chooser_set_extra_widget(gtkFileChooser
, (extraWidget
is null) ?
null : extraWidget
.getWidgetStruct());
1210 * Gets the current preview widget; see
1211 * gtk_file_chooser_set_extra_widget().
1215 * the current extra widget, or NULL
1218 public Widget
getExtraWidget()
1220 // GtkWidget* gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
1221 return new Widget( gtk_file_chooser_get_extra_widget(gtkFileChooser
) );
1225 * Adds filter to the list of filters that the user can select between.
1226 * When a filter is selected, only files that are passed by that
1227 * filter are displayed.
1228 * Note that the chooser takes ownership of the filter, so you have to
1229 * ref and sink it if you want to keep a reference.
1236 public void addFilter(FileFilter filter
)
1238 // void gtk_file_chooser_add_filter (GtkFileChooser *chooser, GtkFileFilter *filter);
1239 gtk_file_chooser_add_filter(gtkFileChooser
, (filter
is null) ?
null : filter
.getFileFilterStruct());
1243 * Removes filter from the list of filters that the user can select between.
1250 public void removeFilter(FileFilter filter
)
1252 // void gtk_file_chooser_remove_filter (GtkFileChooser *chooser, GtkFileFilter *filter);
1253 gtk_file_chooser_remove_filter(gtkFileChooser
, (filter
is null) ?
null : filter
.getFileFilterStruct());
1257 * Lists the current set of user-selectable filters; see
1258 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter().
1262 * a GSList containing the current set of
1263 * user selectable filters. The contents of the list are
1264 * owned by GTK+, but you must free the list itself with
1265 * g_slist_free() when you are done with it.
1268 public ListSG
listFilters()
1270 // GSList* gtk_file_chooser_list_filters (GtkFileChooser *chooser);
1271 return new ListSG( gtk_file_chooser_list_filters(gtkFileChooser
) );
1275 * Sets the current filter; only the files that pass the
1276 * filter will be displayed. If the user-selectable list of filters
1277 * is non-empty, then the filter should be one of the filters
1278 * in that list. Setting the current filter when the list of
1279 * filters is empty is useful if you want to restrict the displayed
1280 * set of files without letting the user change it.
1287 public void setFilter(FileFilter filter
)
1289 // void gtk_file_chooser_set_filter (GtkFileChooser *chooser, GtkFileFilter *filter);
1290 gtk_file_chooser_set_filter(gtkFileChooser
, (filter
is null) ?
null : filter
.getFileFilterStruct());
1294 * Gets the current filter; see gtk_file_chooser_set_filter().
1298 * the current filter, or NULL
1301 public FileFilter
getFilter()
1303 // GtkFileFilter* gtk_file_chooser_get_filter (GtkFileChooser *chooser);
1304 return new FileFilter( gtk_file_chooser_get_filter(gtkFileChooser
) );
1308 * Adds a folder to be displayed with the shortcut folders in a file chooser.
1309 * Note that shortcut folders do not get saved, as they are provided by the
1310 * application. For example, you can use this to add a
1311 * "/usr/share/mydrawprogram/Clipart" folder to the volume list.
1315 * filename of the folder to add
1317 * location to store error, or NULL
1319 * TRUE if the folder could be added successfully, FALSE
1320 * otherwise. In the latter case, the error will be set as appropriate.
1323 public int addShortcutFolder(char[] folder
, GError
** error
)
1325 // gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser, const char *folder, GError **error);
1326 return gtk_file_chooser_add_shortcut_folder(gtkFileChooser
, Str
.toStringz(folder
), error
);
1330 * Removes a folder from a file chooser's list of shortcut folders.
1334 * filename of the folder to remove
1336 * location to store error, or NULL
1338 * TRUE if the operation succeeds, FALSE otherwise.
1339 * In the latter case, the error will be set as appropriate.
1340 * See also: gtk_file_chooser_add_shortcut_folder()
1343 public int removeShortcutFolder(char[] folder
, GError
** error
)
1345 // gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, const char *folder, GError **error);
1346 return gtk_file_chooser_remove_shortcut_folder(gtkFileChooser
, Str
.toStringz(folder
), error
);
1350 * Queries the list of shortcut folders in the file chooser, as set by
1351 * gtk_file_chooser_add_shortcut_folder().
1355 * A list of folder filenames, or NULL if there are no shortcut
1356 * folders. Free the returned list with g_slist_free(), and the filenames with
1360 public ListSG
listShortcutFolders()
1362 // GSList* gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser);
1363 return new ListSG( gtk_file_chooser_list_shortcut_folders(gtkFileChooser
) );
1367 * Adds a folder URI to be displayed with the shortcut folders in a file
1368 * chooser. Note that shortcut folders do not get saved, as they are provided
1369 * by the application. For example, you can use this to add a
1370 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list.
1374 * URI of the folder to add
1376 * location to store error, or NULL
1378 * TRUE if the folder could be added successfully, FALSE
1379 * otherwise. In the latter case, the error will be set as appropriate.
1382 public int addShortcutFolderUri(char[] uri
, GError
** error
)
1384 // gboolean gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser, const char *uri, GError **error);
1385 return gtk_file_chooser_add_shortcut_folder_uri(gtkFileChooser
, Str
.toStringz(uri
), error
);
1389 * Removes a folder URI from a file chooser's list of shortcut folders.
1393 * URI of the folder to remove
1395 * location to store error, or NULL
1397 * TRUE if the operation succeeds, FALSE otherwise.
1398 * In the latter case, the error will be set as appropriate.
1399 * See also: gtk_file_chooser_add_shortcut_folder_uri()
1402 public int removeShortcutFolderUri(char[] uri
, GError
** error
)
1404 // gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser, const char *uri, GError **error);
1405 return gtk_file_chooser_remove_shortcut_folder_uri(gtkFileChooser
, Str
.toStringz(uri
), error
);
1409 * Queries the list of shortcut folders in the file chooser, as set by
1410 * gtk_file_chooser_add_shortcut_folder_uri().
1414 * A list of folder URIs, or NULL if there are no shortcut
1415 * folders. Free the returned list with g_slist_free(), and the URIs with
1419 * The "action" property
1420 * "action" GtkFileChooserAction : Read / Write
1421 * The type of operation that the file selector is performing.
1422 * Default value: GTK_FILE_CHOOSER_ACTION_OPEN
1424 public ListSG
listShortcutFolderUris()
1426 // GSList* gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser);
1427 return new ListSG( gtk_file_chooser_list_shortcut_folder_uris(gtkFileChooser
) );