Method

GtkFileChooserset_filename

since: 2.4

Declaration [src]

gboolean
gtk_file_chooser_set_filename (
  GtkFileChooser* chooser,
  const char* filename
)

Description [src]

Sets filename as the current filename for the file chooser, by changing to the file’s parent folder and actually selecting the file in list; all other files will be unselected. 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.

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

You should use this function only when implementing a save dialog for which you already have a file name to which the user may save. For example, when the user opens an existing file and then does Save As… to save a copy or a modified version. 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:

if (document_is_new)
  {
    // the user just created a new document
    gtk_file_chooser_set_current_name (chooser, "Untitled document");
  }
else
  {
    // the user edited an existing document
    gtk_file_chooser_set_filename (chooser, existing_filename);
  }

In the first case, the file chooser will present the user with useful suggestions as to where to save his new file. In the second case, the file’s existing location is already known, so the file chooser will use it.

Available since: 2.4

Parameters

filename

Type: const char*

The filename to set as current.

The data is owned by the caller of the method.
The value is a platform-native string, using the preferred OS encoding on Unix and UTF-8 on Windows.

Return value

Type: gboolean

Not useful.