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