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 module gtk.FileChooserIF; 26 27 private import gio.File; 28 private import gio.FileIF; 29 private import glib.ErrorG; 30 private import glib.GException; 31 private import glib.ListSG; 32 private import glib.Str; 33 private import gobject.ObjectG; 34 private import gobject.Signals; 35 private import gtk.FileFilter; 36 private import gtk.Widget; 37 public import gtkc.gdktypes; 38 private import gtkc.gtk; 39 public import gtkc.gtktypes; 40 41 42 /** 43 * #GtkFileChooser is an interface that can be implemented by file 44 * selection widgets. In GTK+, the main objects that implement this 45 * interface are #GtkFileChooserWidget, #GtkFileChooserDialog, and 46 * #GtkFileChooserButton. You do not need to write an object that 47 * implements the #GtkFileChooser interface unless you are trying to 48 * adapt an existing file selector to expose a standard programming 49 * interface. 50 * 51 * #GtkFileChooser allows for shortcuts to various places in the filesystem. 52 * In the default implementation these are displayed in the left pane. It 53 * may be a bit confusing at first that these shortcuts come from various 54 * sources and in various flavours, so lets explain the terminology here: 55 * 56 * - Bookmarks: are created by the user, by dragging folders from the 57 * right pane to the left pane, or by using the “Add”. Bookmarks 58 * can be renamed and deleted by the user. 59 * 60 * - Shortcuts: can be provided by the application. For example, a Paint 61 * program may want to add a shortcut for a Clipart folder. Shortcuts 62 * cannot be modified by the user. 63 * 64 * - Volumes: are provided by the underlying filesystem abstraction. They are 65 * the “roots” of the filesystem. 66 * 67 * # File Names and Encodings 68 * 69 * When the user is finished selecting files in a 70 * #GtkFileChooser, your program can get the selected names 71 * either as filenames or as URIs. For URIs, the normal escaping 72 * rules are applied if the URI contains non-ASCII characters. 73 * However, filenames are always returned in 74 * the character set specified by the 75 * `G_FILENAME_ENCODING` environment variable. 76 * Please see the GLib documentation for more details about this 77 * variable. 78 * 79 * This means that while you can pass the result of 80 * gtk_file_chooser_get_filename() to open() or fopen(), 81 * you may not be able to directly set it as the text of a 82 * #GtkLabel widget unless you convert it first to UTF-8, 83 * which all GTK+ widgets expect. You should use g_filename_to_utf8() 84 * to convert filenames into strings that can be passed to GTK+ 85 * widgets. 86 * 87 * # Adding a Preview Widget 88 * 89 * You can add a custom preview widget to a file chooser and then 90 * get notification about when the preview needs to be updated. 91 * To install a preview widget, use 92 * gtk_file_chooser_set_preview_widget(). Then, connect to the 93 * #GtkFileChooser::update-preview signal to get notified when 94 * you need to update the contents of the preview. 95 * 96 * Your callback should use 97 * gtk_file_chooser_get_preview_filename() to see what needs 98 * previewing. Once you have generated the preview for the 99 * corresponding file, you must call 100 * gtk_file_chooser_set_preview_widget_active() with a boolean 101 * flag that indicates whether your callback could successfully 102 * generate a preview. 103 * 104 * ## Example: Using a Preview Widget ## {#gtkfilechooser-preview} 105 * |[<!-- language="C" --> 106 * { 107 * GtkImage *preview; 108 * 109 * ... 110 * 111 * preview = gtk_image_new (); 112 * 113 * gtk_file_chooser_set_preview_widget (my_file_chooser, preview); 114 * g_signal_connect (my_file_chooser, "update-preview", 115 * G_CALLBACK (update_preview_cb), preview); 116 * } 117 * 118 * static void 119 * update_preview_cb (GtkFileChooser *file_chooser, gpointer data) 120 * { 121 * GtkWidget *preview; 122 * char *filename; 123 * GdkPixbuf *pixbuf; 124 * gboolean have_preview; 125 * 126 * preview = GTK_WIDGET (data); 127 * filename = gtk_file_chooser_get_preview_filename (file_chooser); 128 * 129 * pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL); 130 * have_preview = (pixbuf != NULL); 131 * g_free (filename); 132 * 133 * gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf); 134 * if (pixbuf) 135 * g_object_unref (pixbuf); 136 * 137 * gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview); 138 * } 139 * ]| 140 * 141 * # Adding Extra Widgets 142 * 143 * You can add extra widgets to a file chooser to provide options 144 * that are not present in the default design. For example, you 145 * can add a toggle button to give the user the option to open a 146 * file in read-only mode. You can use 147 * gtk_file_chooser_set_extra_widget() to insert additional 148 * widgets in a file chooser. 149 * 150 * An example for adding extra widgets: 151 * |[<!-- language="C" --> 152 * 153 * GtkWidget *toggle; 154 * 155 * ... 156 * 157 * toggle = gtk_check_button_new_with_label ("Open file read-only"); 158 * gtk_widget_show (toggle); 159 * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle); 160 * } 161 * ]| 162 * 163 * If you want to set more than one extra widget in the file 164 * chooser, you can a container such as a #GtkBox or a #GtkGrid 165 * and include your widgets in it. Then, set the container as 166 * the whole extra widget. 167 */ 168 public interface FileChooserIF{ 169 /** Get the main Gtk struct */ 170 public GtkFileChooser* getFileChooserStruct(); 171 172 /** the main Gtk struct as a void* */ 173 protected void* getStruct(); 174 175 /** 176 */ 177 178 /** 179 * Adds @filter to the list of filters that the user can select between. 180 * When a filter is selected, only files that are passed by that 181 * filter are displayed. 182 * 183 * Note that the @chooser takes ownership of the filter, so you have to 184 * ref and sink it if you want to keep a reference. 185 * 186 * Params: 187 * filter = a #GtkFileFilter 188 * 189 * Since: 2.4 190 */ 191 public void addFilter(FileFilter filter); 192 193 /** 194 * Adds a folder to be displayed with the shortcut folders in a file chooser. 195 * Note that shortcut folders do not get saved, as they are provided by the 196 * application. For example, you can use this to add a 197 * “/usr/share/mydrawprogram/Clipart” folder to the volume list. 198 * 199 * Params: 200 * folder = filename of the folder to add 201 * 202 * Return: %TRUE if the folder could be added successfully, %FALSE 203 * otherwise. In the latter case, the @error will be set as appropriate. 204 * 205 * Since: 2.4 206 * 207 * Throws: GException on failure. 208 */ 209 public bool addShortcutFolder(string folder); 210 211 /** 212 * Adds a folder URI to be displayed with the shortcut folders in a file 213 * chooser. Note that shortcut folders do not get saved, as they are provided 214 * by the application. For example, you can use this to add a 215 * “file:///usr/share/mydrawprogram/Clipart” folder to the volume list. 216 * 217 * Params: 218 * uri = URI of the folder to add 219 * 220 * Return: %TRUE if the folder could be added successfully, %FALSE 221 * otherwise. In the latter case, the @error will be set as appropriate. 222 * 223 * Since: 2.4 224 * 225 * Throws: GException on failure. 226 */ 227 public bool addShortcutFolderUri(string uri); 228 229 /** 230 * Gets the type of operation that the file chooser is performing; see 231 * gtk_file_chooser_set_action(). 232 * 233 * Return: the action that the file selector is performing 234 * 235 * Since: 2.4 236 */ 237 public GtkFileChooserAction getFileChooserAction(); 238 239 /** 240 * Gets whether file choser will offer to create new folders. 241 * See gtk_file_chooser_set_create_folders(). 242 * 243 * Return: %TRUE if the Create Folder button should be displayed. 244 * 245 * Since: 2.18 246 */ 247 public bool getCreateFolders(); 248 249 /** 250 * Gets the current folder of @chooser as a local filename. 251 * See gtk_file_chooser_set_current_folder(). 252 * 253 * Note that this is the folder that the file chooser is currently displaying 254 * (e.g. "/home/username/Documents"), which is not the same 255 * as the currently-selected folder if the chooser is in 256 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode 257 * (e.g. "/home/username/Documents/selected-folder/". To get the 258 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 259 * usual way to get the selection. 260 * 261 * Return: the full path of the current folder, 262 * or %NULL if the current path cannot be represented as a local 263 * filename. Free with g_free(). This function will also return 264 * %NULL if the file chooser was unable to load the last folder that 265 * was requested from it; for example, as would be for calling 266 * gtk_file_chooser_set_current_folder() on a nonexistent folder. 267 * 268 * Since: 2.4 269 */ 270 public string getCurrentFolder(); 271 272 /** 273 * Gets the current folder of @chooser as #GFile. 274 * See gtk_file_chooser_get_current_folder_uri(). 275 * 276 * Return: the #GFile for the current folder. 277 * 278 * Since: 2.14 279 */ 280 public FileIF getCurrentFolderFile(); 281 282 /** 283 * Gets the current folder of @chooser as an URI. 284 * See gtk_file_chooser_set_current_folder_uri(). 285 * 286 * Note that this is the folder that the file chooser is currently displaying 287 * (e.g. "file:///home/username/Documents"), which is not the same 288 * as the currently-selected folder if the chooser is in 289 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode 290 * (e.g. "file:///home/username/Documents/selected-folder/". To get the 291 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 292 * usual way to get the selection. 293 * 294 * Return: the URI for the current folder. Free with g_free(). This 295 * function will also return %NULL if the file chooser was unable to load the 296 * last folder that was requested from it; for example, as would be for calling 297 * gtk_file_chooser_set_current_folder_uri() on a nonexistent folder. 298 * 299 * Since: 2.4 300 */ 301 public string getCurrentFolderUri(); 302 303 /** 304 * Gets the current name in the file selector, as entered by the user in the 305 * text entry for “Name”. 306 * 307 * This is meant to be used in save dialogs, to get the currently typed filename 308 * when the file itself does not exist yet. For example, an application that 309 * adds a custom extra widget to the file chooser for “file format” may want to 310 * change the extension of the typed filename based on the chosen format, say, 311 * from “.jpg” to “.png”. 312 * 313 * Return: The raw text from the file chooser’s “Name” entry. Free this with 314 * g_free(). Note that this string is not a full pathname or URI; it is 315 * whatever the contents of the entry are. Note also that this string is in 316 * UTF-8 encoding, which is not necessarily the system’s encoding for filenames. 317 * 318 * Since: 3.10 319 */ 320 public string getCurrentName(); 321 322 /** 323 * Queries whether a file chooser is set to confirm for overwriting when the user 324 * types a file name that already exists. 325 * 326 * Return: %TRUE if the file chooser will present a confirmation dialog; 327 * %FALSE otherwise. 328 * 329 * Since: 2.8 330 */ 331 public bool getDoOverwriteConfirmation(); 332 333 /** 334 * Gets the current preview widget; see 335 * gtk_file_chooser_set_extra_widget(). 336 * 337 * Return: the current extra widget, or %NULL 338 * 339 * Since: 2.4 340 */ 341 public Widget getExtraWidget(); 342 343 /** 344 * Gets the #GFile for the currently selected file in 345 * the file selector. If multiple files are selected, 346 * one of the files will be returned at random. 347 * 348 * If the file chooser is in folder mode, this function returns the selected 349 * folder. 350 * 351 * Return: a selected #GFile. You own the returned file; 352 * use g_object_unref() to release it. 353 * 354 * Since: 2.14 355 */ 356 public FileIF getFile(); 357 358 /** 359 * Gets the filename for the currently selected file in 360 * the file selector. The filename is returned as an absolute path. If 361 * multiple files are selected, one of the filenames will be returned at 362 * random. 363 * 364 * If the file chooser is in folder mode, this function returns the selected 365 * folder. 366 * 367 * Return: The currently selected filename, or %NULL 368 * if no file is selected, or the selected file can't 369 * be represented with a local filename. Free with g_free(). 370 * 371 * Since: 2.4 372 */ 373 public string getFilename(); 374 375 /** 376 * Lists all the selected files and subfolders in the current folder of 377 * @chooser. The returned names are full absolute paths. If files in the current 378 * folder cannot be represented as local filenames they will be ignored. (See 379 * gtk_file_chooser_get_uris()) 380 * 381 * Return: a #GSList 382 * containing the filenames of all selected files and subfolders in 383 * the current folder. Free the returned list with g_slist_free(), 384 * and the filenames with g_free(). 385 * 386 * Since: 2.4 387 */ 388 public ListSG getFilenames(); 389 390 /** 391 * Lists all the selected files and subfolders in the current folder of @chooser 392 * as #GFile. An internal function, see gtk_file_chooser_get_uris(). 393 * 394 * Return: a #GSList 395 * containing a #GFile for each selected file and subfolder in the 396 * current folder. Free the returned list with g_slist_free(), and 397 * the files with g_object_unref(). 398 * 399 * Since: 2.14 400 */ 401 public ListSG getFiles(); 402 403 /** 404 * Gets the current filter; see gtk_file_chooser_set_filter(). 405 * 406 * Return: the current filter, or %NULL 407 * 408 * Since: 2.4 409 */ 410 public FileFilter getFilter(); 411 412 /** 413 * Gets whether only local files can be selected in the 414 * file selector. See gtk_file_chooser_set_local_only() 415 * 416 * Return: %TRUE if only local files can be selected. 417 * 418 * Since: 2.4 419 */ 420 public bool getLocalOnly(); 421 422 /** 423 * Gets the #GFile that should be previewed in a custom preview 424 * Internal function, see gtk_file_chooser_get_preview_uri(). 425 * 426 * Return: the #GFile for the file to preview, 427 * or %NULL if no file is selected. Free with g_object_unref(). 428 * 429 * Since: 2.14 430 */ 431 public FileIF getPreviewFile(); 432 433 /** 434 * Gets the filename that should be previewed in a custom preview 435 * widget. See gtk_file_chooser_set_preview_widget(). 436 * 437 * Return: the filename to preview, or %NULL if 438 * no file is selected, or if the selected file cannot be represented 439 * as a local filename. Free with g_free() 440 * 441 * Since: 2.4 442 */ 443 public string getPreviewFilename(); 444 445 /** 446 * Gets the URI that should be previewed in a custom preview 447 * widget. See gtk_file_chooser_set_preview_widget(). 448 * 449 * Return: the URI for the file to preview, or %NULL if no file is 450 * selected. Free with g_free(). 451 * 452 * Since: 2.4 453 */ 454 public string getPreviewUri(); 455 456 /** 457 * Gets the current preview widget; see 458 * gtk_file_chooser_set_preview_widget(). 459 * 460 * Return: the current preview widget, or %NULL 461 * 462 * Since: 2.4 463 */ 464 public Widget getPreviewWidget(); 465 466 /** 467 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget() 468 * should be shown for the current filename. See 469 * gtk_file_chooser_set_preview_widget_active(). 470 * 471 * Return: %TRUE if the preview widget is active for the current filename. 472 * 473 * Since: 2.4 474 */ 475 public bool getPreviewWidgetActive(); 476 477 /** 478 * Gets whether multiple files can be selected in the file 479 * selector. See gtk_file_chooser_set_select_multiple(). 480 * 481 * Return: %TRUE if multiple files can be selected. 482 * 483 * Since: 2.4 484 */ 485 public bool getSelectMultiple(); 486 487 /** 488 * Gets whether hidden files and folders are displayed in the file selector. 489 * See gtk_file_chooser_set_show_hidden(). 490 * 491 * Return: %TRUE if hidden files and folders are displayed. 492 * 493 * Since: 2.6 494 */ 495 public bool getShowHidden(); 496 497 /** 498 * Gets the URI for the currently selected file in 499 * the file selector. If multiple files are selected, 500 * one of the filenames will be returned at random. 501 * 502 * If the file chooser is in folder mode, this function returns the selected 503 * folder. 504 * 505 * Return: The currently selected URI, or %NULL 506 * if no file is selected. If gtk_file_chooser_set_local_only() is set to %TRUE 507 * (the default) a local URI will be returned for any FUSE locations. 508 * Free with g_free() 509 * 510 * Since: 2.4 511 */ 512 public string getUri(); 513 514 /** 515 * Lists all the selected files and subfolders in the current folder of 516 * @chooser. The returned names are full absolute URIs. 517 * 518 * Return: a #GSList containing the URIs of all selected 519 * files and subfolders in the current folder. Free the returned list 520 * with g_slist_free(), and the filenames with g_free(). 521 * 522 * Since: 2.4 523 */ 524 public ListSG getUris(); 525 526 /** 527 * Gets whether a stock label should be drawn with the name of the previewed 528 * file. See gtk_file_chooser_set_use_preview_label(). 529 * 530 * Return: %TRUE if the file chooser is set to display a label with the 531 * name of the previewed file, %FALSE otherwise. 532 */ 533 public bool getUsePreviewLabel(); 534 535 /** 536 * Lists the current set of user-selectable filters; see 537 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter(). 538 * 539 * Return: a 540 * #GSList containing the current set of user selectable filters. The 541 * contents of the list are owned by GTK+, but you must free the list 542 * itself with g_slist_free() when you are done with it. 543 * 544 * Since: 2.4 545 */ 546 public ListSG listFilters(); 547 548 /** 549 * Queries the list of shortcut folders in the file chooser, as set by 550 * gtk_file_chooser_add_shortcut_folder_uri(). 551 * 552 * Return: A list of 553 * folder URIs, or %NULL if there are no shortcut folders. Free the 554 * returned list with g_slist_free(), and the URIs with g_free(). 555 * 556 * Since: 2.4 557 */ 558 public ListSG listShortcutFolderUris(); 559 560 /** 561 * Queries the list of shortcut folders in the file chooser, as set by 562 * gtk_file_chooser_add_shortcut_folder(). 563 * 564 * Return: A list 565 * of folder filenames, or %NULL if there are no shortcut folders. 566 * Free the returned list with g_slist_free(), and the filenames with 567 * g_free(). 568 * 569 * Since: 2.4 570 */ 571 public ListSG listShortcutFolders(); 572 573 /** 574 * Removes @filter from the list of filters that the user can select between. 575 * 576 * Params: 577 * filter = a #GtkFileFilter 578 * 579 * Since: 2.4 580 */ 581 public void removeFilter(FileFilter filter); 582 583 /** 584 * Removes a folder from a file chooser’s list of shortcut folders. 585 * 586 * Params: 587 * folder = filename of the folder to remove 588 * 589 * Return: %TRUE if the operation succeeds, %FALSE otherwise. 590 * In the latter case, the @error will be set as appropriate. 591 * 592 * See also: gtk_file_chooser_add_shortcut_folder() 593 * 594 * Since: 2.4 595 * 596 * Throws: GException on failure. 597 */ 598 public bool removeShortcutFolder(string folder); 599 600 /** 601 * Removes a folder URI from a file chooser’s list of shortcut folders. 602 * 603 * Params: 604 * uri = URI of the folder to remove 605 * 606 * Return: %TRUE if the operation succeeds, %FALSE otherwise. 607 * In the latter case, the @error will be set as appropriate. 608 * 609 * See also: gtk_file_chooser_add_shortcut_folder_uri() 610 * 611 * Since: 2.4 612 * 613 * Throws: GException on failure. 614 */ 615 public bool removeShortcutFolderUri(string uri); 616 617 /** 618 * Selects all the files in the current folder of a file chooser. 619 * 620 * Since: 2.4 621 */ 622 public void selectAll(); 623 624 /** 625 * Selects the file referred to by @file. An internal function. See 626 * _gtk_file_chooser_select_uri(). 627 * 628 * Params: 629 * file = the file to select 630 * 631 * Return: Not useful. 632 * 633 * Since: 2.14 634 * 635 * Throws: GException on failure. 636 */ 637 public bool selectFile(FileIF file); 638 639 /** 640 * Selects a filename. If the file name isn’t in the current 641 * folder of @chooser, then the current folder of @chooser will 642 * be changed to the folder containing @filename. 643 * 644 * Params: 645 * filename = the filename to select 646 * 647 * Return: Not useful. 648 * 649 * See also: gtk_file_chooser_set_filename() 650 * 651 * Since: 2.4 652 */ 653 public bool selectFilename(string filename); 654 655 /** 656 * Selects the file to by @uri. If the URI doesn’t refer to a 657 * file in the current folder of @chooser, then the current folder of 658 * @chooser will be changed to the folder containing @filename. 659 * 660 * Params: 661 * uri = the URI to select 662 * 663 * Return: Not useful. 664 * 665 * Since: 2.4 666 */ 667 public bool selectUri(string uri); 668 669 /** 670 * Sets the type of operation that the chooser is performing; the 671 * user interface is adapted to suit the selected action. For example, 672 * an option to create a new folder might be shown if the action is 673 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is 674 * %GTK_FILE_CHOOSER_ACTION_OPEN. 675 * 676 * Params: 677 * action = the action that the file selector is performing 678 * 679 * Since: 2.4 680 */ 681 public void setFileChooserAction(GtkFileChooserAction action); 682 683 /** 684 * Sets whether file choser will offer to create new folders. 685 * This is only relevant if the action is not set to be 686 * %GTK_FILE_CHOOSER_ACTION_OPEN. 687 * 688 * Params: 689 * createFolders = %TRUE if the Create Folder button should be displayed 690 * 691 * Since: 2.18 692 */ 693 public void setCreateFolders(bool createFolders); 694 695 /** 696 * Sets the current folder for @chooser from a local filename. 697 * The user will be shown the full contents of the current folder, 698 * plus user interface elements for navigating to other folders. 699 * 700 * In general, you should not use this function. See the 701 * [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up] 702 * for the rationale behind this. 703 * 704 * Params: 705 * filename = the full path of the new current folder 706 * 707 * Return: Not useful. 708 * 709 * Since: 2.4 710 */ 711 public bool setCurrentFolder(string filename); 712 713 /** 714 * Sets the current folder for @chooser from a #GFile. 715 * Internal function, see gtk_file_chooser_set_current_folder_uri(). 716 * 717 * Params: 718 * file = the #GFile for the new folder 719 * 720 * Return: %TRUE if the folder could be changed successfully, %FALSE 721 * otherwise. 722 * 723 * Since: 2.14 724 * 725 * Throws: GException on failure. 726 */ 727 public bool setCurrentFolderFile(FileIF file); 728 729 /** 730 * Sets the current folder for @chooser from an URI. 731 * The user will be shown the full contents of the current folder, 732 * plus user interface elements for navigating to other folders. 733 * 734 * In general, you should not use this function. See the 735 * [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up] 736 * for the rationale behind this. 737 * 738 * Params: 739 * uri = the URI for the new current folder 740 * 741 * Return: %TRUE if the folder could be changed successfully, %FALSE 742 * otherwise. 743 * 744 * Since: 2.4 745 */ 746 public bool setCurrentFolderUri(string uri); 747 748 /** 749 * Sets the current name in the file selector, as if entered 750 * by the user. Note that the name passed in here is a UTF-8 751 * string rather than a filename. This function is meant for 752 * such uses as a suggested name in a “Save As...” dialog. You can 753 * pass “Untitled.doc” or a similarly suitable suggestion for the @name. 754 * 755 * If you want to preselect a particular existing file, you should use 756 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead. 757 * Please see the documentation for those functions for an example of using 758 * gtk_file_chooser_set_current_name() as well. 759 * 760 * Params: 761 * name = the filename to use, as a UTF-8 string 762 * 763 * Since: 2.4 764 */ 765 public void setCurrentName(string name); 766 767 /** 768 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present 769 * a confirmation dialog if the user types a file name that already exists. This 770 * is %FALSE by default. 771 * 772 * If set to %TRUE, the @chooser will emit the 773 * #GtkFileChooser::confirm-overwrite signal when appropriate. 774 * 775 * If all you need is the stock confirmation dialog, set this property to %TRUE. 776 * You can override the way confirmation is done by actually handling the 777 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation 778 * for the details. 779 * 780 * Params: 781 * doOverwriteConfirmation = whether to confirm overwriting in save mode 782 * 783 * Since: 2.8 784 */ 785 public void setDoOverwriteConfirmation(bool doOverwriteConfirmation); 786 787 /** 788 * Sets an application-supplied widget to provide extra options to the user. 789 * 790 * Params: 791 * extraWidget = widget for extra options 792 * 793 * Since: 2.4 794 */ 795 public void setExtraWidget(Widget extraWidget); 796 797 /** 798 * Sets @file as the current filename for the file chooser, by changing 799 * to the file’s parent folder and actually selecting the file in list. If 800 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file’s base name 801 * will also appear in the dialog’s file name entry. 802 * 803 * If the file name isn’t in the current folder of @chooser, then the current 804 * folder of @chooser will be changed to the folder containing @filename. This 805 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by 806 * gtk_file_chooser_select_filename(). 807 * 808 * Note that the file must exist, or nothing will be done except 809 * for the directory change. 810 * 811 * If you are implementing a save dialog, 812 * you should use this function if you already have a file name to which the 813 * user may save; for example, when the user opens an existing file and then 814 * does Save As... If you don’t have 815 * a file name already — for example, if the user just created a new 816 * file and is saving it for the first time, do not call this function. 817 * Instead, use something similar to this: 818 * |[<!-- language="C" --> 819 * if (document_is_new) 820 * { 821 * // the user just created a new document 822 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving); 823 * gtk_file_chooser_set_current_name (chooser, "Untitled document"); 824 * } 825 * else 826 * { 827 * // the user edited an existing document 828 * gtk_file_chooser_set_file (chooser, existing_file); 829 * } 830 * ]| 831 * 832 * Params: 833 * file = the #GFile to set as current 834 * 835 * Return: Not useful. 836 * 837 * Since: 2.14 838 * 839 * Throws: GException on failure. 840 */ 841 public bool setFile(FileIF file); 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 * 850 * Note that the file must exist, or nothing will be done except 851 * for the directory change. 852 * 853 * You should use this function only when implementing a save 854 * dialog for which you already have a file name to which 855 * the user may save. For example, when the user opens an existing file and 856 * then does Save As... to save a copy or 857 * a modified version. If you don’t have a file name already — for 858 * example, if the user just created a new file and is saving it for the first 859 * time, do not call this function. Instead, use something similar to this: 860 * |[<!-- language="C" --> 861 * if (document_is_new) 862 * { 863 * // the user just created a new document 864 * gtk_file_chooser_set_current_name (chooser, "Untitled document"); 865 * } 866 * else 867 * { 868 * // the user edited an existing document 869 * gtk_file_chooser_set_filename (chooser, existing_filename); 870 * } 871 * ]| 872 * 873 * In the first case, the file chooser will present the user with useful suggestions 874 * as to where to save his new file. In the second case, the file’s existing location 875 * is already known, so the file chooser will use it. 876 * 877 * Params: 878 * filename = the filename to set as current 879 * 880 * Return: Not useful. 881 * 882 * Since: 2.4 883 */ 884 public bool setFilename(string filename); 885 886 /** 887 * Sets the current filter; only the files that pass the 888 * filter will be displayed. If the user-selectable list of filters 889 * is non-empty, then the filter should be one of the filters 890 * in that list. Setting the current filter when the list of 891 * filters is empty is useful if you want to restrict the displayed 892 * set of files without letting the user change it. 893 * 894 * Params: 895 * filter = a #GtkFileFilter 896 * 897 * Since: 2.4 898 */ 899 public void setFilter(FileFilter filter); 900 901 /** 902 * Sets whether only local files can be selected in the 903 * file selector. If @local_only is %TRUE (the default), 904 * then the selected file or files are guaranteed to be 905 * accessible through the operating systems native file 906 * system and therefore the application only 907 * needs to worry about the filename functions in 908 * #GtkFileChooser, like gtk_file_chooser_get_filename(), 909 * rather than the URI functions like 910 * gtk_file_chooser_get_uri(), 911 * 912 * On some systems non-native files may still be 913 * available using the native filesystem via a userspace 914 * filesystem (FUSE). 915 * 916 * Params: 917 * localOnly = %TRUE if only local files can be selected 918 * 919 * Since: 2.4 920 */ 921 public void setLocalOnly(bool localOnly); 922 923 /** 924 * Sets an application-supplied widget to use to display a custom preview 925 * of the currently selected file. To implement a preview, after setting the 926 * preview widget, you connect to the #GtkFileChooser::update-preview 927 * signal, and call gtk_file_chooser_get_preview_filename() or 928 * gtk_file_chooser_get_preview_uri() on each change. If you can 929 * display a preview of the new file, update your widget and 930 * set the preview active using gtk_file_chooser_set_preview_widget_active(). 931 * Otherwise, set the preview inactive. 932 * 933 * When there is no application-supplied preview widget, or the 934 * application-supplied preview widget is not active, the file chooser 935 * will display no preview at all. 936 * 937 * Params: 938 * previewWidget = widget for displaying preview. 939 * 940 * Since: 2.4 941 */ 942 public void setPreviewWidget(Widget previewWidget); 943 944 /** 945 * Sets whether the preview widget set by 946 * gtk_file_chooser_set_preview_widget() should be shown for the 947 * current filename. When @active is set to false, the file chooser 948 * may display an internally generated preview of the current file 949 * or it may display no preview at all. See 950 * gtk_file_chooser_set_preview_widget() for more details. 951 * 952 * Params: 953 * active = whether to display the user-specified preview widget 954 * 955 * Since: 2.4 956 */ 957 public void setPreviewWidgetActive(bool active); 958 959 /** 960 * Sets whether multiple files can be selected in the file selector. This is 961 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or 962 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER. 963 * 964 * Params: 965 * selectMultiple = %TRUE if multiple files can be selected. 966 * 967 * Since: 2.4 968 */ 969 public void setSelectMultiple(bool selectMultiple); 970 971 /** 972 * Sets whether hidden files and folders are displayed in the file selector. 973 * 974 * Params: 975 * showHidden = %TRUE if hidden files and folders should be displayed. 976 * 977 * Since: 2.6 978 */ 979 public void setShowHidden(bool showHidden); 980 981 /** 982 * Sets the file referred to by @uri as the current file for the file chooser, 983 * by changing to the URI’s parent folder and actually selecting the URI in the 984 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI’s base 985 * name will also appear in the dialog’s file name entry. 986 * 987 * Note that the URI must exist, or nothing will be done except for the 988 * directory change. 989 * 990 * You should use this function only when implementing a save 991 * dialog for which you already have a file name to which 992 * the user may save. For example, when the user opens an existing file and then 993 * does Save As... to save a copy or a 994 * modified version. If you don’t have a file name already — for example, 995 * if the user just created a new file and is saving it for the first time, do 996 * not call this function. Instead, use something similar to this: 997 * |[<!-- language="C" --> 998 * if (document_is_new) 999 * { 1000 * // the user just created a new document 1001 * gtk_file_chooser_set_current_name (chooser, "Untitled document"); 1002 * } 1003 * else 1004 * { 1005 * // the user edited an existing document 1006 * gtk_file_chooser_set_uri (chooser, existing_uri); 1007 * } 1008 * ]| 1009 * 1010 * 1011 * In the first case, the file chooser will present the user with useful suggestions 1012 * as to where to save his new file. In the second case, the file’s existing location 1013 * is already known, so the file chooser will use it. 1014 * 1015 * Params: 1016 * uri = the URI to set as current 1017 * 1018 * Return: Not useful. 1019 * 1020 * Since: 2.4 1021 */ 1022 public bool setUri(string uri); 1023 1024 /** 1025 * Sets whether the file chooser should display a stock label with the name of 1026 * the file that is being previewed; the default is %TRUE. Applications that 1027 * want to draw the whole preview area themselves should set this to %FALSE and 1028 * display the name themselves in their preview widget. 1029 * 1030 * See also: gtk_file_chooser_set_preview_widget() 1031 * 1032 * Params: 1033 * useLabel = whether to display a stock label with the name of the previewed file 1034 * 1035 * Since: 2.4 1036 */ 1037 public void setUsePreviewLabel(bool useLabel); 1038 1039 /** 1040 * Unselects all the files in the current folder of a file chooser. 1041 * 1042 * Since: 2.4 1043 */ 1044 public void unselectAll(); 1045 1046 /** 1047 * Unselects the file referred to by @file. If the file is not in the current 1048 * directory, does not exist, or is otherwise not currently selected, does nothing. 1049 * 1050 * Params: 1051 * file = a #GFile 1052 * 1053 * Since: 2.14 1054 */ 1055 public void unselectFile(FileIF file); 1056 1057 /** 1058 * Unselects a currently selected filename. If the filename 1059 * is not in the current directory, does not exist, or 1060 * is otherwise not currently selected, does nothing. 1061 * 1062 * Params: 1063 * filename = the filename to unselect 1064 * 1065 * Since: 2.4 1066 */ 1067 public void unselectFilename(string filename); 1068 1069 /** 1070 * Unselects the file referred to by @uri. If the file 1071 * is not in the current directory, does not exist, or 1072 * is otherwise not currently selected, does nothing. 1073 * 1074 * Params: 1075 * uri = the URI to unselect 1076 * 1077 * Since: 2.4 1078 */ 1079 public void unselectUri(string uri); 1080 @property GtkFileChooserConfirmation delegate(FileChooserIF)[] onConfirmOverwriteListeners(); 1081 /** 1082 * This signal gets emitted whenever it is appropriate to present a 1083 * confirmation dialog when the user has selected a file name that 1084 * already exists. The signal only gets emitted when the file 1085 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode. 1086 * 1087 * Most applications just need to turn on the 1088 * #GtkFileChooser:do-overwrite-confirmation property (or call the 1089 * gtk_file_chooser_set_do_overwrite_confirmation() function), and 1090 * they will automatically get a stock confirmation dialog. 1091 * Applications which need to customize this behavior should do 1092 * that, and also connect to the #GtkFileChooser::confirm-overwrite 1093 * signal. 1094 * 1095 * A signal handler for this signal must return a 1096 * #GtkFileChooserConfirmation value, which indicates the action to 1097 * take. If the handler determines that the user wants to select a 1098 * different filename, it should return 1099 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines 1100 * that the user is satisfied with his choice of file name, it 1101 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME. 1102 * On the other hand, if it determines that the stock confirmation 1103 * dialog should be used, it should return 1104 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example 1105 * illustrates this. 1106 * 1107 * ## Custom confirmation ## {#gtkfilechooser-confirmation} 1108 * 1109 * |[<!-- language="C" --> 1110 * static GtkFileChooserConfirmation 1111 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data) 1112 * { 1113 * char *uri; 1114 * 1115 * uri = gtk_file_chooser_get_uri (chooser); 1116 * 1117 * if (is_uri_read_only (uri)) 1118 * { 1119 * if (user_wants_to_replace_read_only_file (uri)) 1120 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME; 1121 * else 1122 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN; 1123 * } else 1124 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog 1125 * } 1126 * 1127 * ... 1128 * 1129 * chooser = gtk_file_chooser_dialog_new (...); 1130 * 1131 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); 1132 * g_signal_connect (chooser, "confirm-overwrite", 1133 * G_CALLBACK (confirm_overwrite_callback), NULL); 1134 * 1135 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT) 1136 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); 1137 * 1138 * gtk_widget_destroy (chooser); 1139 * ]| 1140 * 1141 * Return: a #GtkFileChooserConfirmation value that indicates which 1142 * action to take after emitting the signal. 1143 * 1144 * Since: 2.8 1145 */ 1146 void addOnConfirmOverwrite(GtkFileChooserConfirmation delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 1147 1148 @property void delegate(FileChooserIF)[] onCurrentFolderChangedListeners(); 1149 /** 1150 * This signal is emitted when the current folder in a #GtkFileChooser 1151 * changes. This can happen due to the user performing some action that 1152 * changes folders, such as selecting a bookmark or visiting a folder on the 1153 * file list. It can also happen as a result of calling a function to 1154 * explicitly change the current folder in a file chooser. 1155 * 1156 * Normally you do not need to connect to this signal, unless you need to keep 1157 * track of which folder a file chooser is showing. 1158 * 1159 * See also: gtk_file_chooser_set_current_folder(), 1160 * gtk_file_chooser_get_current_folder(), 1161 * gtk_file_chooser_set_current_folder_uri(), 1162 * gtk_file_chooser_get_current_folder_uri(). 1163 */ 1164 void addOnCurrentFolderChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 1165 1166 @property void delegate(FileChooserIF)[] onFileActivatedListeners(); 1167 /** 1168 * This signal is emitted when the user "activates" a file in the file 1169 * chooser. This can happen by double-clicking on a file in the file list, or 1170 * by pressing `Enter`. 1171 * 1172 * Normally you do not need to connect to this signal. It is used internally 1173 * by #GtkFileChooserDialog to know when to activate the default button in the 1174 * dialog. 1175 * 1176 * See also: gtk_file_chooser_get_filename(), 1177 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(), 1178 * gtk_file_chooser_get_uris(). 1179 */ 1180 void addOnFileActivated(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 1181 1182 @property void delegate(FileChooserIF)[] onSelectionChangedListeners(); 1183 /** 1184 * This signal is emitted when there is a change in the set of selected files 1185 * in a #GtkFileChooser. This can happen when the user modifies the selection 1186 * with the mouse or the keyboard, or when explicitly calling functions to 1187 * change the selection. 1188 * 1189 * Normally you do not need to connect to this signal, as it is easier to wait 1190 * for the file chooser to finish running, and then to get the list of 1191 * selected files using the functions mentioned below. 1192 * 1193 * See also: gtk_file_chooser_select_filename(), 1194 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(), 1195 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(), 1196 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(), 1197 * gtk_file_chooser_get_uris(). 1198 */ 1199 void addOnSelectionChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 1200 1201 @property void delegate(FileChooserIF)[] onUpdatePreviewListeners(); 1202 /** 1203 * This signal is emitted when the preview in a file chooser should be 1204 * regenerated. For example, this can happen when the currently selected file 1205 * changes. You should use this signal if you want your file chooser to have 1206 * a preview widget. 1207 * 1208 * Once you have installed a preview widget with 1209 * gtk_file_chooser_set_preview_widget(), you should update it when this 1210 * signal is emitted. You can use the functions 1211 * gtk_file_chooser_get_preview_filename() or 1212 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview. 1213 * Your widget may not be able to preview all kinds of files; your callback 1214 * must call gtk_file_chooser_set_preview_widget_active() to inform the file 1215 * chooser about whether the preview was generated successfully or not. 1216 * 1217 * Please see the example code in 1218 * [Using a Preview Widget][gtkfilechooser-preview]. 1219 * 1220 * See also: gtk_file_chooser_set_preview_widget(), 1221 * gtk_file_chooser_set_preview_widget_active(), 1222 * gtk_file_chooser_set_use_preview_label(), 1223 * gtk_file_chooser_get_preview_filename(), 1224 * gtk_file_chooser_get_preview_uri(). 1225 */ 1226 void addOnUpdatePreview(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 1227 1228 }