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