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 * Conversion parameters: 26 * inFile = GtkFileChooser.html 27 * outPack = gtk 28 * outFile = FileChooserIF 29 * strct = GtkFileChooser 30 * realStrct= 31 * ctorStrct= 32 * clss = FileChooserT 33 * interf = FileChooserIF 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_file_chooser_ 41 * - gtk_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - glib.ErrorG 49 * - glib.GException 50 * - gio.File 51 * - gtk.Window 52 * - glib.ListSG 53 * - gtk.Widget 54 * - gtk.FileFilter 55 * structWrap: 56 * - GFile* -> File 57 * - GSList* -> ListSG 58 * - GtkFileFilter* -> FileFilter 59 * - GtkWidget* -> Widget 60 * - GtkWindow* -> Window 61 * module aliases: 62 * local aliases: 63 * - getAction -> getFileChooserAction 64 * - setAction -> setFileChooserAction 65 * overrides: 66 */ 67 68 module gtk.FileChooserIF; 69 70 public import gtkc.gtktypes; 71 72 private import gtkc.gtk; 73 private import glib.ConstructionException; 74 private import gobject.ObjectG; 75 76 private import gobject.Signals; 77 public import gtkc.gdktypes; 78 79 private import glib.Str; 80 private import glib.ErrorG; 81 private import glib.GException; 82 private import gio.File; 83 private import gtk.Window; 84 private import glib.ListSG; 85 private import gtk.Widget; 86 private import gtk.FileFilter; 87 88 89 90 91 /** 92 * Description 93 * GtkFileChooser is an interface that can be implemented by file 94 * selection widgets. In GTK+, the main objects that implement this 95 * interface are GtkFileChooserWidget, GtkFileChooserDialog, and 96 * GtkFileChooserButton. You do not need to write an object that 97 * implements the GtkFileChooser interface unless you are trying to 98 * adapt an existing file selector to expose a standard programming 99 * interface. 100 * GtkFileChooser allows for shortcuts to various places in the filesystem. 101 * In the default implementation these are displayed in the left pane. It 102 * may be a bit confusing at first taht these shortcuts come from various 103 * sources and in various flavours, so lets explain the terminology here: 104 * Bookmarks 105 * are created by the user, by dragging folders from the 106 * right pane to the left pane, or by using the "Add". Bookmarks 107 * can be renamed and deleted by the user. 108 * Shortcuts 109 * can be provided by the application or by the underlying filesystem 110 * abstraction (e.g. both the gnome-vfs and the Windows filesystems 111 * provide "Desktop" shortcuts). Shortcuts cannot be modified by the 112 * user. 113 * Volumes 114 * are provided by the underlying filesystem abstraction. They are 115 * the "roots" of the filesystem. 116 * File Names and Encodings 117 * When the user is finished selecting files in a 118 * GtkFileChooser, your program can get the selected names 119 * either as filenames or as URIs. For URIs, the normal escaping 120 * rules are applied if the URI contains non-ASCII characters. 121 * However, filenames are always returned in 122 * the character set specified by the 123 * G_FILENAME_ENCODING environment variable. 124 * Please see the Glib documentation for more details about this 125 * variable. 126 * Note 127 * This means that while you can pass the result of 128 * gtk_file_chooser_get_filename() to 129 * open(2) or 130 * fopen(3), you may not be able to 131 * directly set it as the text of a GtkLabel widget unless you 132 * convert it first to UTF-8, which all GTK+ widgets expect. 133 * You should use g_filename_to_utf8() to convert filenames 134 * into strings that can be passed to GTK+ widgets. 135 * <hr> 136 * Adding a Preview Widget 137 * You can add a custom preview widget to a file chooser and then 138 * get notification about when the preview needs to be updated. 139 * To install a preview widget, use 140 * gtk_file_chooser_set_preview_widget(). Then, connect to the 141 * "update-preview" signal to get notified when 142 * you need to update the contents of the preview. 143 * Your callback should use 144 * gtk_file_chooser_get_preview_filename() to see what needs 145 * previewing. Once you have generated the preview for the 146 * corresponding file, you must call 147 * gtk_file_chooser_set_preview_widget_active() with a boolean 148 * flag that indicates whether your callback could successfully 149 * generate a preview. 150 * $(DDOC_COMMENT example) 151 * <hr> 152 * Adding Extra Widgets 153 * You can add extra widgets to a file chooser to provide options 154 * that are not present in the default design. For example, you 155 * can add a toggle button to give the user the option to open a 156 * file in read-only mode. You can use 157 * gtk_file_chooser_set_extra_widget() to insert additional 158 * widgets in a file chooser. 159 * $(DDOC_COMMENT example) 160 * Note 161 * If you want to set more than one extra widget in the file 162 * chooser, you can a container such as a GtkVBox or a GtkTable 163 * and include your widgets in it. Then, set the container as 164 * the whole extra widget. 165 * <hr> 166 * Key Bindings 167 * Internally, GTK+ implements a file chooser's graphical user 168 * interface with the private 169 * GtkFileChooserDefaultClass. This 170 * widget has several key 171 * bindings and their associated signals. This section 172 * describes the available key binding signals. 173 * $(DDOC_COMMENT example) 174 * You can change these defaults to something else. For 175 * example, to add a Shift modifier to a few 176 * of the default bindings, you can include the following 177 * fragment in your .gtkrc-2.0 file: 178 * binding "my-own-gtkfilechooser-bindings" { 179 * bind "<Alt><Shift>Up" { 180 * "up-folder" () 181 * } 182 * bind "<Alt><Shift>Down" { 183 * "down-folder" () 184 * } 185 * bind "<Alt><Shift>Home" { 186 * "home-folder" () 187 * } 188 * } 189 * class "GtkFileChooserDefault" binding "my-own-gtkfilechooser-bindings" 190 * The "GtkFileChooserDefault::location-popup" signal 191 * void user_function (GtkFileChooserDefault *chooser, 192 * const char *path, 193 * gpointer user_data); 194 * This is used to make the file chooser show a "Location" 195 * dialog which the user can use to manually type the name of 196 * the file he wishes to select. The 197 * path argument is a string that gets 198 * put in the text entry for the file name. By default this is bound to 199 * Control+L 200 * with a path string of "" (the empty 201 * string). It is also bound to / with a 202 * path string of "/" 203 * (a slash): this lets you type / and 204 * immediately type a path name. On Unix systems, this is bound to 205 * ~ (tilde) with a path string 206 * of "~" itself for access to home directories. 207 * chooser : 208 * the object which received the signal. 209 * path : 210 * default contents for the text entry for the file name 211 * user_data : 212 * user data set when the signal handler was connected. 213 * Note 214 * You can create your own bindings for the 215 * GtkFileChooserDefault::location-popup signal with custom 216 * path strings, and have a crude form 217 * of easily-to-type bookmarks. For example, say you access 218 * the path /home/username/misc very 219 * frequently. You could then create an Alt+M 220 * shortcut by including the following in your 221 * .gtkrc-2.0: 222 * binding "misc-shortcut" { 223 * bind "<Alt>M" { 224 * "location-popup" ("/home/username/misc") 225 * } 226 * } 227 * class "GtkFileChooserDefault" binding "misc-shortcut" 228 * The "GtkFileChooserDefault::up-folder" signal 229 * void user_function (GtkFileChooserDefault *chooser, 230 * gpointer user_data); 231 * This is used to make the file chooser go to the parent of 232 * the current folder in the file hierarchy. By default this 233 * is bound to Backspace and 234 * Alt+Up 235 * (the Up key in the numeric keypad also works). 236 * chooser : 237 * the object which received the signal. 238 * user_data : 239 * user data set when the signal handler was connected. 240 * The "GtkFileChooserDefault::down-folder" signal 241 * void user_function (GtkFileChooserDefault *chooser, 242 * gpointer user_data); 243 * This is used to make the file chooser go to a child of the 244 * current folder in the file hierarchy. The subfolder that 245 * will be used is displayed in the path bar widget of the file 246 * chooser. For example, if the path bar is showing 247 * "/foo/bar/baz", then this will cause 248 * the file chooser to switch to the "baz" subfolder. By 249 * default this is bound to 250 * Alt+Down 251 * (the Down key in the numeric keypad also works). 252 * chooser : 253 * the object which received the signal. 254 * user_data : 255 * user data set when the signal handler was connected. 256 * The "GtkFileChooserDefault::home-folder" signal 257 * void user_function (GtkFileChooserDefault *chooser, 258 * gpointer user_data); 259 * This is used to make the file chooser show the user's home 260 * folder in the file list. By default this is bound to 261 * Alt+Home 262 * (the Home key in the numeric keypad also works). 263 * chooser : 264 * the object which received the signal. 265 * user_data : 266 * user data set when the signal handler was connected. 267 * The "GtkFileChooserDefault::desktop-folder" signal 268 * void user_function (GtkFileChooserDefault *chooser, 269 * gpointer user_data); 270 * This is used to make the file chooser show the user's Desktop 271 * folder in the file list. By default this is bound to 272 * Alt+D. 273 * chooser : 274 * the object which received the signal. 275 * user_data : 276 * user data set when the signal handler was connected. 277 * The "GtkFileChooserDefault::quick-bookmark" signal 278 * void user_function (GtkFileChooserDefault *chooser, 279 * gint bookmark_index, 280 * gpointer user_data); 281 * This is used to make the file chooser switch to the bookmark 282 * specified in the bookmark_index parameter. 283 * For example, if you have three bookmarks, you can pass 0, 1, 2 to 284 * this signal to switch to each of them, respectively. By default this is bound to 285 * Alt+1, 286 * Alt+2, 287 * etc. until 288 * Alt+0. Note 289 * that in the default binding, 290 * that Alt+1 is 291 * actually defined to switch to the bookmark at index 0, and so on 292 * successively; 293 * Alt+0 is 294 * defined to switch to the bookmark at index 10. 295 * chooser : 296 * the object which received the signal. 297 * bookmark_indes : 298 * index of the bookmark to switch to; the indices start at 0. 299 * user_data : 300 * user data set when the signal handler was connected. 301 */ 302 public interface FileChooserIF 303 { 304 305 306 public GtkFileChooser* getFileChooserTStruct(); 307 308 /** the main Gtk struct as a void* */ 309 protected void* getStruct(); 310 311 312 /** 313 */ 314 315 GtkFileChooserConfirmation delegate(FileChooserIF)[] onConfirmOverwriteListeners(); 316 /** 317 * This signal gets emitted whenever it is appropriate to present a 318 * confirmation dialog when the user has selected a file name that 319 * already exists. The signal only gets emitted when the file 320 * chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode. 321 * Most applications just need to turn on the 322 * "do-overwrite-confirmation" property (or call the 323 * gtk_file_chooser_set_do_overwrite_confirmation() function), and 324 * they will automatically get a stock confirmation dialog. 325 * Applications which need to customize this behavior should do 326 * that, and also connect to the "confirm-overwrite" 327 * signal. 328 * A signal handler for this signal must return a 329 * GtkFileChooserConfirmation value, which indicates the action to 330 * take. If the handler determines that the user wants to select a 331 * different filename, it should return 332 * GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines 333 * that the user is satisfied with his choice of file name, it 334 * should return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME. 335 * On the other hand, if it determines that the stock confirmation 336 * dialog should be used, it should return 337 * GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM. The following example 338 * illustrates this. 339 * $(DDOC_COMMENT example) 340 * 341 * Since 2.8 342 */ 343 void addOnConfirmOverwrite(GtkFileChooserConfirmation delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 344 void delegate(FileChooserIF)[] onCurrentFolderChangedListeners(); 345 /** 346 * This signal is emitted when the current folder in a GtkFileChooser 347 * changes. This can happen due to the user performing some action that 348 * changes folders, such as selecting a bookmark or visiting a folder on the 349 * file list. It can also happen as a result of calling a function to 350 * explicitly change the current folder in a file chooser. 351 * Normally you do not need to connect to this signal, unless you need to keep 352 * track of which folder a file chooser is showing. 353 * See also: gtk_file_chooser_set_current_folder(), 354 * gtk_file_chooser_get_current_folder(), 355 * gtk_file_chooser_set_current_folder_uri(), 356 * gtk_file_chooser_get_current_folder_uri(). 357 */ 358 void addOnCurrentFolderChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 359 void delegate(FileChooserIF)[] onFileActivatedListeners(); 360 /** 361 * This signal is emitted when the user "activates" a file in the file 362 * chooser. This can happen by double-clicking on a file in the file list, or 363 * by pressing Enter. 364 * Normally you do not need to connect to this signal. It is used internally 365 * by GtkFileChooserDialog to know when to activate the default button in the 366 * dialog. 367 * See also: gtk_file_chooser_get_filename(), 368 * gtk_file_chooser_get_filenames(), gtk_file_chooser_get_uri(), 369 * gtk_file_chooser_get_uris(). 370 */ 371 void addOnFileActivated(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 372 void delegate(FileChooserIF)[] onSelectionChangedListeners(); 373 /** 374 * This signal is emitted when there is a change in the set of selected files 375 * in a GtkFileChooser. This can happen when the user modifies the selection 376 * with the mouse or the keyboard, or when explicitly calling functions to 377 * change the selection. 378 * Normally you do not need to connect to this signal, as it is easier to wait 379 * for the file chooser to finish running, and then to get the list of 380 * selected files using the functions mentioned below. 381 * See also: gtk_file_chooser_select_filename(), 382 * gtk_file_chooser_unselect_filename(), gtk_file_chooser_get_filename(), 383 * gtk_file_chooser_get_filenames(), gtk_file_chooser_select_uri(), 384 * gtk_file_chooser_unselect_uri(), gtk_file_chooser_get_uri(), 385 * gtk_file_chooser_get_uris(). 386 */ 387 void addOnSelectionChanged(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 388 void delegate(FileChooserIF)[] onUpdatePreviewListeners(); 389 /** 390 * This signal is emitted when the preview in a file chooser should be 391 * regenerated. For example, this can happen when the currently selected file 392 * changes. You should use this signal if you want your file chooser to have 393 * a preview widget. 394 * Once you have installed a preview widget with 395 * gtk_file_chooser_set_preview_widget(), you should update it when this 396 * signal is emitted. You can use the functions 397 * gtk_file_chooser_get_preview_filename() or 398 * gtk_file_chooser_get_preview_uri() to get the name of the file to preview. 399 * Your widget may not be able to preview all kinds of files; your callback 400 * must call gtk_file_chooser_set_preview_widget_active() to inform the file 401 * chooser about whether the preview was generated successfully or not. 402 * Please see the example code in the section called “Adding a Preview Widget”. 403 * See also: gtk_file_chooser_set_preview_widget(), 404 * gtk_file_chooser_set_preview_widget_active(), 405 * gtk_file_chooser_set_use_preview_label(), 406 * gtk_file_chooser_get_preview_filename(), 407 * gtk_file_chooser_get_preview_uri(). 408 * See Also 409 * GtkFileChooserDialog, GtkFileChooserWidget, GtkFileChooserButton 410 */ 411 void addOnUpdatePreview(void delegate(FileChooserIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0); 412 413 /** 414 * Sets the type of operation that the chooser is performing; the 415 * user interface is adapted to suit the selected action. For example, 416 * an option to create a new folder might be shown if the action is 417 * GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is 418 * GTK_FILE_CHOOSER_ACTION_OPEN. 419 * Since 2.4 420 * Params: 421 * action = the action that the file selector is performing 422 */ 423 public void setFileChooserAction(GtkFileChooserAction action); 424 425 /** 426 * Gets the type of operation that the file chooser is performing; see 427 * gtk_file_chooser_set_action(). 428 * Since 2.4 429 * Returns: the action that the file selector is performing 430 */ 431 public GtkFileChooserAction getFileChooserAction(); 432 433 /** 434 * Sets whether only local files can be selected in the 435 * file selector. If local_only is TRUE (the default), 436 * then the selected file are files are guaranteed to be 437 * accessible through the operating systems native file 438 * file system and therefore the application only 439 * needs to worry about the filename functions in 440 * GtkFileChooser, like gtk_file_chooser_get_filename(), 441 * rather than the URI functions like 442 * gtk_file_chooser_get_uri(), 443 * Since 2.4 444 * Params: 445 * localOnly = TRUE if only local files can be selected 446 */ 447 public void setLocalOnly(int localOnly); 448 449 /** 450 * Gets whether only local files can be selected in the 451 * file selector. See gtk_file_chooser_set_local_only() 452 * Since 2.4 453 * Returns: TRUE if only local files can be selected. 454 */ 455 public int getLocalOnly(); 456 457 /** 458 * Sets whether multiple files can be selected in the file selector. This is 459 * only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or 460 * GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER. 461 * Since 2.4 462 * Params: 463 * selectMultiple = TRUE if multiple files can be selected. 464 */ 465 public void setSelectMultiple(int selectMultiple); 466 467 /** 468 * Gets whether multiple files can be selected in the file 469 * selector. See gtk_file_chooser_set_select_multiple(). 470 * Since 2.4 471 * Returns: TRUE if multiple files can be selected. 472 */ 473 public int getSelectMultiple(); 474 475 /** 476 * Sets whether hidden files and folders are displayed in the file selector. 477 * Since 2.6 478 * Params: 479 * showHidden = TRUE if hidden files and folders should be displayed. 480 */ 481 public void setShowHidden(int showHidden); 482 483 /** 484 * Gets whether hidden files and folders are displayed in the file selector. 485 * See gtk_file_chooser_set_show_hidden(). 486 * Since 2.6 487 * Returns: TRUE if hidden files and folders are displayed. 488 */ 489 public int getShowHidden(); 490 491 /** 492 * Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present 493 * a confirmation dialog if the user types a file name that already exists. This 494 * is FALSE by default. 495 * Regardless of this setting, the chooser will emit the 496 * "confirm-overwrite" signal when appropriate. 497 * If all you need is the stock confirmation dialog, set this property to TRUE. 498 * You can override the way confirmation is done by actually handling the 499 * "confirm-overwrite" signal; please refer to its documentation 500 * for the details. 501 * Since 2.8 502 * Params: 503 * doOverwriteConfirmation = whether to confirm overwriting in save mode 504 */ 505 public void setDoOverwriteConfirmation(int doOverwriteConfirmation); 506 507 /** 508 * Queries whether a file chooser is set to confirm for overwriting when the user 509 * types a file name that already exists. 510 * Since 2.8 511 * Returns: TRUE if the file chooser will present a confirmation dialog; FALSE otherwise. 512 */ 513 public int getDoOverwriteConfirmation(); 514 515 /** 516 * Sets whether file choser will offer to create new folders. 517 * This is only relevant if the action is not set to be 518 * GTK_FILE_CHOOSER_ACTION_OPEN. 519 * Since 2.18 520 * Params: 521 * createFolders = TRUE if the New Folder button should be displayed 522 */ 523 public void setCreateFolders(int createFolders); 524 525 /** 526 * Gets whether file choser will offer to create new folders. 527 * See gtk_file_chooser_set_create_folders(). 528 * Since 2.18 529 * Returns: TRUE if the New Folder button should be displayed. 530 */ 531 public int getCreateFolders(); 532 533 /** 534 * Sets the current name in the file selector, as if entered 535 * by the user. Note that the name passed in here is a UTF-8 536 * string rather than a filename. This function is meant for 537 * such uses as a suggested name in a "Save As..." dialog. 538 * If you want to preselect a particular existing file, you should use 539 * gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead. 540 * Please see the documentation for those functions for an example of using 541 * gtk_file_chooser_set_current_name() as well. 542 * Since 2.4 543 * Params: 544 * name = the filename to use, as a UTF-8 string 545 */ 546 public void setCurrentName(string name); 547 548 /** 549 * Gets the filename for the currently selected file in 550 * the file selector. If multiple files are selected, 551 * one of the filenames will be returned at random. 552 * If the file chooser is in folder mode, this function returns the selected 553 * folder. 554 * Since 2.4 555 * Returns: The currently selected filename, or NULL if no file is selected, or the selected file can't be represented with a local filename. Free with g_free(). 556 */ 557 public string getFilename(); 558 559 /** 560 * Sets filename as the current filename for the file chooser, by changing 561 * to the file's parent folder and actually selecting the file in list. If 562 * the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name 563 * will also appear in the dialog's file name entry. 564 * If the file name isn't in the current folder of chooser, then the current 565 * folder of chooser will be changed to the folder containing filename. This 566 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by 567 * gtk_file_chooser_select_filename(). 568 * Note that the file must exist, or nothing will be done except 569 * for the directory change. 570 * If you are implementing a File/Save As... dialog, 571 * you should use this function if you already have a file name to which the 572 * user may save; for example, when the user opens an existing file and then 573 * does File/Save As... on it. If you don't have 574 * a file name already — for example, if the user just created a new 575 * file and is saving it for the first time, do not call this function. 576 * Since 2.4 577 * Params: 578 * filename = the filename to set as current 579 * Returns: TRUE if both the folder could be changed and the file was selected successfully, FALSE otherwise. 580 */ 581 public int setFilename(string filename); 582 583 /** 584 * Selects a filename. If the file name isn't in the current 585 * folder of chooser, then the current folder of chooser will 586 * be changed to the folder containing filename. 587 * Since 2.4 588 * Params: 589 * filename = the filename to select 590 * Returns: TRUE if both the folder could be changed and the file was selected successfully, FALSE otherwise. 591 */ 592 public int selectFilename(string filename); 593 594 /** 595 * Unselects a currently selected filename. If the filename 596 * is not in the current directory, does not exist, or 597 * is otherwise not currently selected, does nothing. 598 * Since 2.4 599 * Params: 600 * filename = the filename to unselect 601 */ 602 public void unselectFilename(string filename); 603 604 /** 605 * Selects all the files in the current folder of a file chooser. 606 * Since 2.4 607 */ 608 public void selectAll(); 609 610 /** 611 * Unselects all the files in the current folder of a file chooser. 612 * Since 2.4 613 */ 614 public void unselectAll(); 615 616 /** 617 * Lists all the selected files and subfolders in the current folder of 618 * chooser. The returned names are full absolute paths. If files in the current 619 * folder cannot be represented as local filenames they will be ignored. (See 620 * gtk_file_chooser_get_uris()) 621 * Since 2.4 622 * Returns: a GSList containing the filenames of all selected files and subfolders in the current folder. Free the returned list with g_slist_free(), and the filenames with g_free(). [element-type utf8][transfer full utf8] 623 */ 624 public ListSG getFilenames(); 625 626 /** 627 * Sets the current folder for chooser from a local filename. 628 * The user will be shown the full contents of the current folder, 629 * plus user interface elements for navigating to other folders. 630 * Since 2.4 631 * Params: 632 * filename = the full path of the new current folder 633 * Returns: TRUE if the folder could be changed successfully, FALSE otherwise. 634 */ 635 public int setCurrentFolder(string filename); 636 637 /** 638 * Gets the current folder of chooser as a local filename. 639 * See gtk_file_chooser_set_current_folder(). 640 * Note that this is the folder that the file chooser is currently displaying 641 * (e.g. "/home/username/Documents"), which is not the same 642 * as the currently-selected folder if the chooser is in 643 * GTK_FILE_CHOOSER_SELECT_FOLDER mode 644 * (e.g. "/home/username/Documents/selected-folder/". To get the 645 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 646 * usual way to get the selection. 647 * Since 2.4 648 * Returns: the full path of the current folder, or NULL if the current path cannot be represented as a local filename. Free with g_free(). This function will also return NULL if the file chooser was unable to load the last folder that was requested from it; for example, as would be for calling gtk_file_chooser_set_current_folder() on a nonexistent folder. 649 */ 650 public string getCurrentFolder(); 651 652 /** 653 * Gets the URI for the currently selected file in 654 * the file selector. If multiple files are selected, 655 * one of the filenames will be returned at random. 656 * If the file chooser is in folder mode, this function returns the selected 657 * folder. 658 * Since 2.4 659 * Returns: The currently selected URI, or NULL if no file is selected. Free with g_free() 660 */ 661 public string getUri(); 662 663 /** 664 * Sets the file referred to by uri as the current file for the file chooser, 665 * by changing to the URI's parent folder and actually selecting the URI in the 666 * list. If the chooser is GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base 667 * name will also appear in the dialog's file name entry. 668 * If the URI isn't in the current folder of chooser, then the current folder 669 * of chooser will be changed to the folder containing uri. This is equivalent 670 * to a sequence of gtk_file_chooser_unselect_all() followed by 671 * gtk_file_chooser_select_uri(). 672 * Note that the URI must exist, or nothing will be done except for the 673 * directory change. 674 * If you are implementing a File/Save As... dialog, 675 * you should use this function if you already have a file name to which the 676 * user may save; for example, when the user opens an existing file and then 677 * does File/Save As... on it. If you don't have 678 * a file name already — for example, if the user just created a new 679 * file and is saving it for the first time, do not call this function. 680 * Since 2.4 681 * Params: 682 * uri = the URI to set as current 683 * Returns: TRUE if both the folder could be changed and the URI was selected successfully, FALSE otherwise. 684 */ 685 public int setUri(string uri); 686 687 /** 688 * Selects the file to by uri. If the URI doesn't refer to a 689 * file in the current folder of chooser, then the current folder of 690 * chooser will be changed to the folder containing filename. 691 * Since 2.4 692 * Params: 693 * uri = the URI to select 694 * Returns: TRUE if both the folder could be changed and the URI was selected successfully, FALSE otherwise. 695 */ 696 public int selectUri(string uri); 697 698 /** 699 * Unselects the file referred to by uri. If the file 700 * is not in the current directory, does not exist, or 701 * is otherwise not currently selected, does nothing. 702 * Since 2.4 703 * Params: 704 * uri = the URI to unselect 705 */ 706 public void unselectUri(string uri); 707 708 /** 709 * Lists all the selected files and subfolders in the current folder of 710 * chooser. The returned names are full absolute URIs. 711 * Since 2.4 712 * Returns: a GSList containing the URIs of all selected files and subfolders in the current folder. Free the returned list with g_slist_free(), and the filenames with g_free(). [element-type utf8][transfer full utf8] 713 */ 714 public ListSG getUris(); 715 716 /** 717 * Sets the current folder for chooser from an URI. 718 * The user will be shown the full contents of the current folder, 719 * plus user interface elements for navigating to other folders. 720 * Since 2.4 721 * Params: 722 * uri = the URI for the new current folder 723 * Returns: TRUE if the folder could be changed successfully, FALSE otherwise. 724 */ 725 public int setCurrentFolderUri(string uri); 726 727 /** 728 * Gets the current folder of chooser as an URI. 729 * See gtk_file_chooser_set_current_folder_uri(). 730 * Note that this is the folder that the file chooser is currently displaying 731 * (e.g. "file:///home/username/Documents"), which is not the same 732 * as the currently-selected folder if the chooser is in 733 * GTK_FILE_CHOOSER_SELECT_FOLDER mode 734 * (e.g. "file:///home/username/Documents/selected-folder/". To get the 735 * currently-selected folder in that mode, use gtk_file_chooser_get_uri() as the 736 * usual way to get the selection. 737 * Since 2.4 738 * Returns: the URI for the current folder. Free with g_free(). This function will also return NULL if the file chooser was unable to load the last folder that was requested from it; for example, as would be for calling gtk_file_chooser_set_current_folder_uri() on a nonexistent folder. 739 */ 740 public string getCurrentFolderUri(); 741 742 /** 743 * Sets an application-supplied widget to use to display a custom preview 744 * of the currently selected file. To implement a preview, after setting the 745 * preview widget, you connect to the "update-preview" 746 * signal, and call gtk_file_chooser_get_preview_filename() or 747 * gtk_file_chooser_get_preview_uri() on each change. If you can 748 * display a preview of the new file, update your widget and 749 * set the preview active using gtk_file_chooser_set_preview_widget_active(). 750 * Otherwise, set the preview inactive. 751 * When there is no application-supplied preview widget, or the 752 * application-supplied preview widget is not active, the file chooser 753 * may display an internally generated preview of the current file or 754 * it may display no preview at all. 755 * Since 2.4 756 * Params: 757 * previewWidget = widget for displaying preview. 758 */ 759 public void setPreviewWidget(Widget previewWidget); 760 761 /** 762 * Gets the current preview widget; see 763 * gtk_file_chooser_set_preview_widget(). 764 * Since 2.4 765 * Returns: the current preview widget, or NULL 766 */ 767 public Widget getPreviewWidget(); 768 769 /** 770 * Sets whether the preview widget set by 771 * gtk_file_chooser_set_preview_widget() should be shown for the 772 * current filename. When active is set to false, the file chooser 773 * may display an internally generated preview of the current file 774 * or it may display no preview at all. See 775 * gtk_file_chooser_set_preview_widget() for more details. 776 * Since 2.4 777 * Params: 778 * active = whether to display the user-specified preview widget 779 */ 780 public void setPreviewWidgetActive(int active); 781 782 /** 783 * Gets whether the preview widget set by gtk_file_chooser_set_preview_widget() 784 * should be shown for the current filename. See 785 * gtk_file_chooser_set_preview_widget_active(). 786 * Since 2.4 787 * Returns: TRUE if the preview widget is active for the current filename. 788 */ 789 public int getPreviewWidgetActive(); 790 791 /** 792 * Sets whether the file chooser should display a stock label with the name of 793 * the file that is being previewed; the default is TRUE. Applications that 794 * want to draw the whole preview area themselves should set this to FALSE and 795 * display the name themselves in their preview widget. 796 * See also: gtk_file_chooser_set_preview_widget() 797 * Since 2.4 798 * Params: 799 * useLabel = whether to display a stock label with the name of the previewed file 800 */ 801 public void setUsePreviewLabel(int useLabel); 802 803 /** 804 * Gets whether a stock label should be drawn with the name of the previewed 805 * file. See gtk_file_chooser_set_use_preview_label(). 806 * Returns: TRUE if the file chooser is set to display a label with the name of the previewed file, FALSE otherwise. 807 */ 808 public int getUsePreviewLabel(); 809 810 /** 811 * Gets the filename that should be previewed in a custom preview 812 * widget. See gtk_file_chooser_set_preview_widget(). 813 * Since 2.4 814 * Returns: the filename to preview, or NULL if no file is selected, or if the selected file cannot be represented as a local filename. Free with g_free() 815 */ 816 public string getPreviewFilename(); 817 818 /** 819 * Gets the URI that should be previewed in a custom preview 820 * widget. See gtk_file_chooser_set_preview_widget(). 821 * Since 2.4 822 * Returns: the URI for the file to preview, or NULL if no file is selected. Free with g_free(). 823 */ 824 public string getPreviewUri(); 825 826 /** 827 * Sets an application-supplied widget to provide extra options to the user. 828 * Since 2.4 829 * Params: 830 * extraWidget = widget for extra options 831 */ 832 public void setExtraWidget(Widget extraWidget); 833 834 /** 835 * Gets the current preview widget; see 836 * gtk_file_chooser_set_extra_widget(). 837 * Since 2.4 838 * Returns: the current extra widget, or NULL 839 */ 840 public Widget getExtraWidget(); 841 842 /** 843 * Adds filter to the list of filters that the user can select between. 844 * When a filter is selected, only files that are passed by that 845 * filter are displayed. 846 * Note that the chooser takes ownership of the filter, so you have to 847 * ref and sink it if you want to keep a reference. 848 * Since 2.4 849 * Params: 850 * filter = a GtkFileFilter 851 */ 852 public void addFilter(FileFilter filter); 853 854 /** 855 * Removes filter from the list of filters that the user can select between. 856 * Since 2.4 857 * Params: 858 * filter = a GtkFileFilter 859 */ 860 public void removeFilter(FileFilter filter); 861 862 /** 863 * Lists the current set of user-selectable filters; see 864 * gtk_file_chooser_add_filter(), gtk_file_chooser_remove_filter(). 865 * Since 2.4 866 * Returns: a GSList containing the current set of user selectable filters. The contents of the list are owned by GTK+, but you must free the list itself with g_slist_free() when you are done with it. [element-type utf8][transfer container utf8] 867 */ 868 public ListSG listFilters(); 869 870 /** 871 * Sets the current filter; only the files that pass the 872 * filter will be displayed. If the user-selectable list of filters 873 * is non-empty, then the filter should be one of the filters 874 * in that list. Setting the current filter when the list of 875 * filters is empty is useful if you want to restrict the displayed 876 * set of files without letting the user change it. 877 * Since 2.4 878 * Params: 879 * filter = a GtkFileFilter 880 */ 881 public void setFilter(FileFilter filter); 882 883 /** 884 * Gets the current filter; see gtk_file_chooser_set_filter(). 885 * Since 2.4 886 * Returns: the current filter, or NULL 887 */ 888 public FileFilter getFilter(); 889 890 /** 891 * Adds a folder to be displayed with the shortcut folders in a file chooser. 892 * Note that shortcut folders do not get saved, as they are provided by the 893 * application. For example, you can use this to add a 894 * "/usr/share/mydrawprogram/Clipart" folder to the volume list. 895 * Since 2.4 896 * Params: 897 * folder = filename of the folder to add 898 * Returns: TRUE if the folder could be added successfully, FALSE otherwise. In the latter case, the error will be set as appropriate. 899 * Throws: GException on failure. 900 */ 901 public int addShortcutFolder(string folder); 902 903 /** 904 * Removes a folder from a file chooser's list of shortcut folders. 905 * Since 2.4 906 * Params: 907 * folder = filename of the folder to remove 908 * Returns: TRUE if the operation succeeds, FALSE otherwise. In the latter case, the error will be set as appropriate. See also: gtk_file_chooser_add_shortcut_folder() 909 * Throws: GException on failure. 910 */ 911 public int removeShortcutFolder(string folder); 912 913 /** 914 * Queries the list of shortcut folders in the file chooser, as set by 915 * gtk_file_chooser_add_shortcut_folder(). 916 * Since 2.4 917 * Returns: A list of folder filenames, or NULL if there are no shortcut folders. Free the returned list with g_slist_free(), and the filenames with g_free(). [element-type utf8][transfer full utf8] 918 */ 919 public ListSG listShortcutFolders(); 920 921 /** 922 * Adds a folder URI to be displayed with the shortcut folders in a file 923 * chooser. Note that shortcut folders do not get saved, as they are provided 924 * by the application. For example, you can use this to add a 925 * "file:///usr/share/mydrawprogram/Clipart" folder to the volume list. 926 * Since 2.4 927 * Params: 928 * uri = URI of the folder to add 929 * Returns: TRUE if the folder could be added successfully, FALSE otherwise. In the latter case, the error will be set as appropriate. 930 * Throws: GException on failure. 931 */ 932 public int addShortcutFolderUri(string uri); 933 934 /** 935 * Removes a folder URI from a file chooser's list of shortcut folders. 936 * Since 2.4 937 * Params: 938 * uri = URI of the folder to remove 939 * Returns: TRUE if the operation succeeds, FALSE otherwise. In the latter case, the error will be set as appropriate. See also: gtk_file_chooser_add_shortcut_folder_uri() 940 * Throws: GException on failure. 941 */ 942 public int removeShortcutFolderUri(string uri); 943 944 /** 945 * Queries the list of shortcut folders in the file chooser, as set by 946 * gtk_file_chooser_add_shortcut_folder_uri(). 947 * Since 2.4 948 * Returns: A list of folder URIs, or NULL if there are no shortcut folders. Free the returned list with g_slist_free(), and the URIs with g_free(). [element-type utf8][transfer full utf8] 949 */ 950 public ListSG listShortcutFolderUris(); 951 952 /** 953 * Gets the current folder of chooser as GFile. 954 * See gtk_file_chooser_get_current_folder_uri(). 955 * Since 2.14 956 * Returns: the GFile for the current folder. 957 */ 958 public File getCurrentFolderFile(); 959 960 /** 961 * Gets the GFile for the currently selected file in 962 * the file selector. If multiple files are selected, 963 * one of the files will be returned at random. 964 * If the file chooser is in folder mode, this function returns the selected 965 * folder. 966 * Since 2.14 967 * Returns: a selected GFile. You own the returned file; use g_object_unref() to release it. 968 */ 969 public File getFile(); 970 971 /** 972 * Lists all the selected files and subfolders in the current folder of chooser 973 * as GFile. An internal function, see gtk_file_chooser_get_uris(). 974 * Since 2.14 975 * Returns: a GSList containing a GFile for each selected file and subfolder in the current folder. Free the returned list with g_slist_free(), and the files with g_object_unref(). [element-type utf8][transfer full utf8] 976 */ 977 public ListSG getFiles(); 978 979 /** 980 * Gets the GFile that should be previewed in a custom preview 981 * Internal function, see gtk_file_chooser_get_preview_uri(). 982 * Since 2.14 983 * Returns: the GFile for the file to preview, or NULL if no file is selected. Free with g_object_unref(). 984 */ 985 public File getPreviewFile(); 986 987 /** 988 * Selects the file referred to by file. An internal function. See 989 * _gtk_file_chooser_select_uri(). 990 * Since 2.14 991 * Params: 992 * file = the file to select 993 * Returns: TRUE if both the folder could be changed and the path was selected successfully, FALSE otherwise. 994 * Throws: GException on failure. 995 */ 996 public int selectFile(File file); 997 998 /** 999 * Sets the current folder for chooser from a GFile. 1000 * Internal function, see gtk_file_chooser_set_current_folder_uri(). 1001 * Since 2.14 1002 * Params: 1003 * file = the GFile for the new folder 1004 * Returns: TRUE if the folder could be changed successfully, FALSE otherwise. 1005 * Throws: GException on failure. 1006 */ 1007 public int setCurrentFolderFile(File file); 1008 1009 /** 1010 * Sets file as the current filename for the file chooser, by changing 1011 * to the file's parent folder and actually selecting the file in list. If 1012 * the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name 1013 * will also appear in the dialog's file name entry. 1014 * If the file name isn't in the current folder of chooser, then the current 1015 * folder of chooser will be changed to the folder containing filename. This 1016 * is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by 1017 * gtk_file_chooser_select_filename(). 1018 * Note that the file must exist, or nothing will be done except 1019 * for the directory change. 1020 * If you are implementing a File/Save As... dialog, 1021 * you should use this function if you already have a file name to which the 1022 * user may save; for example, when the user opens an existing file and then 1023 * does File/Save As... on it. If you don't have 1024 * a file name already — for example, if the user just created a new 1025 * file and is saving it for the first time, do not call this function. 1026 * Since 2.14 1027 * Params: 1028 * file = the GFile to set as current 1029 * Returns: TRUE if both the folder could be changed and the file was selected successfully, FALSE otherwise. 1030 * Throws: GException on failure. 1031 */ 1032 public int setFile(File file); 1033 1034 /** 1035 * Unselects the file referred to by file. If the file is not in the current 1036 * directory, does not exist, or is otherwise not currently selected, does nothing. 1037 * Since 2.14 1038 * Params: 1039 * file = a GFile 1040 */ 1041 public void unselectFile(File file); 1042 }