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