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