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.FileChooserT; 26 27 public import gio.FileIF; 28 public import glib.ErrorG; 29 public import glib.GException; 30 public import glib.ListSG; 31 public import glib.Str; 32 public import gobject.ObjectG; 33 public import gobject.Signals; 34 public import gtk.FileFilter; 35 public import gtk.Widget; 36 public import gtk.c.functions; 37 public import gtk.c.types; 38 public import gtkc.gtktypes; 39 public 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 template FileChooserT(TStruct) 169 { 170 /** Get the main Gtk struct */ 171 public GtkFileChooser* getFileChooserStruct(bool transferOwnership = false) 172 { 173 if (transferOwnership) 174 ownedRef = false; 175 return cast(GtkFileChooser*)getStruct(); 176 } 177 178 179 /** 180 * Adds a 'choice' to the file chooser. This is typically implemented 181 * as a combobox or, for boolean choices, as a checkbutton. You can select 182 * a value using gtk_file_chooser_set_choice() before the dialog is shown, 183 * and you can obtain the user-selected value in the ::response signal handler 184 * using gtk_file_chooser_get_choice(). 185 * 186 * Compare gtk_file_chooser_set_extra_widget(). 187 * 188 * Params: 189 * id = id for the added choice 190 * label = user-visible label for the added choice 191 * options = ids for the options of the choice, or %NULL for a boolean choice 192 * optionLabels = user-visible labels for the options, must be the same length as @options 193 * 194 * Since: 3.22 195 */ 196 public void addChoice(string id, string label, string[] options, string[] optionLabels) 197 { 198 gtk_file_chooser_add_choice(getFileChooserStruct(), Str.toStringz(id), Str.toStringz(label), Str.toStringzArray(options), Str.toStringzArray(optionLabels)); 199 } 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 gtk_file_chooser_add_filter(getFileChooserStruct(), (filter is null) ? null : filter.getFileFilterStruct()); 217 } 218 219 /** 220 * Adds a folder to be displayed with the shortcut folders in a file chooser. 221 * Note that shortcut folders do not get saved, as they are provided by the 222 * application. For example, you can use this to add a 223 * “/usr/share/mydrawprogram/Clipart” folder to the volume list. 224 * 225 * Params: 226 * folder = filename of the folder to add 227 * 228 * Returns: %TRUE if the folder could be added successfully, %FALSE 229 * otherwise. In the latter case, the @error will be set as appropriate. 230 * 231 * Since: 2.4 232 * 233 * Throws: GException on failure. 234 */ 235 public bool addShortcutFolder(string folder) 236 { 237 GError* err = null; 238 239 auto p = gtk_file_chooser_add_shortcut_folder(getFileChooserStruct(), Str.toStringz(folder), &err) != 0; 240 241 if (err !is null) 242 { 243 throw new GException( new ErrorG(err) ); 244 } 245 246 return p; 247 } 248 249 /** 250 * Adds a folder URI to be displayed with the shortcut folders in a file 251 * chooser. Note that shortcut folders do not get saved, as they are provided 252 * by the application. For example, you can use this to add a 253 * “file:///usr/share/mydrawprogram/Clipart” folder to the volume list. 254 * 255 * Params: 256 * uri = URI of the folder to add 257 * 258 * Returns: %TRUE if the folder could be added successfully, %FALSE 259 * otherwise. In the latter case, the @error will be set as appropriate. 260 * 261 * Since: 2.4 262 * 263 * Throws: GException on failure. 264 */ 265 public bool addShortcutFolderUri(string uri) 266 { 267 GError* err = null; 268 269 auto p = gtk_file_chooser_add_shortcut_folder_uri(getFileChooserStruct(), Str.toStringz(uri), &err) != 0; 270 271 if (err !is null) 272 { 273 throw new GException( new ErrorG(err) ); 274 } 275 276 return p; 277 } 278 279 /** 280 * Gets the type of operation that the file chooser is performing; see 281 * gtk_file_chooser_set_action(). 282 * 283 * Returns: the action that the file selector is performing 284 * 285 * Since: 2.4 286 */ 287 public GtkFileChooserAction getFileChooserAction() 288 { 289 return gtk_file_chooser_get_action(getFileChooserStruct()); 290 } 291 292 /** 293 * Gets the currently selected option in the 'choice' with the given ID. 294 * 295 * Params: 296 * id = the ID of the choice to get 297 * 298 * Returns: the ID of the currenly selected option 299 * 300 * Since: 3.22 301 */ 302 public string getChoice(string id) 303 { 304 return Str.toString(gtk_file_chooser_get_choice(getFileChooserStruct(), Str.toStringz(id))); 305 } 306 307 /** 308 * Gets whether file choser will offer to create new folders. 309 * See gtk_file_chooser_set_create_folders(). 310 * 311 * Returns: %TRUE if the Create Folder button should be displayed. 312 * 313 * Since: 2.18 314 */ 315 public bool getCreateFolders() 316 { 317 return gtk_file_chooser_get_create_folders(getFileChooserStruct()) != 0; 318 } 319 320 /** 321 * Gets the current folder of @chooser as a local filename. 322 * See gtk_file_chooser_set_current_folder(). 323 * 324 * Note that this is the folder that the file chooser is currently displaying 325 * (e.g. "/home/username/Documents"), which is not the same 326 * as the currently-selected folder if the chooser is in 327 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode 328 * (e.g. "/home/username/Documents/selected-folder/". To get the 329 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 330 * usual way to get the selection. 331 * 332 * Returns: the full path of the current 333 * folder, or %NULL if the current path cannot be represented as a local 334 * filename. Free with g_free(). This function will also return 335 * %NULL if the file chooser was unable to load the last folder that 336 * was requested from it; for example, as would be for calling 337 * gtk_file_chooser_set_current_folder() on a nonexistent folder. 338 * 339 * Since: 2.4 340 */ 341 public string getCurrentFolder() 342 { 343 auto retStr = gtk_file_chooser_get_current_folder(getFileChooserStruct()); 344 345 scope(exit) Str.freeString(retStr); 346 return Str.toString(retStr); 347 } 348 349 /** 350 * Gets the current folder of @chooser as #GFile. 351 * See gtk_file_chooser_get_current_folder_uri(). 352 * 353 * Returns: the #GFile for the current folder. 354 * 355 * Since: 2.14 356 */ 357 public FileIF getCurrentFolderFile() 358 { 359 auto p = gtk_file_chooser_get_current_folder_file(getFileChooserStruct()); 360 361 if(p is null) 362 { 363 return null; 364 } 365 366 return ObjectG.getDObject!(FileIF)(cast(GFile*) p, true); 367 } 368 369 /** 370 * Gets the current folder of @chooser as an URI. 371 * See gtk_file_chooser_set_current_folder_uri(). 372 * 373 * Note that this is the folder that the file chooser is currently displaying 374 * (e.g. "file:///home/username/Documents"), which is not the same 375 * as the currently-selected folder if the chooser is in 376 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode 377 * (e.g. "file:///home/username/Documents/selected-folder/". To get the 378 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 379 * usual way to get the selection. 380 * 381 * Returns: the URI for the current folder. 382 * Free with g_free(). This function will also return %NULL if the file chooser 383 * was unable to load the last folder that was requested from it; for example, 384 * as would be for calling gtk_file_chooser_set_current_folder_uri() on a 385 * nonexistent folder. 386 * 387 * Since: 2.4 388 */ 389 public string getCurrentFolderUri() 390 { 391 auto retStr = gtk_file_chooser_get_current_folder_uri(getFileChooserStruct()); 392 393 scope(exit) Str.freeString(retStr); 394 return Str.toString(retStr); 395 } 396 397 /** 398 * Gets the current name in the file selector, as entered by the user in the 399 * text entry for “Name”. 400 * 401 * This is meant to be used in save dialogs, to get the currently typed filename 402 * when the file itself does not exist yet. For example, an application that 403 * adds a custom extra widget to the file chooser for “file format” may want to 404 * change the extension of the typed filename based on the chosen format, say, 405 * from “.jpg” to “.png”. 406 * 407 * Returns: The raw text from the file chooser’s “Name” entry. Free this with 408 * g_free(). Note that this string is not a full pathname or URI; it is 409 * whatever the contents of the entry are. Note also that this string is in 410 * UTF-8 encoding, which is not necessarily the system’s encoding for filenames. 411 * 412 * Since: 3.10 413 */ 414 public string getCurrentName() 415 { 416 auto retStr = gtk_file_chooser_get_current_name(getFileChooserStruct()); 417 418 scope(exit) Str.freeString(retStr); 419 return Str.toString(retStr); 420 } 421 422 /** 423 * Queries whether a file chooser is set to confirm for overwriting when the user 424 * types a file name that already exists. 425 * 426 * Returns: %TRUE if the file chooser will present a confirmation dialog; 427 * %FALSE otherwise. 428 * 429 * Since: 2.8 430 */ 431 public bool getDoOverwriteConfirmation() 432 { 433 return gtk_file_chooser_get_do_overwrite_confirmation(getFileChooserStruct()) != 0; 434 } 435 436 /** 437 * Gets the current extra widget; see 438 * gtk_file_chooser_set_extra_widget(). 439 * 440 * Returns: the current extra widget, or %NULL 441 * 442 * Since: 2.4 443 */ 444 public Widget getExtraWidget() 445 { 446 auto p = gtk_file_chooser_get_extra_widget(getFileChooserStruct()); 447 448 if(p is null) 449 { 450 return null; 451 } 452 453 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 454 } 455 456 /** 457 * Gets the #GFile for the currently selected file in 458 * the file selector. If multiple files are selected, 459 * one of the files will be returned at random. 460 * 461 * If the file chooser is in folder mode, this function returns the selected 462 * folder. 463 * 464 * Returns: a selected #GFile. You own the returned file; 465 * use g_object_unref() to release it. 466 * 467 * Since: 2.14 468 */ 469 public FileIF getFile() 470 { 471 auto p = gtk_file_chooser_get_file(getFileChooserStruct()); 472 473 if(p is null) 474 { 475 return null; 476 } 477 478 return ObjectG.getDObject!(FileIF)(cast(GFile*) p, true); 479 } 480 481 /** 482 * Gets the filename for the currently selected file in 483 * the file selector. The filename is returned as an absolute path. If 484 * multiple files are selected, one of the filenames will be returned at 485 * random. 486 * 487 * If the file chooser is in folder mode, this function returns the selected 488 * folder. 489 * 490 * Returns: The currently selected filename, 491 * or %NULL if no file is selected, or the selected file can't 492 * be represented with a local filename. Free with g_free(). 493 * 494 * Since: 2.4 495 */ 496 public string getFilename() 497 { 498 auto retStr = gtk_file_chooser_get_filename(getFileChooserStruct()); 499 500 scope(exit) Str.freeString(retStr); 501 return Str.toString(retStr); 502 } 503 504 /** 505 * Lists all the selected files and subfolders in the current folder of 506 * @chooser. The returned names are full absolute paths. If files in the current 507 * folder cannot be represented as local filenames they will be ignored. (See 508 * gtk_file_chooser_get_uris()) 509 * 510 * Returns: a #GSList 511 * containing the filenames of all selected files and subfolders in 512 * the current folder. Free the returned list with g_slist_free(), 513 * and the filenames with g_free(). 514 * 515 * Since: 2.4 516 */ 517 public ListSG getFilenames() 518 { 519 auto p = gtk_file_chooser_get_filenames(getFileChooserStruct()); 520 521 if(p is null) 522 { 523 return null; 524 } 525 526 return new ListSG(cast(GSList*) p, true); 527 } 528 529 /** 530 * Lists all the selected files and subfolders in the current folder of @chooser 531 * as #GFile. An internal function, see gtk_file_chooser_get_uris(). 532 * 533 * Returns: a #GSList 534 * containing a #GFile for each selected file and subfolder in the 535 * current folder. Free the returned list with g_slist_free(), and 536 * the files with g_object_unref(). 537 * 538 * Since: 2.14 539 */ 540 public ListSG getFiles() 541 { 542 auto p = gtk_file_chooser_get_files(getFileChooserStruct()); 543 544 if(p is null) 545 { 546 return null; 547 } 548 549 return new ListSG(cast(GSList*) p, true); 550 } 551 552 /** 553 * Gets the current filter; see gtk_file_chooser_set_filter(). 554 * 555 * Returns: the current filter, or %NULL 556 * 557 * Since: 2.4 558 */ 559 public FileFilter getFilter() 560 { 561 auto p = gtk_file_chooser_get_filter(getFileChooserStruct()); 562 563 if(p is null) 564 { 565 return null; 566 } 567 568 return ObjectG.getDObject!(FileFilter)(cast(GtkFileFilter*) p); 569 } 570 571 /** 572 * Gets whether only local files can be selected in the 573 * file selector. See gtk_file_chooser_set_local_only() 574 * 575 * Returns: %TRUE if only local files can be selected. 576 * 577 * Since: 2.4 578 */ 579 public bool getLocalOnly() 580 { 581 return gtk_file_chooser_get_local_only(getFileChooserStruct()) != 0; 582 } 583 584 /** 585 * Gets the #GFile that should be previewed in a custom preview 586 * Internal function, see gtk_file_chooser_get_preview_uri(). 587 * 588 * Returns: the #GFile for the file to preview, 589 * or %NULL if no file is selected. Free with g_object_unref(). 590 * 591 * Since: 2.14 592 */ 593 public FileIF getPreviewFile() 594 { 595 auto p = gtk_file_chooser_get_preview_file(getFileChooserStruct()); 596 597 if(p is null) 598 { 599 return null; 600 } 601 602 return ObjectG.getDObject!(FileIF)(cast(GFile*) p, true); 603 } 604 605 /** 606 * Gets the filename that should be previewed in a custom preview 607 * widget. See gtk_file_chooser_set_preview_widget(). 608 * 609 * Returns: the filename to preview, or %NULL if 610 * no file is selected, or if the selected file cannot be represented 611 * as a local filename. Free with g_free() 612 * 613 * Since: 2.4 614 */ 615 public string getPreviewFilename() 616 { 617 auto retStr = gtk_file_chooser_get_preview_filename(getFileChooserStruct()); 618 619 scope(exit) Str.freeString(retStr); 620 return Str.toString(retStr); 621 } 622 623 /** 624 * Gets the URI that should be previewed in a custom preview 625 * widget. See gtk_file_chooser_set_preview_widget(). 626 * 627 * Returns: the URI for the file to preview, 628 * or %NULL if no file is selected. Free with g_free(). 629 * 630 * Since: 2.4 631 */ 632 public string getPreviewUri() 633 { 634 auto retStr = gtk_file_chooser_get_preview_uri(getFileChooserStruct()); 635 636 scope(exit) Str.freeString(retStr); 637 return Str.toString(retStr); 638 } 639 640 /** 641 * Gets the current preview widget; see 642 * gtk_file_chooser_set_preview_widget(). 643 * 644 * Returns: the current preview widget, or %NULL 645 * 646 * Since: 2.4 647 */ 648 public Widget getPreviewWidget() 649 { 650 auto p = gtk_file_chooser_get_preview_widget(getFileChooserStruct()); 651 652 if(p is null) 653 { 654 return null; 655 } 656 657 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 658 } 659 660 /** 661 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget() 662 * should be shown for the current filename. See 663 * gtk_file_chooser_set_preview_widget_active(). 664 * 665 * Returns: %TRUE if the preview widget is active for the current filename. 666 * 667 * Since: 2.4 668 */ 669 public bool getPreviewWidgetActive() 670 { 671 return gtk_file_chooser_get_preview_widget_active(getFileChooserStruct()) != 0; 672 } 673 674 /** 675 * Gets whether multiple files can be selected in the file 676 * selector. See gtk_file_chooser_set_select_multiple(). 677 * 678 * Returns: %TRUE if multiple files can be selected. 679 * 680 * Since: 2.4 681 */ 682 public bool getSelectMultiple() 683 { 684 return gtk_file_chooser_get_select_multiple(getFileChooserStruct()) != 0; 685 } 686 687 /** 688 * Gets whether hidden files and folders are displayed in the file selector. 689 * See gtk_file_chooser_set_show_hidden(). 690 * 691 * Returns: %TRUE if hidden files and folders are displayed. 692 * 693 * Since: 2.6 694 */ 695 public bool getShowHidden() 696 { 697 return gtk_file_chooser_get_show_hidden(getFileChooserStruct()) != 0; 698 } 699 700 /** 701 * Gets the URI for the currently selected file in 702 * the file selector. If multiple files are selected, 703 * one of the filenames will be returned at random. 704 * 705 * If the file chooser is in folder mode, this function returns the selected 706 * folder. 707 * 708 * Returns: The currently selected URI, or %NULL 709 * if no file is selected. If gtk_file_chooser_set_local_only() is set to 710 * %TRUE (the default) a local URI will be returned for any FUSE locations. 711 * Free with g_free() 712 * 713 * Since: 2.4 714 */ 715 public string getUri() 716 { 717 auto retStr = gtk_file_chooser_get_uri(getFileChooserStruct()); 718 719 scope(exit) Str.freeString(retStr); 720 return Str.toString(retStr); 721 } 722 723 /** 724 * Lists all the selected files and subfolders in the current folder of 725 * @chooser. The returned names are full absolute URIs. 726 * 727 * Returns: a #GSList containing the URIs of all selected 728 * files and subfolders in the current folder. Free the returned list 729 * with g_slist_free(), and the filenames with g_free(). 730 * 731 * Since: 2.4 732 */ 733 public ListSG getUris() 734 { 735 auto p = gtk_file_chooser_get_uris(getFileChooserStruct()); 736 737 if(p is null) 738 { 739 return null; 740 } 741 742 return new ListSG(cast(GSList*) p, true); 743 } 744 745 /** 746 * Gets whether a stock label should be drawn with the name of the previewed 747 * file. See gtk_file_chooser_set_use_preview_label(). 748 * 749 * Returns: %TRUE if the file chooser is set to display a label with the 750 * name of the previewed file, %FALSE otherwise. 751 */ 752 public bool getUsePreviewLabel() 753 { 754 return gtk_file_chooser_get_use_preview_label(getFileChooserStruct()) != 0; 755 } 756 757 /** 758 * Lists the current set of user-selectable filters; see 759 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter(). 760 * 761 * Returns: a 762 * #GSList containing the current set of user selectable filters. The 763 * contents of the list are owned by GTK+, but you must free the list 764 * itself with g_slist_free() when you are done with it. 765 * 766 * Since: 2.4 767 */ 768 public ListSG listFilters() 769 { 770 auto p = gtk_file_chooser_list_filters(getFileChooserStruct()); 771 772 if(p is null) 773 { 774 return null; 775 } 776 777 return new ListSG(cast(GSList*) p); 778 } 779 780 /** 781 * Queries the list of shortcut folders in the file chooser, as set by 782 * gtk_file_chooser_add_shortcut_folder_uri(). 783 * 784 * Returns: A list of 785 * folder URIs, or %NULL if there are no shortcut folders. Free the 786 * returned list with g_slist_free(), and the URIs with g_free(). 787 * 788 * Since: 2.4 789 */ 790 public ListSG listShortcutFolderUris() 791 { 792 auto p = gtk_file_chooser_list_shortcut_folder_uris(getFileChooserStruct()); 793 794 if(p is null) 795 { 796 return null; 797 } 798 799 return new ListSG(cast(GSList*) p, true); 800 } 801 802 /** 803 * Queries the list of shortcut folders in the file chooser, as set by 804 * gtk_file_chooser_add_shortcut_folder(). 805 * 806 * Returns: A list 807 * of folder filenames, or %NULL if there are no shortcut folders. 808 * Free the returned list with g_slist_free(), and the filenames with 809 * g_free(). 810 * 811 * Since: 2.4 812 */ 813 public ListSG listShortcutFolders() 814 { 815 auto p = gtk_file_chooser_list_shortcut_folders(getFileChooserStruct()); 816 817 if(p is null) 818 { 819 return null; 820 } 821 822 return new ListSG(cast(GSList*) p, true); 823 } 824 825 /** 826 * Removes a 'choice' that has been added with gtk_file_chooser_add_choice(). 827 * 828 * Params: 829 * id = the ID of the choice to remove 830 * 831 * Since: 3.22 832 */ 833 public void removeChoice(string id) 834 { 835 gtk_file_chooser_remove_choice(getFileChooserStruct(), Str.toStringz(id)); 836 } 837 838 /** 839 * Removes @filter from the list of filters that the user can select between. 840 * 841 * Params: 842 * filter = a #GtkFileFilter 843 * 844 * Since: 2.4 845 */ 846 public void removeFilter(FileFilter filter) 847 { 848 gtk_file_chooser_remove_filter(getFileChooserStruct(), (filter is null) ? null : filter.getFileFilterStruct()); 849 } 850 851 /** 852 * Removes a folder from a file chooser’s list of shortcut folders. 853 * 854 * Params: 855 * folder = filename of the folder to remove 856 * 857 * Returns: %TRUE if the operation succeeds, %FALSE otherwise. 858 * In the latter case, the @error will be set as appropriate. 859 * 860 * See also: gtk_file_chooser_add_shortcut_folder() 861 * 862 * Since: 2.4 863 * 864 * Throws: GException on failure. 865 */ 866 public bool removeShortcutFolder(string folder) 867 { 868 GError* err = null; 869 870 auto p = gtk_file_chooser_remove_shortcut_folder(getFileChooserStruct(), Str.toStringz(folder), &err) != 0; 871 872 if (err !is null) 873 { 874 throw new GException( new ErrorG(err) ); 875 } 876 877 return p; 878 } 879 880 /** 881 * Removes a folder URI from a file chooser’s list of shortcut folders. 882 * 883 * Params: 884 * uri = URI of the folder to remove 885 * 886 * Returns: %TRUE if the operation succeeds, %FALSE otherwise. 887 * In the latter case, the @error will be set as appropriate. 888 * 889 * See also: gtk_file_chooser_add_shortcut_folder_uri() 890 * 891 * Since: 2.4 892 * 893 * Throws: GException on failure. 894 */ 895 public bool removeShortcutFolderUri(string uri) 896 { 897 GError* err = null; 898 899 auto p = gtk_file_chooser_remove_shortcut_folder_uri(getFileChooserStruct(), Str.toStringz(uri), &err) != 0; 900 901 if (err !is null) 902 { 903 throw new GException( new ErrorG(err) ); 904 } 905 906 return p; 907 } 908 909 /** 910 * Selects all the files in the current folder of a file chooser. 911 * 912 * Since: 2.4 913 */ 914 public void selectAll() 915 { 916 gtk_file_chooser_select_all(getFileChooserStruct()); 917 } 918 919 /** 920 * Selects the file referred to by @file. An internal function. See 921 * _gtk_file_chooser_select_uri(). 922 * 923 * Params: 924 * file = the file to select 925 * 926 * Returns: Not useful. 927 * 928 * Since: 2.14 929 * 930 * Throws: GException on failure. 931 */ 932 public bool selectFile(FileIF file) 933 { 934 GError* err = null; 935 936 auto p = gtk_file_chooser_select_file(getFileChooserStruct(), (file is null) ? null : file.getFileStruct(), &err) != 0; 937 938 if (err !is null) 939 { 940 throw new GException( new ErrorG(err) ); 941 } 942 943 return p; 944 } 945 946 /** 947 * Selects a filename. If the file name isn’t in the current 948 * folder of @chooser, then the current folder of @chooser will 949 * be changed to the folder containing @filename. 950 * 951 * Params: 952 * filename = the filename to select 953 * 954 * Returns: Not useful. 955 * 956 * See also: gtk_file_chooser_set_filename() 957 * 958 * Since: 2.4 959 */ 960 public bool selectFilename(string filename) 961 { 962 return gtk_file_chooser_select_filename(getFileChooserStruct(), Str.toStringz(filename)) != 0; 963 } 964 965 /** 966 * Selects the file to by @uri. If the URI doesn’t refer to a 967 * file in the current folder of @chooser, then the current folder of 968 * @chooser will be changed to the folder containing @filename. 969 * 970 * Params: 971 * uri = the URI to select 972 * 973 * Returns: Not useful. 974 * 975 * Since: 2.4 976 */ 977 public bool selectUri(string uri) 978 { 979 return gtk_file_chooser_select_uri(getFileChooserStruct(), Str.toStringz(uri)) != 0; 980 } 981 982 /** 983 * Sets the type of operation that the chooser is performing; the 984 * user interface is adapted to suit the selected action. For example, 985 * an option to create a new folder might be shown if the action is 986 * %GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is 987 * %GTK_FILE_CHOOSER_ACTION_OPEN. 988 * 989 * Params: 990 * action = the action that the file selector is performing 991 * 992 * Since: 2.4 993 */ 994 public void setFileChooserAction(GtkFileChooserAction action) 995 { 996 gtk_file_chooser_set_action(getFileChooserStruct(), action); 997 } 998 999 /** 1000 * Selects an option in a 'choice' that has been added with 1001 * gtk_file_chooser_add_choice(). For a boolean choice, the 1002 * possible options are "true" and "false". 1003 * 1004 * Params: 1005 * id = the ID of the choice to set 1006 * option = the ID of the option to select 1007 * 1008 * Since: 3.22 1009 */ 1010 public void setChoice(string id, string option) 1011 { 1012 gtk_file_chooser_set_choice(getFileChooserStruct(), Str.toStringz(id), Str.toStringz(option)); 1013 } 1014 1015 /** 1016 * Sets whether file choser will offer to create new folders. 1017 * This is only relevant if the action is not set to be 1018 * %GTK_FILE_CHOOSER_ACTION_OPEN. 1019 * 1020 * Params: 1021 * createFolders = %TRUE if the Create Folder button should be displayed 1022 * 1023 * Since: 2.18 1024 */ 1025 public void setCreateFolders(bool createFolders) 1026 { 1027 gtk_file_chooser_set_create_folders(getFileChooserStruct(), createFolders); 1028 } 1029 1030 /** 1031 * Sets the current folder for @chooser from a local filename. 1032 * The user will be shown the full contents of the current folder, 1033 * plus user interface elements for navigating to other folders. 1034 * 1035 * In general, you should not use this function. See the 1036 * [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up] 1037 * for the rationale behind this. 1038 * 1039 * Params: 1040 * filename = the full path of the new current folder 1041 * 1042 * Returns: Not useful. 1043 * 1044 * Since: 2.4 1045 */ 1046 public bool setCurrentFolder(string filename) 1047 { 1048 return gtk_file_chooser_set_current_folder(getFileChooserStruct(), Str.toStringz(filename)) != 0; 1049 } 1050 1051 /** 1052 * Sets the current folder for @chooser from a #GFile. 1053 * Internal function, see gtk_file_chooser_set_current_folder_uri(). 1054 * 1055 * Params: 1056 * file = the #GFile for the new folder 1057 * 1058 * Returns: %TRUE if the folder could be changed successfully, %FALSE 1059 * otherwise. 1060 * 1061 * Since: 2.14 1062 * 1063 * Throws: GException on failure. 1064 */ 1065 public bool setCurrentFolderFile(FileIF file) 1066 { 1067 GError* err = null; 1068 1069 auto p = gtk_file_chooser_set_current_folder_file(getFileChooserStruct(), (file is null) ? null : file.getFileStruct(), &err) != 0; 1070 1071 if (err !is null) 1072 { 1073 throw new GException( new ErrorG(err) ); 1074 } 1075 1076 return p; 1077 } 1078 1079 /** 1080 * Sets the current folder for @chooser from an URI. 1081 * The user will be shown the full contents of the current folder, 1082 * plus user interface elements for navigating to other folders. 1083 * 1084 * In general, you should not use this function. See the 1085 * [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up] 1086 * for the rationale behind this. 1087 * 1088 * Params: 1089 * uri = the URI for the new current folder 1090 * 1091 * Returns: %TRUE if the folder could be changed successfully, %FALSE 1092 * otherwise. 1093 * 1094 * Since: 2.4 1095 */ 1096 public bool setCurrentFolderUri(string uri) 1097 { 1098 return gtk_file_chooser_set_current_folder_uri(getFileChooserStruct(), Str.toStringz(uri)) != 0; 1099 } 1100 1101 /** 1102 * Sets the current name in the file selector, as if entered 1103 * by the user. Note that the name passed in here is a UTF-8 1104 * string rather than a filename. This function is meant for 1105 * such uses as a suggested name in a “Save As...” dialog. You can 1106 * pass “Untitled.doc” or a similarly suitable suggestion for the @name. 1107 * 1108 * If you want to preselect a particular existing file, you should use 1109 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead. 1110 * Please see the documentation for those functions for an example of using 1111 * gtk_file_chooser_set_current_name() as well. 1112 * 1113 * Params: 1114 * name = the filename to use, as a UTF-8 string 1115 * 1116 * Since: 2.4 1117 */ 1118 public void setCurrentName(string name) 1119 { 1120 gtk_file_chooser_set_current_name(getFileChooserStruct(), Str.toStringz(name)); 1121 } 1122 1123 /** 1124 * Sets whether a file chooser in %GTK_FILE_CHOOSER_ACTION_SAVE mode will present 1125 * a confirmation dialog if the user types a file name that already exists. This 1126 * is %FALSE by default. 1127 * 1128 * If set to %TRUE, the @chooser will emit the 1129 * #GtkFileChooser::confirm-overwrite signal when appropriate. 1130 * 1131 * If all you need is the stock confirmation dialog, set this property to %TRUE. 1132 * You can override the way confirmation is done by actually handling the 1133 * #GtkFileChooser::confirm-overwrite signal; please refer to its documentation 1134 * for the details. 1135 * 1136 * Params: 1137 * doOverwriteConfirmation = whether to confirm overwriting in save mode 1138 * 1139 * Since: 2.8 1140 */ 1141 public void setDoOverwriteConfirmation(bool doOverwriteConfirmation) 1142 { 1143 gtk_file_chooser_set_do_overwrite_confirmation(getFileChooserStruct(), doOverwriteConfirmation); 1144 } 1145 1146 /** 1147 * Sets an application-supplied widget to provide extra options to the user. 1148 * 1149 * Params: 1150 * extraWidget = widget for extra options 1151 * 1152 * Since: 2.4 1153 */ 1154 public void setExtraWidget(Widget extraWidget) 1155 { 1156 gtk_file_chooser_set_extra_widget(getFileChooserStruct(), (extraWidget is null) ? null : extraWidget.getWidgetStruct()); 1157 } 1158 1159 /** 1160 * Sets @file as the current filename for the file chooser, by changing 1161 * to the file’s parent folder and actually selecting the file in list. If 1162 * the @chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file’s base name 1163 * will also appear in the dialog’s file name entry. 1164 * 1165 * If the file name isn’t in the current folder of @chooser, then the current 1166 * folder of @chooser will be changed to the folder containing @filename. This 1167 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by 1168 * gtk_file_chooser_select_filename(). 1169 * 1170 * Note that the file must exist, or nothing will be done except 1171 * for the directory change. 1172 * 1173 * If you are implementing a save dialog, 1174 * you should use this function if you already have a file name to which the 1175 * user may save; for example, when the user opens an existing file and then 1176 * does Save As... If you don’t have 1177 * a file name already — for example, if the user just created a new 1178 * file and is saving it for the first time, do not call this function. 1179 * Instead, use something similar to this: 1180 * |[<!-- language="C" --> 1181 * if (document_is_new) 1182 * { 1183 * // the user just created a new document 1184 * gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving); 1185 * gtk_file_chooser_set_current_name (chooser, "Untitled document"); 1186 * } 1187 * else 1188 * { 1189 * // the user edited an existing document 1190 * gtk_file_chooser_set_file (chooser, existing_file); 1191 * } 1192 * ]| 1193 * 1194 * Params: 1195 * file = the #GFile to set as current 1196 * 1197 * Returns: Not useful. 1198 * 1199 * Since: 2.14 1200 * 1201 * Throws: GException on failure. 1202 */ 1203 public bool setFile(FileIF file) 1204 { 1205 GError* err = null; 1206 1207 auto p = gtk_file_chooser_set_file(getFileChooserStruct(), (file is null) ? null : file.getFileStruct(), &err) != 0; 1208 1209 if (err !is null) 1210 { 1211 throw new GException( new ErrorG(err) ); 1212 } 1213 1214 return p; 1215 } 1216 1217 /** 1218 * Sets @filename as the current filename for the file chooser, by changing to 1219 * the file’s parent folder and actually selecting the file in list; all other 1220 * files will be unselected. If the @chooser is in 1221 * %GTK_FILE_CHOOSER_ACTION_SAVE mode, the file’s base name will also appear in 1222 * the dialog’s file name entry. 1223 * 1224 * Note that the file must exist, or nothing will be done except 1225 * for the directory change. 1226 * 1227 * You should use this function only when implementing a save 1228 * dialog for which you already have a file name to which 1229 * the user may save. For example, when the user opens an existing file and 1230 * then does Save As... to save a copy or 1231 * a modified version. If you don’t have a file name already — for 1232 * example, if the user just created a new file and is saving it for the first 1233 * time, do not call this function. Instead, use something similar to this: 1234 * |[<!-- language="C" --> 1235 * if (document_is_new) 1236 * { 1237 * // the user just created a new document 1238 * gtk_file_chooser_set_current_name (chooser, "Untitled document"); 1239 * } 1240 * else 1241 * { 1242 * // the user edited an existing document 1243 * gtk_file_chooser_set_filename (chooser, existing_filename); 1244 * } 1245 * ]| 1246 * 1247 * In the first case, the file chooser will present the user with useful suggestions 1248 * as to where to save his new file. In the second case, the file’s existing location 1249 * is already known, so the file chooser will use it. 1250 * 1251 * Params: 1252 * filename = the filename to set as current 1253 * 1254 * Returns: Not useful. 1255 * 1256 * Since: 2.4 1257 */ 1258 public bool setFilename(string filename) 1259 { 1260 return gtk_file_chooser_set_filename(getFileChooserStruct(), Str.toStringz(filename)) != 0; 1261 } 1262 1263 /** 1264 * Sets the current filter; only the files that pass the 1265 * filter will be displayed. If the user-selectable list of filters 1266 * is non-empty, then the filter should be one of the filters 1267 * in that list. Setting the current filter when the list of 1268 * filters is empty is useful if you want to restrict the displayed 1269 * set of files without letting the user change it. 1270 * 1271 * Params: 1272 * filter = a #GtkFileFilter 1273 * 1274 * Since: 2.4 1275 */ 1276 public void setFilter(FileFilter filter) 1277 { 1278 gtk_file_chooser_set_filter(getFileChooserStruct(), (filter is null) ? null : filter.getFileFilterStruct()); 1279 } 1280 1281 /** 1282 * Sets whether only local files can be selected in the 1283 * file selector. If @local_only is %TRUE (the default), 1284 * then the selected file or files are guaranteed to be 1285 * accessible through the operating systems native file 1286 * system and therefore the application only 1287 * needs to worry about the filename functions in 1288 * #GtkFileChooser, like gtk_file_chooser_get_filename(), 1289 * rather than the URI functions like 1290 * gtk_file_chooser_get_uri(), 1291 * 1292 * On some systems non-native files may still be 1293 * available using the native filesystem via a userspace 1294 * filesystem (FUSE). 1295 * 1296 * Params: 1297 * localOnly = %TRUE if only local files can be selected 1298 * 1299 * Since: 2.4 1300 */ 1301 public void setLocalOnly(bool localOnly) 1302 { 1303 gtk_file_chooser_set_local_only(getFileChooserStruct(), localOnly); 1304 } 1305 1306 /** 1307 * Sets an application-supplied widget to use to display a custom preview 1308 * of the currently selected file. To implement a preview, after setting the 1309 * preview widget, you connect to the #GtkFileChooser::update-preview 1310 * signal, and call gtk_file_chooser_get_preview_filename() or 1311 * gtk_file_chooser_get_preview_uri() on each change. If you can 1312 * display a preview of the new file, update your widget and 1313 * set the preview active using gtk_file_chooser_set_preview_widget_active(). 1314 * Otherwise, set the preview inactive. 1315 * 1316 * When there is no application-supplied preview widget, or the 1317 * application-supplied preview widget is not active, the file chooser 1318 * will display no preview at all. 1319 * 1320 * Params: 1321 * previewWidget = widget for displaying preview. 1322 * 1323 * Since: 2.4 1324 */ 1325 public void setPreviewWidget(Widget previewWidget) 1326 { 1327 gtk_file_chooser_set_preview_widget(getFileChooserStruct(), (previewWidget is null) ? null : previewWidget.getWidgetStruct()); 1328 } 1329 1330 /** 1331 * Sets whether the preview widget set by 1332 * gtk_file_chooser_set_preview_widget() should be shown for the 1333 * current filename. When @active is set to false, the file chooser 1334 * may display an internally generated preview of the current file 1335 * or it may display no preview at all. See 1336 * gtk_file_chooser_set_preview_widget() for more details. 1337 * 1338 * Params: 1339 * active = whether to display the user-specified preview widget 1340 * 1341 * Since: 2.4 1342 */ 1343 public void setPreviewWidgetActive(bool active) 1344 { 1345 gtk_file_chooser_set_preview_widget_active(getFileChooserStruct(), active); 1346 } 1347 1348 /** 1349 * Sets whether multiple files can be selected in the file selector. This is 1350 * only relevant if the action is set to be %GTK_FILE_CHOOSER_ACTION_OPEN or 1351 * %GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER. 1352 * 1353 * Params: 1354 * selectMultiple = %TRUE if multiple files can be selected. 1355 * 1356 * Since: 2.4 1357 */ 1358 public void setSelectMultiple(bool selectMultiple) 1359 { 1360 gtk_file_chooser_set_select_multiple(getFileChooserStruct(), selectMultiple); 1361 } 1362 1363 /** 1364 * Sets whether hidden files and folders are displayed in the file selector. 1365 * 1366 * Params: 1367 * showHidden = %TRUE if hidden files and folders should be displayed. 1368 * 1369 * Since: 2.6 1370 */ 1371 public void setShowHidden(bool showHidden) 1372 { 1373 gtk_file_chooser_set_show_hidden(getFileChooserStruct(), showHidden); 1374 } 1375 1376 /** 1377 * Sets the file referred to by @uri as the current file for the file chooser, 1378 * by changing to the URI’s parent folder and actually selecting the URI in the 1379 * list. If the @chooser is %GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI’s base 1380 * name will also appear in the dialog’s file name entry. 1381 * 1382 * Note that the URI must exist, or nothing will be done except for the 1383 * directory change. 1384 * 1385 * You should use this function only when implementing a save 1386 * dialog for which you already have a file name to which 1387 * the user may save. For example, when the user opens an existing file and then 1388 * does Save As... to save a copy or a 1389 * modified version. If you don’t have a file name already — for example, 1390 * if the user just created a new file and is saving it for the first time, do 1391 * not call this function. Instead, use something similar to this: 1392 * |[<!-- language="C" --> 1393 * if (document_is_new) 1394 * { 1395 * // the user just created a new document 1396 * gtk_file_chooser_set_current_name (chooser, "Untitled document"); 1397 * } 1398 * else 1399 * { 1400 * // the user edited an existing document 1401 * gtk_file_chooser_set_uri (chooser, existing_uri); 1402 * } 1403 * ]| 1404 * 1405 * 1406 * In the first case, the file chooser will present the user with useful suggestions 1407 * as to where to save his new file. In the second case, the file’s existing location 1408 * is already known, so the file chooser will use it. 1409 * 1410 * Params: 1411 * uri = the URI to set as current 1412 * 1413 * Returns: Not useful. 1414 * 1415 * Since: 2.4 1416 */ 1417 public bool setUri(string uri) 1418 { 1419 return gtk_file_chooser_set_uri(getFileChooserStruct(), Str.toStringz(uri)) != 0; 1420 } 1421 1422 /** 1423 * Sets whether the file chooser should display a stock label with the name of 1424 * the file that is being previewed; the default is %TRUE. Applications that 1425 * want to draw the whole preview area themselves should set this to %FALSE and 1426 * display the name themselves in their preview widget. 1427 * 1428 * See also: gtk_file_chooser_set_preview_widget() 1429 * 1430 * Params: 1431 * useLabel = whether to display a stock label with the name of the previewed file 1432 * 1433 * Since: 2.4 1434 */ 1435 public void setUsePreviewLabel(bool useLabel) 1436 { 1437 gtk_file_chooser_set_use_preview_label(getFileChooserStruct(), useLabel); 1438 } 1439 1440 /** 1441 * Unselects all the files in the current folder of a file chooser. 1442 * 1443 * Since: 2.4 1444 */ 1445 public void unselectAll() 1446 { 1447 gtk_file_chooser_unselect_all(getFileChooserStruct()); 1448 } 1449 1450 /** 1451 * Unselects the file referred to by @file. If the file is not in the current 1452 * directory, does not exist, or is otherwise not currently selected, does nothing. 1453 * 1454 * Params: 1455 * file = a #GFile 1456 * 1457 * Since: 2.14 1458 */ 1459 public void unselectFile(FileIF file) 1460 { 1461 gtk_file_chooser_unselect_file(getFileChooserStruct(), (file is null) ? null : file.getFileStruct()); 1462 } 1463 1464 /** 1465 * Unselects a currently selected filename. If the filename 1466 * is not in the current directory, does not exist, or 1467 * is otherwise not currently selected, does nothing. 1468 * 1469 * Params: 1470 * filename = the filename to unselect 1471 * 1472 * Since: 2.4 1473 */ 1474 public void unselectFilename(string filename) 1475 { 1476 gtk_file_chooser_unselect_filename(getFileChooserStruct(), Str.toStringz(filename)); 1477 } 1478 1479 /** 1480 * Unselects the file referred to by @uri. If the file 1481 * is not in the current directory, does not exist, or 1482 * is otherwise not currently selected, does nothing. 1483 * 1484 * Params: 1485 * uri = the URI to unselect 1486 * 1487 * Since: 2.4 1488 */ 1489 public void unselectUri(string uri) 1490 { 1491 gtk_file_chooser_unselect_uri(getFileChooserStruct(), Str.toStringz(uri)); 1492 } 1493 1494 /** 1495 * This signal gets emitted whenever it is appropriate to present a 1496 * confirmation dialog when the user has selected a file name that 1497 * already exists. The signal only gets emitted when the file 1498 * chooser is in %GTK_FILE_CHOOSER_ACTION_SAVE mode. 1499 * 1500 * Most applications just need to turn on the 1501 * #GtkFileChooser:do-overwrite-confirmation property (or call the 1502 * gtk_file_chooser_set_do_overwrite_confirmation() function), and 1503 * they will automatically get a stock confirmation dialog. 1504 * Applications which need to customize this behavior should do 1505 * that, and also connect to the #GtkFileChooser::confirm-overwrite 1506 * signal. 1507 * 1508 * A signal handler for this signal must return a 1509 * #GtkFileChooserConfirmation value, which indicates the action to 1510 * take. If the handler determines that the user wants to select a 1511 * different filename, it should return 1512 * %GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines 1513 * that the user is satisfied with his choice of file name, it 1514 * should return %GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME. 1515 * On the other hand, if it determines that the stock confirmation 1516 * dialog should be used, it should return 1517 * %GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example 1518 * illustrates this. 1519 * 1520 * ## Custom confirmation ## {#gtkfilechooser-confirmation} 1521 * 1522 * |[<!-- language="C" --> 1523 * static GtkFileChooserConfirmation 1524 * confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data) 1525 * { 1526 * char *uri; 1527 * 1528 * uri = gtk_file_chooser_get_uri (chooser); 1529 * 1530 * if (is_uri_read_only (uri)) 1531 * { 1532 * if (user_wants_to_replace_read_only_file (uri)) 1533 * return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME; 1534 * else 1535 * return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN; 1536 * } else 1537 * return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog 1538 * } 1539 * 1540 * ... 1541 * 1542 * chooser = gtk_file_chooser_dialog_new (...); 1543 * 1544 * gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); 1545 * g_signal_connect (chooser, "confirm-overwrite", 1546 * G_CALLBACK (confirm_overwrite_callback), NULL); 1547 * 1548 * if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT) 1549 * save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); 1550 * 1551 * gtk_widget_destroy (chooser); 1552 * ]| 1553 * 1554 * Returns: a #GtkFileChooserConfirmation value that indicates which 1555 * action to take after emitting the signal. 1556 * 1557 * Since: 2.8 1558 */ 1559 gulong addOnConfirmOverwrite(GtkFileChooserConfirmation delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1560 { 1561 return Signals.connect(this, "confirm-overwrite", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1562 } 1563 1564 /** 1565 * This signal is emitted when the current folder in a #GtkFileChooser 1566 * changes. This can happen due to the user performing some action that 1567 * changes folders, such as selecting a bookmark or visiting a folder on the 1568 * file list. It can also happen as a result of calling a function to 1569 * explicitly change the current folder in a file chooser. 1570 * 1571 * Normally you do not need to connect to this signal, unless you need to keep 1572 * track of which folder a file chooser is showing. 1573 * 1574 * See also: gtk_file_chooser_set_current_folder(), 1575 * gtk_file_chooser_get_current_folder(), 1576 * gtk_file_chooser_set_current_folder_uri(), 1577 * gtk_file_chooser_get_current_folder_uri(). 1578 */ 1579 gulong addOnCurrentFolderChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1580 { 1581 return Signals.connect(this, "current-folder-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1582 } 1583 1584 /** 1585 * This signal is emitted when the user "activates" a file in the file 1586 * chooser. This can happen by double-clicking on a file in the file list, or 1587 * by pressing `Enter`. 1588 * 1589 * Normally you do not need to connect to this signal. It is used internally 1590 * by #GtkFileChooserDialog to know when to activate the default button in the 1591 * dialog. 1592 * 1593 * See also: gtk_file_chooser_get_filename(), 1594 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(), 1595 * gtk_file_chooser_get_uris(). 1596 */ 1597 gulong addOnFileActivated(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1598 { 1599 return Signals.connect(this, "file-activated", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1600 } 1601 1602 /** 1603 * This signal is emitted when there is a change in the set of selected files 1604 * in a #GtkFileChooser. This can happen when the user modifies the selection 1605 * with the mouse or the keyboard, or when explicitly calling functions to 1606 * change the selection. 1607 * 1608 * Normally you do not need to connect to this signal, as it is easier to wait 1609 * for the file chooser to finish running, and then to get the list of 1610 * selected files using the functions mentioned below. 1611 * 1612 * See also: gtk_file_chooser_select_filename(), 1613 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(), 1614 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(), 1615 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(), 1616 * gtk_file_chooser_get_uris(). 1617 */ 1618 gulong addOnSelectionChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1619 { 1620 return Signals.connect(this, "selection-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1621 } 1622 1623 /** 1624 * This signal is emitted when the preview in a file chooser should be 1625 * regenerated. For example, this can happen when the currently selected file 1626 * changes. You should use this signal if you want your file chooser to have 1627 * a preview widget. 1628 * 1629 * Once you have installed a preview widget with 1630 * gtk_file_chooser_set_preview_widget(), you should update it when this 1631 * signal is emitted. You can use the functions 1632 * gtk_file_chooser_get_preview_filename() or 1633 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview. 1634 * Your widget may not be able to preview all kinds of files; your callback 1635 * must call gtk_file_chooser_set_preview_widget_active() to inform the file 1636 * chooser about whether the preview was generated successfully or not. 1637 * 1638 * Please see the example code in 1639 * [Using a Preview Widget][gtkfilechooser-preview]. 1640 * 1641 * See also: gtk_file_chooser_set_preview_widget(), 1642 * gtk_file_chooser_set_preview_widget_active(), 1643 * gtk_file_chooser_set_use_preview_label(), 1644 * gtk_file_chooser_get_preview_filename(), 1645 * gtk_file_chooser_get_preview_uri(). 1646 */ 1647 gulong addOnUpdatePreview(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1648 { 1649 return Signals.connect(this, "update-preview", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1650 } 1651 }