1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GtkFileChooser.html 27 * outPack = gtk 28 * outFile = FileChooserT 29 * strct = GtkFileChooser 30 * realStrct= 31 * ctorStrct= 32 * clss = FileChooserT 33 * interf = FileChooserIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * - TStruct 38 * extend = 39 * implements: 40 * prefixes: 41 * - gtk_file_chooser_ 42 * - gtk_ 43 * omit structs: 44 * omit prefixes: 45 * omit code: 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - glib.ErrorG 50 * - glib.GException 51 * - gio.File 52 * - gtk.Window 53 * - glib.ListSG 54 * - gtk.Widget 55 * - gtk.FileFilter 56 * structWrap: 57 * - GFile* -> File 58 * - GSList* -> ListSG 59 * - GtkFileFilter* -> FileFilter 60 * - GtkWidget* -> Widget 61 * - GtkWindow* -> Window 62 * module aliases: 63 * local aliases: 64 * - getAction -> getFileChooserAction 65 * - setAction -> setFileChooserAction 66 * overrides: 67 */ 68 69 module gtk.FileChooserT; 70 71 public import gtkc.gtktypes; 72 73 public import gtkc.gtk; 74 public import glib.ConstructionException; 75 public import gobject.ObjectG; 76 77 public import gobject.Signals; 78 public import gtkc.gdktypes; 79 80 public import glib.Str; 81 public import glib.ErrorG; 82 public import glib.GException; 83 public import gio.File; 84 public import gtk.Window; 85 public import glib.ListSG; 86 public import gtk.Widget; 87 public import gtk.FileFilter; 88 89 90 91 92 /** 93 * Description 94 * GtkFileChooser is an interface that can be implemented by file 95 * selection widgets. In GTK+, the main objects that implement this 96 * interface are GtkFileChooserWidget, GtkFileChooserDialog, and 97 * GtkFileChooserButton. You do not need to write an object that 98 * implements the GtkFileChooser interface unless you are trying to 99 * adapt an existing file selector to expose a standard programming 100 * interface. 101 * GtkFileChooser allows for shortcuts to various places in the filesystem. 102 * In the default implementation these are displayed in the left pane. It 103 * may be a bit confusing at first taht these shortcuts come from various 104 * sources and in various flavours, so lets explain the terminology here: 105 * Bookmarks 106 * are created by the user, by dragging folders from the 107 * right pane to the left pane, or by using the "Add". Bookmarks 108 * can be renamed and deleted by the user. 109 * Shortcuts 110 * can be provided by the application or by the underlying filesystem 111 * abstraction (e.g. both the gnome-vfs and the Windows filesystems 112 * provide "Desktop" shortcuts). Shortcuts cannot be modified by the 113 * user. 114 * Volumes 115 * are provided by the underlying filesystem abstraction. They are 116 * the "roots" of the filesystem. 117 * File Names and Encodings 118 * When the user is finished selecting files in a 119 * GtkFileChooser, your program can get the selected names 120 * either as filenames or as URIs. For URIs, the normal escaping 121 * rules are applied if the URI contains non-ASCII characters. 122 * However, filenames are always returned in 123 * the character set specified by the 124 * G_FILENAME_ENCODING environment variable. 125 * Please see the Glib documentation for more details about this 126 * variable. 127 * Note 128 * This means that while you can pass the result of 129 * gtk_file_chooser_get_filename() to 130 * open(2) or 131 * fopen(3), you may not be able to 132 * directly set it as the text of a GtkLabel widget unless you 133 * convert it first to UTF-8, which all GTK+ widgets expect. 134 * You should use g_filename_to_utf8() to convert filenames 135 * into strings that can be passed to GTK+ widgets. 136 * <hr> 137 * Adding a Preview Widget 138 * You can add a custom preview widget to a file chooser and then 139 * get notification about when the preview needs to be updated. 140 * To install a preview widget, use 141 * gtk_file_chooser_set_preview_widget(). Then, connect to the 142 * "update-preview" signal to get notified when 143 * you need to update the contents of the preview. 144 * Your callback should use 145 * gtk_file_chooser_get_preview_filename() to see what needs 146 * previewing. Once you have generated the preview for the 147 * corresponding file, you must call 148 * gtk_file_chooser_set_preview_widget_active() with a boolean 149 * flag that indicates whether your callback could successfully 150 * generate a preview. 151 * $(DDOC_COMMENT example) 152 * <hr> 153 * Adding Extra Widgets 154 * You can add extra widgets to a file chooser to provide options 155 * that are not present in the default design. For example, you 156 * can add a toggle button to give the user the option to open a 157 * file in read-only mode. You can use 158 * gtk_file_chooser_set_extra_widget() to insert additional 159 * widgets in a file chooser. 160 * $(DDOC_COMMENT example) 161 * Note 162 * If you want to set more than one extra widget in the file 163 * chooser, you can a container such as a GtkVBox or a GtkTable 164 * and include your widgets in it. Then, set the container as 165 * the whole extra widget. 166 * <hr> 167 * Key Bindings 168 * Internally, GTK+ implements a file chooser's graphical user 169 * interface with the private 170 * GtkFileChooserDefaultClass. This 171 * widget has several key 172 * bindings and their associated signals. This section 173 * describes the available key binding signals. 174 * $(DDOC_COMMENT example) 175 * You can change these defaults to something else. For 176 * example, to add a Shift modifier to a few 177 * of the default bindings, you can include the following 178 * fragment in your .gtkrc-2.0 file: 179 * binding "my-own-gtkfilechooser-bindings" { 180 * bind "<Alt><Shift>Up" { 181 * "up-folder" () 182 * } 183 * bind "<Alt><Shift>Down" { 184 * "down-folder" () 185 * } 186 * bind "<Alt><Shift>Home" { 187 * "home-folder" () 188 * } 189 * } 190 * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings" 191 * The "GtkFileChooserDefault::location-popup" signal 192 * void user_function (GtkFileChooserDefault *chooser, 193 * const char *path, 194 * gpointer user_data); 195 * This is used to make the file chooser show a "Location" 196 * dialog which the user can use to manually type the name of 197 * the file he wishes to select. The 198 * path argument is a string that gets 199 * put in the text entry for the file name. By default this is bound to 200 * Control+L 201 * with a path string of "" (the empty 202 * string). It is also bound to / with a 203 * path string of "/" 204 * (a slash): this lets you type / and 205 * immediately type a path name. On Unix systems, this is bound to 206 * ~ (tilde) with a path string 207 * of "~" itself for access to home directories. 208 * chooser : 209 * the object which received the signal. 210 * path : 211 * default contents for the text entry for the file name 212 * user_data : 213 * user data set when the signal handler was connected. 214 * Note 215 * You can create your own bindings for the 216 * GtkFileChooserDefault::location-popup signal with custom 217 * path strings, and have a crude form 218 * of easily-to-type bookmarks. For example, say you access 219 * the path /home/username/misc very 220 * frequently. You could then create an Alt+M 221 * shortcut by including the following in your 222 * .gtkrc-2.0: 223 * binding "misc-shortcut" { 224 * bind "<Alt>M" { 225 * "location-popup" ("/home/username/misc") 226 * } 227 * } 228 * class "GtkFileChooserDefault" binding "misc-shortcut" 229 * The "GtkFileChooserDefault::up-folder" signal 230 * void user_function (GtkFileChooserDefault *chooser, 231 * gpointer user_data); 232 * This is used to make the file chooser go to the parent of 233 * the current folder in the file hierarchy. By default this 234 * is bound to Backspace and 235 * Alt+Up 236 * (the Up key in the numeric keypad also works). 237 * chooser : 238 * the object which received the signal. 239 * user_data : 240 * user data set when the signal handler was connected. 241 * The "GtkFileChooserDefault::down-folder" signal 242 * void user_function (GtkFileChooserDefault *chooser, 243 * gpointer user_data); 244 * This is used to make the file chooser go to a child of the 245 * current folder in the file hierarchy. The subfolder that 246 * will be used is displayed in the path bar widget of the file 247 * chooser. For example, if the path bar is showing 248 * "/foo/bar/baz", then this will cause 249 * the file chooser to switch to the "baz" subfolder. By 250 * default this is bound to 251 * Alt+Down 252 * (the Down key in the numeric keypad also works). 253 * chooser : 254 * the object which received the signal. 255 * user_data : 256 * user data set when the signal handler was connected. 257 * The "GtkFileChooserDefault::home-folder" signal 258 * void user_function (GtkFileChooserDefault *chooser, 259 * gpointer user_data); 260 * This is used to make the file chooser show the user's home 261 * folder in the file list. By default this is bound to 262 * Alt+Home 263 * (the Home key in the numeric keypad also works). 264 * chooser : 265 * the object which received the signal. 266 * user_data : 267 * user data set when the signal handler was connected. 268 * The "GtkFileChooserDefault::desktop-folder" signal 269 * void user_function (GtkFileChooserDefault *chooser, 270 * gpointer user_data); 271 * This is used to make the file chooser show the user's Desktop 272 * folder in the file list. By default this is bound to 273 * Alt+D. 274 * chooser : 275 * the object which received the signal. 276 * user_data : 277 * user data set when the signal handler was connected. 278 * The "GtkFileChooserDefault::quick-bookmark" signal 279 * void user_function (GtkFileChooserDefault *chooser, 280 * gint bookmark_index, 281 * gpointer user_data); 282 * This is used to make the file chooser switch to the bookmark 283 * specified in the bookmark_index parameter. 284 * For example, if you have three bookmarks, you can pass 0, 1, 2 to 285 * this signal to switch to each of them, respectively. By default this is bound to 286 * Alt+1, 287 * Alt+2, 288 * etc. until 289 * Alt+0. Note 290 * that in the default binding, 291 * that Alt+1 is 292 * actually defined to switch to the bookmark at index 0, and so on 293 * successively; 294 * Alt+0 is 295 * defined to switch to the bookmark at index 10. 296 * chooser : 297 * the object which received the signal. 298 * bookmark_indes : 299 * index of the bookmark to switch to; the indices start at 0. 300 * user_data : 301 * user data set when the signal handler was connected. 302 */ 303 public template FileChooserT(TStruct) 304 { 305 306 /** the main Gtk struct */ 307 protected GtkFileChooser* gtkFileChooser; 308 309 310 public GtkFileChooser* getFileChooserTStruct() 311 { 312 return cast(GtkFileChooser*)getStruct(); 313 } 314 315 316 /** 317 */ 318 int[string] connectedSignals; 319 320 GtkFileChooserConfirmation delegate(FileChooserIF)[] _onConfirmOverwriteListeners; 321 GtkFileChooserConfirmation delegate(FileChooserIF)[] onConfirmOverwriteListeners() 322 { 323 return _onConfirmOverwriteListeners; 324 } 325 /** 326 * This signal gets emitted whenever it is appropriate to present a 327 * confirmation dialog when the user has selected a file name that 328 * already exists. The signal only gets emitted when the file 329 * chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode. 330 * Most applications just need to turn on the 331 * "do-overwrite-confirmation" property (or call the 332 * gtk_file_chooser_set_do_overwrite_confirmation() function), and 333 * they will automatically get a stock confirmation dialog. 334 * Applications which need to customize this behavior should do 335 * that, and also connect to the "confirm-overwrite" 336 * signal. 337 * A signal handler for this signal must return a 338 * GtkFileChooserConfirmation value, which indicates the action to 339 * take. If the handler determines that the user wants to select a 340 * different filename, it should return 341 * GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines 342 * that the user is satisfied with his choice of file name, it 343 * should return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME. 344 * On the other hand, if it determines that the stock confirmation 345 * dialog should be used, it should return 346 * GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example 347 * illustrates this. 348 * $(DDOC_COMMENT example) 349 * 350 * Since 2.8 351 */ 352 void addOnConfirmOverwrite(GtkFileChooserConfirmation delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 353 { 354 if ( !("confirm-overwrite" in connectedSignals) ) 355 { 356 Signals.connectData( 357 getStruct(), 358 "confirm-overwrite", 359 cast(GCallback)&callBackConfirmOverwrite, 360 cast(void*)cast(FileChooserIF)this, 361 null, 362 connectFlags); 363 connectedSignals["confirm-overwrite"] = 1; 364 } 365 _onConfirmOverwriteListeners ~= dlg; 366 } 367 extern(C) static void callBackConfirmOverwrite(GtkFileChooser* chooserStruct, FileChooserIF _fileChooserIF) 368 { 369 foreach ( GtkFileChooserConfirmation delegate(FileChooserIF) dlg ; _fileChooserIF.onConfirmOverwriteListeners ) 370 { 371 dlg(_fileChooserIF); 372 } 373 } 374 375 void delegate(FileChooserIF)[] _onCurrentFolderChangedListeners; 376 void delegate(FileChooserIF)[] onCurrentFolderChangedListeners() 377 { 378 return _onCurrentFolderChangedListeners; 379 } 380 /** 381 * This signal is emitted when the current folder in a GtkFileChooser 382 * changes. This can happen due to the user performing some action that 383 * changes folders, such as selecting a bookmark or visiting a folder on the 384 * file list. It can also happen as a result of calling a function to 385 * explicitly change the current folder in a file chooser. 386 * Normally you do not need to connect to this signal, unless you need to keep 387 * track of which folder a file chooser is showing. 388 * See also: gtk_file_chooser_set_current_folder(), 389 * gtk_file_chooser_get_current_folder(), 390 * gtk_file_chooser_set_current_folder_uri(), 391 * gtk_file_chooser_get_current_folder_uri(). 392 */ 393 void addOnCurrentFolderChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 394 { 395 if ( !("current-folder-changed" in connectedSignals) ) 396 { 397 Signals.connectData( 398 getStruct(), 399 "current-folder-changed", 400 cast(GCallback)&callBackCurrentFolderChanged, 401 cast(void*)cast(FileChooserIF)this, 402 null, 403 connectFlags); 404 connectedSignals["current-folder-changed"] = 1; 405 } 406 _onCurrentFolderChangedListeners ~= dlg; 407 } 408 extern(C) static void callBackCurrentFolderChanged(GtkFileChooser* chooserStruct, FileChooserIF _fileChooserIF) 409 { 410 foreach ( void delegate(FileChooserIF) dlg ; _fileChooserIF.onCurrentFolderChangedListeners ) 411 { 412 dlg(_fileChooserIF); 413 } 414 } 415 416 void delegate(FileChooserIF)[] _onFileActivatedListeners; 417 void delegate(FileChooserIF)[] onFileActivatedListeners() 418 { 419 return _onFileActivatedListeners; 420 } 421 /** 422 * This signal is emitted when the user "activates" a file in the file 423 * chooser. This can happen by double-clicking on a file in the file list, or 424 * by pressing Enter. 425 * Normally you do not need to connect to this signal. It is used internally 426 * by GtkFileChooserDialog to know when to activate the default button in the 427 * dialog. 428 * See also: gtk_file_chooser_get_filename(), 429 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(), 430 * gtk_file_chooser_get_uris(). 431 */ 432 void addOnFileActivated(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 433 { 434 if ( !("file-activated" in connectedSignals) ) 435 { 436 Signals.connectData( 437 getStruct(), 438 "file-activated", 439 cast(GCallback)&callBackFileActivated, 440 cast(void*)cast(FileChooserIF)this, 441 null, 442 connectFlags); 443 connectedSignals["file-activated"] = 1; 444 } 445 _onFileActivatedListeners ~= dlg; 446 } 447 extern(C) static void callBackFileActivated(GtkFileChooser* chooserStruct, FileChooserIF _fileChooserIF) 448 { 449 foreach ( void delegate(FileChooserIF) dlg ; _fileChooserIF.onFileActivatedListeners ) 450 { 451 dlg(_fileChooserIF); 452 } 453 } 454 455 void delegate(FileChooserIF)[] _onSelectionChangedListeners; 456 void delegate(FileChooserIF)[] onSelectionChangedListeners() 457 { 458 return _onSelectionChangedListeners; 459 } 460 /** 461 * This signal is emitted when there is a change in the set of selected files 462 * in a GtkFileChooser. This can happen when the user modifies the selection 463 * with the mouse or the keyboard, or when explicitly calling functions to 464 * change the selection. 465 * Normally you do not need to connect to this signal, as it is easier to wait 466 * for the file chooser to finish running, and then to get the list of 467 * selected files using the functions mentioned below. 468 * See also: gtk_file_chooser_select_filename(), 469 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(), 470 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(), 471 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(), 472 * gtk_file_chooser_get_uris(). 473 */ 474 void addOnSelectionChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 475 { 476 if ( !("selection-changed" in connectedSignals) ) 477 { 478 Signals.connectData( 479 getStruct(), 480 "selection-changed", 481 cast(GCallback)&callBackSelectionChanged, 482 cast(void*)cast(FileChooserIF)this, 483 null, 484 connectFlags); 485 connectedSignals["selection-changed"] = 1; 486 } 487 _onSelectionChangedListeners ~= dlg; 488 } 489 extern(C) static void callBackSelectionChanged(GtkFileChooser* chooserStruct, FileChooserIF _fileChooserIF) 490 { 491 foreach ( void delegate(FileChooserIF) dlg ; _fileChooserIF.onSelectionChangedListeners ) 492 { 493 dlg(_fileChooserIF); 494 } 495 } 496 497 void delegate(FileChooserIF)[] _onUpdatePreviewListeners; 498 void delegate(FileChooserIF)[] onUpdatePreviewListeners() 499 { 500 return _onUpdatePreviewListeners; 501 } 502 /** 503 * This signal is emitted when the preview in a file chooser should be 504 * regenerated. For example, this can happen when the currently selected file 505 * changes. You should use this signal if you want your file chooser to have 506 * a preview widget. 507 * Once you have installed a preview widget with 508 * gtk_file_chooser_set_preview_widget(), you should update it when this 509 * signal is emitted. You can use the functions 510 * gtk_file_chooser_get_preview_filename() or 511 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview. 512 * Your widget may not be able to preview all kinds of files; your callback 513 * must call gtk_file_chooser_set_preview_widget_active() to inform the file 514 * chooser about whether the preview was generated successfully or not. 515 * Please see the example code in the section called “Adding a Preview Widget”. 516 * See also: gtk_file_chooser_set_preview_widget(), 517 * gtk_file_chooser_set_preview_widget_active(), 518 * gtk_file_chooser_set_use_preview_label(), 519 * gtk_file_chooser_get_preview_filename(), 520 * gtk_file_chooser_get_preview_uri(). 521 * See Also 522 * GtkFileChooserDialog, GtkFileChooserWidget, GtkFileChooserButton 523 */ 524 void addOnUpdatePreview(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 525 { 526 if ( !("update-preview" in connectedSignals) ) 527 { 528 Signals.connectData( 529 getStruct(), 530 "update-preview", 531 cast(GCallback)&callBackUpdatePreview, 532 cast(void*)cast(FileChooserIF)this, 533 null, 534 connectFlags); 535 connectedSignals["update-preview"] = 1; 536 } 537 _onUpdatePreviewListeners ~= dlg; 538 } 539 extern(C) static void callBackUpdatePreview(GtkFileChooser* chooserStruct, FileChooserIF _fileChooserIF) 540 { 541 foreach ( void delegate(FileChooserIF) dlg ; _fileChooserIF.onUpdatePreviewListeners ) 542 { 543 dlg(_fileChooserIF); 544 } 545 } 546 547 548 /** 549 * Sets the type of operation that the chooser is performing; the 550 * user interface is adapted to suit the selected action. For example, 551 * an option to create a new folder might be shown if the action is 552 * GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is 553 * GTK_FILE_CHOOSER_ACTION_OPEN. 554 * Since 2.4 555 * Params: 556 * action = the action that the file selector is performing 557 */ 558 public void setFileChooserAction(GtkFileChooserAction action) 559 { 560 // void gtk_file_chooser_set_action (GtkFileChooser *chooser, GtkFileChooserAction action); 561 gtk_file_chooser_set_action(getFileChooserTStruct(), action); 562 } 563 564 /** 565 * Gets the type of operation that the file chooser is performing; see 566 * gtk_file_chooser_set_action(). 567 * Since 2.4 568 * Returns: the action that the file selector is performing 569 */ 570 public GtkFileChooserAction getFileChooserAction() 571 { 572 // GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser); 573 return gtk_file_chooser_get_action(getFileChooserTStruct()); 574 } 575 576 /** 577 * Sets whether only local files can be selected in the 578 * file selector. If local_only is TRUE (the default), 579 * then the selected file are files are guaranteed to be 580 * accessible through the operating systems native file 581 * file system and therefore the application only 582 * needs to worry about the filename functions in 583 * GtkFileChooser, like gtk_file_chooser_get_filename(), 584 * rather than the URI functions like 585 * gtk_file_chooser_get_uri(), 586 * Since 2.4 587 * Params: 588 * localOnly = TRUE if only local files can be selected 589 */ 590 public void setLocalOnly(int localOnly) 591 { 592 // void gtk_file_chooser_set_local_only (GtkFileChooser *chooser, gboolean local_only); 593 gtk_file_chooser_set_local_only(getFileChooserTStruct(), localOnly); 594 } 595 596 /** 597 * Gets whether only local files can be selected in the 598 * file selector. See gtk_file_chooser_set_local_only() 599 * Since 2.4 600 * Returns: TRUE if only local files can be selected. 601 */ 602 public int getLocalOnly() 603 { 604 // gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser); 605 return gtk_file_chooser_get_local_only(getFileChooserTStruct()); 606 } 607 608 /** 609 * Sets whether multiple files can be selected in the file selector. This is 610 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or 611 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER. 612 * Since 2.4 613 * Params: 614 * selectMultiple = TRUE if multiple files can be selected. 615 */ 616 public void setSelectMultiple(int selectMultiple) 617 { 618 // void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser, gboolean select_multiple); 619 gtk_file_chooser_set_select_multiple(getFileChooserTStruct(), selectMultiple); 620 } 621 622 /** 623 * Gets whether multiple files can be selected in the file 624 * selector. See gtk_file_chooser_set_select_multiple(). 625 * Since 2.4 626 * Returns: TRUE if multiple files can be selected. 627 */ 628 public int getSelectMultiple() 629 { 630 // gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser); 631 return gtk_file_chooser_get_select_multiple(getFileChooserTStruct()); 632 } 633 634 /** 635 * Sets whether hidden files and folders are displayed in the file selector. 636 * Since 2.6 637 * Params: 638 * showHidden = TRUE if hidden files and folders should be displayed. 639 */ 640 public void setShowHidden(int showHidden) 641 { 642 // void gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser, gboolean show_hidden); 643 gtk_file_chooser_set_show_hidden(getFileChooserTStruct(), showHidden); 644 } 645 646 /** 647 * Gets whether hidden files and folders are displayed in the file selector. 648 * See gtk_file_chooser_set_show_hidden(). 649 * Since 2.6 650 * Returns: TRUE if hidden files and folders are displayed. 651 */ 652 public int getShowHidden() 653 { 654 // gboolean gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser); 655 return gtk_file_chooser_get_show_hidden(getFileChooserTStruct()); 656 } 657 658 /** 659 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present 660 * a confirmation dialog if the user types a file name that already exists. This 661 * is FALSE by default. 662 * Regardless of this setting, the chooser will emit the 663 * "confirm-overwrite" signal when appropriate. 664 * If all you need is the stock confirmation dialog, set this property to TRUE. 665 * You can override the way confirmation is done by actually handling the 666 * "confirm-overwrite" signal; please refer to its documentation 667 * for the details. 668 * Since 2.8 669 * Params: 670 * doOverwriteConfirmation = whether to confirm overwriting in save mode 671 */ 672 public void setDoOverwriteConfirmation(int doOverwriteConfirmation) 673 { 674 // void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser, gboolean do_overwrite_confirmation); 675 gtk_file_chooser_set_do_overwrite_confirmation(getFileChooserTStruct(), doOverwriteConfirmation); 676 } 677 678 /** 679 * Queries whether a file chooser is set to confirm for overwriting when the user 680 * types a file name that already exists. 681 * Since 2.8 682 * Returns: TRUE if the file chooser will present a confirmation dialog; FALSE otherwise. 683 */ 684 public int getDoOverwriteConfirmation() 685 { 686 // gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser); 687 return gtk_file_chooser_get_do_overwrite_confirmation(getFileChooserTStruct()); 688 } 689 690 /** 691 * Sets whether file choser will offer to create new folders. 692 * This is only relevant if the action is not set to be 693 * GTK_FILE_CHOOSER_ACTION_OPEN. 694 * Since 2.18 695 * Params: 696 * createFolders = TRUE if the New Folder button should be displayed 697 */ 698 public void setCreateFolders(int createFolders) 699 { 700 // void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser, gboolean create_folders); 701 gtk_file_chooser_set_create_folders(getFileChooserTStruct(), createFolders); 702 } 703 704 /** 705 * Gets whether file choser will offer to create new folders. 706 * See gtk_file_chooser_set_create_folders(). 707 * Since 2.18 708 * Returns: TRUE if the New Folder button should be displayed. 709 */ 710 public int getCreateFolders() 711 { 712 // gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser); 713 return gtk_file_chooser_get_create_folders(getFileChooserTStruct()); 714 } 715 716 /** 717 * Sets the current name in the file selector, as if entered 718 * by the user. Note that the name passed in here is a UTF-8 719 * string rather than a filename. This function is meant for 720 * such uses as a suggested name in a "Save As..." dialog. 721 * If you want to preselect a particular existing file, you should use 722 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead. 723 * Please see the documentation for those functions for an example of using 724 * gtk_file_chooser_set_current_name() as well. 725 * Since 2.4 726 * Params: 727 * name = the filename to use, as a UTF-8 string 728 */ 729 public void setCurrentName(string name) 730 { 731 // void gtk_file_chooser_set_current_name (GtkFileChooser *chooser, const gchar *name); 732 gtk_file_chooser_set_current_name(getFileChooserTStruct(), Str.toStringz(name)); 733 } 734 735 /** 736 * Gets the filename for the currently selected file in 737 * the file selector. If multiple files are selected, 738 * one of the filenames will be returned at random. 739 * If the file chooser is in folder mode, this function returns the selected 740 * folder. 741 * Since 2.4 742 * Returns: The currently selected filename, or NULL if no file is selected, or the selected file can't be represented with a local filename. Free with g_free(). 743 */ 744 public string getFilename() 745 { 746 // gchar * gtk_file_chooser_get_filename (GtkFileChooser *chooser); 747 return Str.toString(gtk_file_chooser_get_filename(getFileChooserTStruct())); 748 } 749 750 /** 751 * Sets filename as the current filename for the file chooser, by changing 752 * to the file's parent folder and actually selecting the file in list. If 753 * the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name 754 * will also appear in the dialog's file name entry. 755 * If the file name isn't in the current folder of chooser, then the current 756 * folder of chooser will be changed to the folder containing filename. This 757 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by 758 * gtk_file_chooser_select_filename(). 759 * Note that the file must exist, or nothing will be done except 760 * for the directory change. 761 * If you are implementing a File/Save As... dialog, 762 * you should use this function if you already have a file name to which the 763 * user may save; for example, when the user opens an existing file and then 764 * does File/Save As... on it. If you don't have 765 * a file name already — for example, if the user just created a new 766 * file and is saving it for the first time, do not call this function. 767 * Since 2.4 768 * Params: 769 * filename = the filename to set as current 770 * Returns: TRUE if both the folder could be changed and the file was selected successfully, FALSE otherwise. 771 */ 772 public int setFilename(string filename) 773 { 774 // gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser, const char *filename); 775 return gtk_file_chooser_set_filename(getFileChooserTStruct(), Str.toStringz(filename)); 776 } 777 778 /** 779 * Selects a filename. If the file name isn't in the current 780 * folder of chooser, then the current folder of chooser will 781 * be changed to the folder containing filename. 782 * Since 2.4 783 * Params: 784 * filename = the filename to select 785 * Returns: TRUE if both the folder could be changed and the file was selected successfully, FALSE otherwise. 786 */ 787 public int selectFilename(string filename) 788 { 789 // gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser, const char *filename); 790 return gtk_file_chooser_select_filename(getFileChooserTStruct(), Str.toStringz(filename)); 791 } 792 793 /** 794 * Unselects a currently selected filename. If the filename 795 * is not in the current directory, does not exist, or 796 * is otherwise not currently selected, does nothing. 797 * Since 2.4 798 * Params: 799 * filename = the filename to unselect 800 */ 801 public void unselectFilename(string filename) 802 { 803 // void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser, const char *filename); 804 gtk_file_chooser_unselect_filename(getFileChooserTStruct(), Str.toStringz(filename)); 805 } 806 807 /** 808 * Selects all the files in the current folder of a file chooser. 809 * Since 2.4 810 */ 811 public void selectAll() 812 { 813 // void gtk_file_chooser_select_all (GtkFileChooser *chooser); 814 gtk_file_chooser_select_all(getFileChooserTStruct()); 815 } 816 817 /** 818 * Unselects all the files in the current folder of a file chooser. 819 * Since 2.4 820 */ 821 public void unselectAll() 822 { 823 // void gtk_file_chooser_unselect_all (GtkFileChooser *chooser); 824 gtk_file_chooser_unselect_all(getFileChooserTStruct()); 825 } 826 827 /** 828 * Lists all the selected files and subfolders in the current folder of 829 * chooser. The returned names are full absolute paths. If files in the current 830 * folder cannot be represented as local filenames they will be ignored. (See 831 * gtk_file_chooser_get_uris()) 832 * Since 2.4 833 * Returns: a GSList containing the filenames of all selected files and subfolders in the current folder. Free the returned list with g_slist_free(), and the filenames with g_free(). [element-type utf8][transfer full utf8] 834 */ 835 public ListSG getFilenames() 836 { 837 // GSList * gtk_file_chooser_get_filenames (GtkFileChooser *chooser); 838 auto p = gtk_file_chooser_get_filenames(getFileChooserTStruct()); 839 840 if(p is null) 841 { 842 return null; 843 } 844 845 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 846 } 847 848 /** 849 * Sets the current folder for chooser from a local filename. 850 * The user will be shown the full contents of the current folder, 851 * plus user interface elements for navigating to other folders. 852 * Since 2.4 853 * Params: 854 * filename = the full path of the new current folder 855 * Returns: TRUE if the folder could be changed successfully, FALSE otherwise. 856 */ 857 public int setCurrentFolder(string filename) 858 { 859 // gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser, const gchar *filename); 860 return gtk_file_chooser_set_current_folder(getFileChooserTStruct(), Str.toStringz(filename)); 861 } 862 863 /** 864 * Gets the current folder of chooser as a local filename. 865 * See gtk_file_chooser_set_current_folder(). 866 * Note that this is the folder that the file chooser is currently displaying 867 * (e.g. "/home/username/Documents"), which is not the same 868 * as the currently-selected folder if the chooser is in 869 * GTK_FILE_CHOOSER_SELECT_FOLDER mode 870 * (e.g. "/home/username/Documents/selected-folder/". To get the 871 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 872 * usual way to get the selection. 873 * Since 2.4 874 * Returns: the full path of the current folder, or NULL if the current path cannot be represented as a local filename. Free with g_free(). This function will also return NULL if the file chooser was unable to load the last folder that was requested from it; for example, as would be for calling gtk_file_chooser_set_current_folder() on a nonexistent folder. 875 */ 876 public string getCurrentFolder() 877 { 878 // gchar * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser); 879 return Str.toString(gtk_file_chooser_get_current_folder(getFileChooserTStruct())); 880 } 881 882 /** 883 * Gets the URI for the currently selected file in 884 * the file selector. If multiple files are selected, 885 * one of the filenames will be returned at random. 886 * If the file chooser is in folder mode, this function returns the selected 887 * folder. 888 * Since 2.4 889 * Returns: The currently selected URI, or NULL if no file is selected. Free with g_free() 890 */ 891 public string getUri() 892 { 893 // gchar * gtk_file_chooser_get_uri (GtkFileChooser *chooser); 894 return Str.toString(gtk_file_chooser_get_uri(getFileChooserTStruct())); 895 } 896 897 /** 898 * Sets the file referred to by uri as the current file for the file chooser, 899 * by changing to the URI's parent folder and actually selecting the URI in the 900 * list. If the chooser is GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base 901 * name will also appear in the dialog's file name entry. 902 * If the URI isn't in the current folder of chooser, then the current folder 903 * of chooser will be changed to the folder containing uri. This is equivalent 904 * to a sequence of gtk_file_chooser_unselect_all() followed by 905 * gtk_file_chooser_select_uri(). 906 * Note that the URI must exist, or nothing will be done except for the 907 * directory change. 908 * If you are implementing a File/Save As... dialog, 909 * you should use this function if you already have a file name to which the 910 * user may save; for example, when the user opens an existing file and then 911 * does File/Save As... on it. If you don't have 912 * a file name already — for example, if the user just created a new 913 * file and is saving it for the first time, do not call this function. 914 * Since 2.4 915 * Params: 916 * uri = the URI to set as current 917 * Returns: TRUE if both the folder could be changed and the URI was selected successfully, FALSE otherwise. 918 */ 919 public int setUri(string uri) 920 { 921 // gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser, const char *uri); 922 return gtk_file_chooser_set_uri(getFileChooserTStruct(), Str.toStringz(uri)); 923 } 924 925 /** 926 * Selects the file to by uri. If the URI doesn't refer to a 927 * file in the current folder of chooser, then the current folder of 928 * chooser will be changed to the folder containing filename. 929 * Since 2.4 930 * Params: 931 * uri = the URI to select 932 * Returns: TRUE if both the folder could be changed and the URI was selected successfully, FALSE otherwise. 933 */ 934 public int selectUri(string uri) 935 { 936 // gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser, const char *uri); 937 return gtk_file_chooser_select_uri(getFileChooserTStruct(), Str.toStringz(uri)); 938 } 939 940 /** 941 * Unselects the file referred to by uri. If the file 942 * is not in the current directory, does not exist, or 943 * is otherwise not currently selected, does nothing. 944 * Since 2.4 945 * Params: 946 * uri = the URI to unselect 947 */ 948 public void unselectUri(string uri) 949 { 950 // void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser, const char *uri); 951 gtk_file_chooser_unselect_uri(getFileChooserTStruct(), Str.toStringz(uri)); 952 } 953 954 /** 955 * Lists all the selected files and subfolders in the current folder of 956 * chooser. The returned names are full absolute URIs. 957 * Since 2.4 958 * Returns: a GSList containing the URIs of all selected files and subfolders in the current folder. Free the returned list with g_slist_free(), and the filenames with g_free(). [element-type utf8][transfer full utf8] 959 */ 960 public ListSG getUris() 961 { 962 // GSList * gtk_file_chooser_get_uris (GtkFileChooser *chooser); 963 auto p = gtk_file_chooser_get_uris(getFileChooserTStruct()); 964 965 if(p is null) 966 { 967 return null; 968 } 969 970 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 971 } 972 973 /** 974 * Sets the current folder for chooser from an URI. 975 * The user will be shown the full contents of the current folder, 976 * plus user interface elements for navigating to other folders. 977 * Since 2.4 978 * Params: 979 * uri = the URI for the new current folder 980 * Returns: TRUE if the folder could be changed successfully, FALSE otherwise. 981 */ 982 public int setCurrentFolderUri(string uri) 983 { 984 // gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser, const gchar *uri); 985 return gtk_file_chooser_set_current_folder_uri(getFileChooserTStruct(), Str.toStringz(uri)); 986 } 987 988 /** 989 * Gets the current folder of chooser as an URI. 990 * See gtk_file_chooser_set_current_folder_uri(). 991 * Note that this is the folder that the file chooser is currently displaying 992 * (e.g. "file:///home/username/Documents"), which is not the same 993 * as the currently-selected folder if the chooser is in 994 * GTK_FILE_CHOOSER_SELECT_FOLDER mode 995 * (e.g. "file:///home/username/Documents/selected-folder/". To get the 996 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 997 * usual way to get the selection. 998 * Since 2.4 999 * Returns: the URI for the current folder. Free with g_free(). This function will also return NULL if the file chooser was unable to load the last folder that was requested from it; for example, as would be for calling gtk_file_chooser_set_current_folder_uri() on a nonexistent folder. 1000 */ 1001 public string getCurrentFolderUri() 1002 { 1003 // gchar * gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser); 1004 return Str.toString(gtk_file_chooser_get_current_folder_uri(getFileChooserTStruct())); 1005 } 1006 1007 /** 1008 * Sets an application-supplied widget to use to display a custom preview 1009 * of the currently selected file. To implement a preview, after setting the 1010 * preview widget, you connect to the "update-preview" 1011 * signal, and call gtk_file_chooser_get_preview_filename() or 1012 * gtk_file_chooser_get_preview_uri() on each change. If you can 1013 * display a preview of the new file, update your widget and 1014 * set the preview active using gtk_file_chooser_set_preview_widget_active(). 1015 * Otherwise, set the preview inactive. 1016 * When there is no application-supplied preview widget, or the 1017 * application-supplied preview widget is not active, the file chooser 1018 * may display an internally generated preview of the current file or 1019 * it may display no preview at all. 1020 * Since 2.4 1021 * Params: 1022 * previewWidget = widget for displaying preview. 1023 */ 1024 public void setPreviewWidget(Widget previewWidget) 1025 { 1026 // void gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser, GtkWidget *preview_widget); 1027 gtk_file_chooser_set_preview_widget(getFileChooserTStruct(), (previewWidget is null) ? null : previewWidget.getWidgetStruct()); 1028 } 1029 1030 /** 1031 * Gets the current preview widget; see 1032 * gtk_file_chooser_set_preview_widget(). 1033 * Since 2.4 1034 * Returns: the current preview widget, or NULL 1035 */ 1036 public Widget getPreviewWidget() 1037 { 1038 // GtkWidget * gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser); 1039 auto p = gtk_file_chooser_get_preview_widget(getFileChooserTStruct()); 1040 1041 if(p is null) 1042 { 1043 return null; 1044 } 1045 1046 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 1047 } 1048 1049 /** 1050 * Sets whether the preview widget set by 1051 * gtk_file_chooser_set_preview_widget() should be shown for the 1052 * current filename. When active is set to false, the file chooser 1053 * may display an internally generated preview of the current file 1054 * or it may display no preview at all. See 1055 * gtk_file_chooser_set_preview_widget() for more details. 1056 * Since 2.4 1057 * Params: 1058 * active = whether to display the user-specified preview widget 1059 */ 1060 public void setPreviewWidgetActive(int active) 1061 { 1062 // void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser, gboolean active); 1063 gtk_file_chooser_set_preview_widget_active(getFileChooserTStruct(), active); 1064 } 1065 1066 /** 1067 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget() 1068 * should be shown for the current filename. See 1069 * gtk_file_chooser_set_preview_widget_active(). 1070 * Since 2.4 1071 * Returns: TRUE if the preview widget is active for the current filename. 1072 */ 1073 public int getPreviewWidgetActive() 1074 { 1075 // gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser); 1076 return gtk_file_chooser_get_preview_widget_active(getFileChooserTStruct()); 1077 } 1078 1079 /** 1080 * Sets whether the file chooser should display a stock label with the name of 1081 * the file that is being previewed; the default is TRUE. Applications that 1082 * want to draw the whole preview area themselves should set this to FALSE and 1083 * display the name themselves in their preview widget. 1084 * See also: gtk_file_chooser_set_preview_widget() 1085 * Since 2.4 1086 * Params: 1087 * useLabel = whether to display a stock label with the name of the previewed file 1088 */ 1089 public void setUsePreviewLabel(int useLabel) 1090 { 1091 // void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser, gboolean use_label); 1092 gtk_file_chooser_set_use_preview_label(getFileChooserTStruct(), useLabel); 1093 } 1094 1095 /** 1096 * Gets whether a stock label should be drawn with the name of the previewed 1097 * file. See gtk_file_chooser_set_use_preview_label(). 1098 * Returns: TRUE if the file chooser is set to display a label with the name of the previewed file, FALSE otherwise. 1099 */ 1100 public int getUsePreviewLabel() 1101 { 1102 // gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser); 1103 return gtk_file_chooser_get_use_preview_label(getFileChooserTStruct()); 1104 } 1105 1106 /** 1107 * Gets the filename that should be previewed in a custom preview 1108 * widget. See gtk_file_chooser_set_preview_widget(). 1109 * Since 2.4 1110 * Returns: the filename to preview, or NULL if no file is selected, or if the selected file cannot be represented as a local filename. Free with g_free() 1111 */ 1112 public string getPreviewFilename() 1113 { 1114 // char * gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser); 1115 return Str.toString(gtk_file_chooser_get_preview_filename(getFileChooserTStruct())); 1116 } 1117 1118 /** 1119 * Gets the URI that should be previewed in a custom preview 1120 * widget. See gtk_file_chooser_set_preview_widget(). 1121 * Since 2.4 1122 * Returns: the URI for the file to preview, or NULL if no file is selected. Free with g_free(). 1123 */ 1124 public string getPreviewUri() 1125 { 1126 // char * gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser); 1127 return Str.toString(gtk_file_chooser_get_preview_uri(getFileChooserTStruct())); 1128 } 1129 1130 /** 1131 * Sets an application-supplied widget to provide extra options to the user. 1132 * Since 2.4 1133 * Params: 1134 * extraWidget = widget for extra options 1135 */ 1136 public void setExtraWidget(Widget extraWidget) 1137 { 1138 // void gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser, GtkWidget *extra_widget); 1139 gtk_file_chooser_set_extra_widget(getFileChooserTStruct(), (extraWidget is null) ? null : extraWidget.getWidgetStruct()); 1140 } 1141 1142 /** 1143 * Gets the current preview widget; see 1144 * gtk_file_chooser_set_extra_widget(). 1145 * Since 2.4 1146 * Returns: the current extra widget, or NULL 1147 */ 1148 public Widget getExtraWidget() 1149 { 1150 // GtkWidget * gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser); 1151 auto p = gtk_file_chooser_get_extra_widget(getFileChooserTStruct()); 1152 1153 if(p is null) 1154 { 1155 return null; 1156 } 1157 1158 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 1159 } 1160 1161 /** 1162 * Adds filter to the list of filters that the user can select between. 1163 * When a filter is selected, only files that are passed by that 1164 * filter are displayed. 1165 * Note that the chooser takes ownership of the filter, so you have to 1166 * ref and sink it if you want to keep a reference. 1167 * Since 2.4 1168 * Params: 1169 * filter = a GtkFileFilter 1170 */ 1171 public void addFilter(FileFilter filter) 1172 { 1173 // void gtk_file_chooser_add_filter (GtkFileChooser *chooser, GtkFileFilter *filter); 1174 gtk_file_chooser_add_filter(getFileChooserTStruct(), (filter is null) ? null : filter.getFileFilterStruct()); 1175 } 1176 1177 /** 1178 * Removes filter from the list of filters that the user can select between. 1179 * Since 2.4 1180 * Params: 1181 * filter = a GtkFileFilter 1182 */ 1183 public void removeFilter(FileFilter filter) 1184 { 1185 // void gtk_file_chooser_remove_filter (GtkFileChooser *chooser, GtkFileFilter *filter); 1186 gtk_file_chooser_remove_filter(getFileChooserTStruct(), (filter is null) ? null : filter.getFileFilterStruct()); 1187 } 1188 1189 /** 1190 * Lists the current set of user-selectable filters; see 1191 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter(). 1192 * Since 2.4 1193 * Returns: a GSList containing the current set of user selectable filters. The contents of the list are owned by GTK+, but you must free the list itself with g_slist_free() when you are done with it. [element-type utf8][transfer container utf8] 1194 */ 1195 public ListSG listFilters() 1196 { 1197 // GSList * gtk_file_chooser_list_filters (GtkFileChooser *chooser); 1198 auto p = gtk_file_chooser_list_filters(getFileChooserTStruct()); 1199 1200 if(p is null) 1201 { 1202 return null; 1203 } 1204 1205 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 1206 } 1207 1208 /** 1209 * Sets the current filter; only the files that pass the 1210 * filter will be displayed. If the user-selectable list of filters 1211 * is non-empty, then the filter should be one of the filters 1212 * in that list. Setting the current filter when the list of 1213 * filters is empty is useful if you want to restrict the displayed 1214 * set of files without letting the user change it. 1215 * Since 2.4 1216 * Params: 1217 * filter = a GtkFileFilter 1218 */ 1219 public void setFilter(FileFilter filter) 1220 { 1221 // void gtk_file_chooser_set_filter (GtkFileChooser *chooser, GtkFileFilter *filter); 1222 gtk_file_chooser_set_filter(getFileChooserTStruct(), (filter is null) ? null : filter.getFileFilterStruct()); 1223 } 1224 1225 /** 1226 * Gets the current filter; see gtk_file_chooser_set_filter(). 1227 * Since 2.4 1228 * Returns: the current filter, or NULL 1229 */ 1230 public FileFilter getFilter() 1231 { 1232 // GtkFileFilter * gtk_file_chooser_get_filter (GtkFileChooser *chooser); 1233 auto p = gtk_file_chooser_get_filter(getFileChooserTStruct()); 1234 1235 if(p is null) 1236 { 1237 return null; 1238 } 1239 1240 return ObjectG.getDObject!(FileFilter)(cast(GtkFileFilter*) p); 1241 } 1242 1243 /** 1244 * Adds a folder to be displayed with the shortcut folders in a file chooser. 1245 * Note that shortcut folders do not get saved, as they are provided by the 1246 * application. For example, you can use this to add a 1247 * "/usr/share/mydrawprogram/Clipart" folder to the volume list. 1248 * Since 2.4 1249 * Params: 1250 * folder = filename of the folder to add 1251 * Returns: TRUE if the folder could be added successfully, FALSE otherwise. In the latter case, the error will be set as appropriate. 1252 * Throws: GException on failure. 1253 */ 1254 public int addShortcutFolder(string folder) 1255 { 1256 // gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser, const char *folder, GError **error); 1257 GError* err = null; 1258 1259 auto p = gtk_file_chooser_add_shortcut_folder(getFileChooserTStruct(), Str.toStringz(folder), &err); 1260 1261 if (err !is null) 1262 { 1263 throw new GException( new ErrorG(err) ); 1264 } 1265 1266 return p; 1267 } 1268 1269 /** 1270 * Removes a folder from a file chooser's list of shortcut folders. 1271 * Since 2.4 1272 * Params: 1273 * folder = filename of the folder to remove 1274 * Returns: TRUE if the operation succeeds, FALSE otherwise. In the latter case, the error will be set as appropriate. See also: gtk_file_chooser_add_shortcut_folder() 1275 * Throws: GException on failure. 1276 */ 1277 public int removeShortcutFolder(string folder) 1278 { 1279 // gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, const char *folder, GError **error); 1280 GError* err = null; 1281 1282 auto p = gtk_file_chooser_remove_shortcut_folder(getFileChooserTStruct(), Str.toStringz(folder), &err); 1283 1284 if (err !is null) 1285 { 1286 throw new GException( new ErrorG(err) ); 1287 } 1288 1289 return p; 1290 } 1291 1292 /** 1293 * Queries the list of shortcut folders in the file chooser, as set by 1294 * gtk_file_chooser_add_shortcut_folder(). 1295 * Since 2.4 1296 * Returns: A list of folder filenames, or NULL if there are no shortcut folders. Free the returned list with g_slist_free(), and the filenames with g_free(). [element-type utf8][transfer full utf8] 1297 */ 1298 public ListSG listShortcutFolders() 1299 { 1300 // GSList * gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser); 1301 auto p = gtk_file_chooser_list_shortcut_folders(getFileChooserTStruct()); 1302 1303 if(p is null) 1304 { 1305 return null; 1306 } 1307 1308 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 1309 } 1310 1311 /** 1312 * Adds a folder URI to be displayed with the shortcut folders in a file 1313 * chooser. Note that shortcut folders do not get saved, as they are provided 1314 * by the application. For example, you can use this to add a 1315 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list. 1316 * Since 2.4 1317 * Params: 1318 * uri = URI of the folder to add 1319 * Returns: TRUE if the folder could be added successfully, FALSE otherwise. In the latter case, the error will be set as appropriate. 1320 * Throws: GException on failure. 1321 */ 1322 public int addShortcutFolderUri(string uri) 1323 { 1324 // gboolean gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser, const char *uri, GError **error); 1325 GError* err = null; 1326 1327 auto p = gtk_file_chooser_add_shortcut_folder_uri(getFileChooserTStruct(), Str.toStringz(uri), &err); 1328 1329 if (err !is null) 1330 { 1331 throw new GException( new ErrorG(err) ); 1332 } 1333 1334 return p; 1335 } 1336 1337 /** 1338 * Removes a folder URI from a file chooser's list of shortcut folders. 1339 * Since 2.4 1340 * Params: 1341 * uri = URI of the folder to remove 1342 * Returns: TRUE if the operation succeeds, FALSE otherwise. In the latter case, the error will be set as appropriate. See also: gtk_file_chooser_add_shortcut_folder_uri() 1343 * Throws: GException on failure. 1344 */ 1345 public int removeShortcutFolderUri(string uri) 1346 { 1347 // gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser, const char *uri, GError **error); 1348 GError* err = null; 1349 1350 auto p = gtk_file_chooser_remove_shortcut_folder_uri(getFileChooserTStruct(), Str.toStringz(uri), &err); 1351 1352 if (err !is null) 1353 { 1354 throw new GException( new ErrorG(err) ); 1355 } 1356 1357 return p; 1358 } 1359 1360 /** 1361 * Queries the list of shortcut folders in the file chooser, as set by 1362 * gtk_file_chooser_add_shortcut_folder_uri(). 1363 * Since 2.4 1364 * Returns: A list of folder URIs, or NULL if there are no shortcut folders. Free the returned list with g_slist_free(), and the URIs with g_free(). [element-type utf8][transfer full utf8] 1365 */ 1366 public ListSG listShortcutFolderUris() 1367 { 1368 // GSList * gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser); 1369 auto p = gtk_file_chooser_list_shortcut_folder_uris(getFileChooserTStruct()); 1370 1371 if(p is null) 1372 { 1373 return null; 1374 } 1375 1376 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 1377 } 1378 1379 /** 1380 * Gets the current folder of chooser as GFile. 1381 * See gtk_file_chooser_get_current_folder_uri(). 1382 * Since 2.14 1383 * Returns: the GFile for the current folder. 1384 */ 1385 public File getCurrentFolderFile() 1386 { 1387 // GFile * gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser); 1388 auto p = gtk_file_chooser_get_current_folder_file(getFileChooserTStruct()); 1389 1390 if(p is null) 1391 { 1392 return null; 1393 } 1394 1395 return ObjectG.getDObject!(File)(cast(GFile*) p); 1396 } 1397 1398 /** 1399 * Gets the GFile for the currently selected file in 1400 * the file selector. If multiple files are selected, 1401 * one of the files will be returned at random. 1402 * If the file chooser is in folder mode, this function returns the selected 1403 * folder. 1404 * Since 2.14 1405 * Returns: a selected GFile. You own the returned file; use g_object_unref() to release it. 1406 */ 1407 public File getFile() 1408 { 1409 // GFile * gtk_file_chooser_get_file (GtkFileChooser *chooser); 1410 auto p = gtk_file_chooser_get_file(getFileChooserTStruct()); 1411 1412 if(p is null) 1413 { 1414 return null; 1415 } 1416 1417 return ObjectG.getDObject!(File)(cast(GFile*) p); 1418 } 1419 1420 /** 1421 * Lists all the selected files and subfolders in the current folder of chooser 1422 * as GFile. An internal function, see gtk_file_chooser_get_uris(). 1423 * Since 2.14 1424 * Returns: a GSList containing a GFile for each selected file and subfolder in the current folder. Free the returned list with g_slist_free(), and the files with g_object_unref(). [element-type utf8][transfer full utf8] 1425 */ 1426 public ListSG getFiles() 1427 { 1428 // GSList * gtk_file_chooser_get_files (GtkFileChooser *chooser); 1429 auto p = gtk_file_chooser_get_files(getFileChooserTStruct()); 1430 1431 if(p is null) 1432 { 1433 return null; 1434 } 1435 1436 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 1437 } 1438 1439 /** 1440 * Gets the GFile that should be previewed in a custom preview 1441 * Internal function, see gtk_file_chooser_get_preview_uri(). 1442 * Since 2.14 1443 * Returns: the GFile for the file to preview, or NULL if no file is selected. Free with g_object_unref(). 1444 */ 1445 public File getPreviewFile() 1446 { 1447 // GFile * gtk_file_chooser_get_preview_file (GtkFileChooser *chooser); 1448 auto p = gtk_file_chooser_get_preview_file(getFileChooserTStruct()); 1449 1450 if(p is null) 1451 { 1452 return null; 1453 } 1454 1455 return ObjectG.getDObject!(File)(cast(GFile*) p); 1456 } 1457 1458 /** 1459 * Selects the file referred to by file. An internal function. See 1460 * _gtk_file_chooser_select_uri(). 1461 * Since 2.14 1462 * Params: 1463 * file = the file to select 1464 * Returns: TRUE if both the folder could be changed and the path was selected successfully, FALSE otherwise. 1465 * Throws: GException on failure. 1466 */ 1467 public int selectFile(File file) 1468 { 1469 // gboolean gtk_file_chooser_select_file (GtkFileChooser *chooser, GFile *file, GError **error); 1470 GError* err = null; 1471 1472 auto p = gtk_file_chooser_select_file(getFileChooserTStruct(), (file is null) ? null : file.getFileStruct(), &err); 1473 1474 if (err !is null) 1475 { 1476 throw new GException( new ErrorG(err) ); 1477 } 1478 1479 return p; 1480 } 1481 1482 /** 1483 * Sets the current folder for chooser from a GFile. 1484 * Internal function, see gtk_file_chooser_set_current_folder_uri(). 1485 * Since 2.14 1486 * Params: 1487 * file = the GFile for the new folder 1488 * Returns: TRUE if the folder could be changed successfully, FALSE otherwise. 1489 * Throws: GException on failure. 1490 */ 1491 public int setCurrentFolderFile(File file) 1492 { 1493 // gboolean gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser, GFile *file, GError **error); 1494 GError* err = null; 1495 1496 auto p = gtk_file_chooser_set_current_folder_file(getFileChooserTStruct(), (file is null) ? null : file.getFileStruct(), &err); 1497 1498 if (err !is null) 1499 { 1500 throw new GException( new ErrorG(err) ); 1501 } 1502 1503 return p; 1504 } 1505 1506 /** 1507 * Sets file as the current filename for the file chooser, by changing 1508 * to the file's parent folder and actually selecting the file in list. If 1509 * the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name 1510 * will also appear in the dialog's file name entry. 1511 * If the file name isn't in the current folder of chooser, then the current 1512 * folder of chooser will be changed to the folder containing filename. This 1513 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by 1514 * gtk_file_chooser_select_filename(). 1515 * Note that the file must exist, or nothing will be done except 1516 * for the directory change. 1517 * If you are implementing a File/Save As... dialog, 1518 * you should use this function if you already have a file name to which the 1519 * user may save; for example, when the user opens an existing file and then 1520 * does File/Save As... on it. If you don't have 1521 * a file name already — for example, if the user just created a new 1522 * file and is saving it for the first time, do not call this function. 1523 * Since 2.14 1524 * Params: 1525 * file = the GFile to set as current 1526 * Returns: TRUE if both the folder could be changed and the file was selected successfully, FALSE otherwise. 1527 * Throws: GException on failure. 1528 */ 1529 public int setFile(File file) 1530 { 1531 // gboolean gtk_file_chooser_set_file (GtkFileChooser *chooser, GFile *file, GError **error); 1532 GError* err = null; 1533 1534 auto p = gtk_file_chooser_set_file(getFileChooserTStruct(), (file is null) ? null : file.getFileStruct(), &err); 1535 1536 if (err !is null) 1537 { 1538 throw new GException( new ErrorG(err) ); 1539 } 1540 1541 return p; 1542 } 1543 1544 /** 1545 * Unselects the file referred to by file. If the file is not in the current 1546 * directory, does not exist, or is otherwise not currently selected, does nothing. 1547 * Since 2.14 1548 * Params: 1549 * file = a GFile 1550 */ 1551 public void unselectFile(File file) 1552 { 1553 // void gtk_file_chooser_unselect_file (GtkFileChooser *chooser, GFile *file); 1554 gtk_file_chooser_unselect_file(getFileChooserTStruct(), (file is null) ? null : file.getFileStruct()); 1555 } 1556 }