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