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