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