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