gtkFileChooserSetFile: gtkFileChooserSetFile

Description Usage Arguments Details Value Author(s)

View source: R/gtkFuncs.R

Description

Sets file as the current filename for the file chooser, by changing to the file's parent folder and actually selecting the file in list. If the chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file's base name will also appear in the dialog's file name entry.

Usage

1
gtkFileChooserSetFile(object, file, .errwarn = TRUE)

Arguments

object

a GtkFileChooser

file

the GFile to set as current

.errwarn

Whether to issue a warning on error or fail silently

Details

If the file name isn't in the current folder of chooser, then the current folder of chooser will be changed to the folder containing filename. This is equivalent to a sequence of gtkFileChooserUnselectAll followed by gtkFileChooserSelectFilename.

Note that the file must exist, or nothing will be done except for the directory change.

If you are implementing a File/Save As... dialog, you should use this function if you already have a file name to which the user may save; for example, when the user opens an existing file and then does File/Save As... on it. If you don't have a file name already – for example, if the user just created a new file and is saving it for the first time, do not call this function. Instead, use something similar to this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
if (document_is_new)
  {
    /* the user just created a new document */
    gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
    gtk_file_chooser_set_current_name (chooser, "Untitled document");
  }
else
  {
    /* the user edited an existing document */
    gtk_file_chooser_set_file (chooser, existing_file);
  }

Since 2.14

Value

A list containing the following elements:

retval

[logical] TRUE if both the folder could be changed and the file was selected successfully, FALSE otherwise.

error

location to store the error, or NULL to ignore errors. [ allow-none ]

Author(s)

Derived by RGtkGen from GTK+ documentation


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.