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