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