Gtk.FileChooser


Gtk.FileChooser — File chooser interface used by Gtk.FileChooserWidget and Gtk.FileChooserDialog

Object Hierarchy:

    GInterface
    ╰── Gtk.FileChooser

See also:

Gtk.FileChooserDialog, Gtk.FileChooserWidget, Gtk.FileChooserButton


Functions:


Signals:

  • “confirm-overwrite” (chooser, user_data)
  • “current-folder-changed” (chooser, user_data)
  • “file-activated” (chooser, user_data)
  • “selection-changed” (chooser, user_data)

Description:

Gtk.FileChooser is an interface that can be implemented by file selection widgets. In GTK+, the main objects that implement this interface are Gtk.FileChooserWidget, Gtk.FileChooserDialog, and Gtk.FileChooserButton. You do not need to write an object that implements the Gtk.FileChooser interface unless you are trying to adapt an existing file selector to expose a standard programming interface.

Gtk.FileChooser allows for shortcuts to various places in the filesystem.

In the default implementation these are displayed in the left pane. It may be a bit confusing at first that these shortcuts come from various sources and in various flavours, so lets explain the terminology here:

  • right pane to the left pane, or by using the Add. Bookmarks can be renamed and deleted by the user.
  • program may want to add a shortcut for a Clipart folder. Shortcuts cannot be modified by the user.
  • the roots of the filesystem.

File Names and Encodings

When the user is finished selecting files in a Gtk.FileChooser, your program can get the selected names either as filenames or as URIs. For URIs, the normal escaping rules are applied if the URI contains non-ASCII characters.

However, filenames are always returned in the character set specified by the G_FILENAME_ENCODING environment variable.

Please see the GLib documentation for more details about this variable.

This means that while you can pass the result of Gtk.FileChooser::get_filename() to open() or fopen(), you may not be able to directly set it as the text of a Gtk.Label widget unless you convert it first to UTF-8, which all GTK+ widgets expect. You should use g_filename_to_utf8() to convert filenames into strings that can be passed to GTK+ widgets.

Adding a Preview Widget

You can add a custom preview widget to a file chooser and then get notification about when the preview needs to be updated.

To install a preview widget, use Gtk.FileChooser::set_preview_widget(). Then, connect to the you need to update the contents of the preview.

Your callback should use Gtk.FileChooser::get_preview_filename() to see what needs previewing. Once you have generated the preview for the corresponding file, you must call Gtk.FileChooser::set_preview_widget_active() with a boolean flag that indicates whether your callback could successfully generate a preview.

class TestWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title("Test Gtk.FileChooser with Image Preview")
        self.set_size_request(800, 600)
        self.connect("destroy", Gtk.main_quit)

        box = Gtk.VBox()
        self.add(box)

        # create file chooser
        filechooser = Gtk.FileChooserWidget(action=Gtk.FileChooserAction.OPEN)
        box.add(filechooser)        

        # add filter
        png_filter = Gtk.FileFilter()
        png_filter.set_name("Image files")
        png_filter.add_mime_type("text/x-png")
        png_filter.add_pattern("*.png")   
        filechooser.set_filter(png_filter)

        # add scrolled window for bigger image
        scrolled_win = Gtk.ScrolledWindow()
        scrolled_win.set_size_request(300, 300)
        box.add(scrolled_win)

        # add preview image widget
        preview = Gtk.Image()
        scrolled_win.add(preview)

        # setting chooser's preview widget
        filechooser.set_preview_widget(preview)        

        # connect signal
        filechooser.connect('update-preview', self.on_preview)        

    # signal 'update-preview' callback
    def on_preview(self, chooser):
        preview = chooser.get_preview_widget()
        filename = chooser.get_preview_filename()
        if '.png' in filename:
            preview.set_from_file(filename)
            chooser.set_preview_widget_active(True)

Adding Extra Widgets

You can add extra widgets to a file chooser to provide options that are not present in the default design. For example, you can add a toggle button to give the user the option to open a file in read-only mode. You can use Gtk.FileChooser::set_extra_widget() to insert additional widgets in a file chooser.

An example for adding extra widgets:

    ...

    toggle = Gtk.CheckButton(label="Open file read-only")
    filechooserwidget.set_extra_widget(toggle)

    ...

If you want to set more than one extra widget in the file chooser, you can a container such as a GtkBox or a Gtk.Grid and include your widgets in it. Then, set the container as the whole extra widget.


Function Details:

set_action()

set_action (self, action:Gtk.FileChooserAction)

Sets the type of operation that the chooser is performing; theuser interface is adapted to suit the selected action. For example,an option to create a new folder might be shown if the action isGTK_FILE_CHOOSER_ACTION_SAVE but not if the action isGTK_FILE_CHOOSER_ACTION_OPEN.

  • Since: 2.4

get_action()

get_action (self) -> Gtk.FileChooserAction

Gets the type of operation that the file chooser is performing; seeGtk.FileChooser:set_action().

  • Returns: the action that the file selector is performing

  • Since: 2.4


set_local_only()

set_local_only (self, local_only:bool)

Sets whether only local files can be selected in thefile selector. If local_only is True (the default),then the selected file or files are guaranteed to beaccessible through the operating systems native filesystem and therefore the application onlyneeds to worry about the filename functions inGtk.FileChooser, like Gtk.FileChooser:get_filename(),rather than the URI functions likeGtk.FileChooser:get_uri(), On some systems non-native files may still beavailable using the native filesystem via a userspacefilesystem (FUSE).

  • Since: 2.4

get_local_only()

get_local_only (self) -> bool

Gets whether only local files can be selected in thefile selector. See Gtk.FileChooser:set_local_only()

  • Returns: True if only local files can be selected.

  • Since: 2.4


set_select_multiple()

set_select_multiple (self, select_multiple:bool)

Sets whether multiple files can be selected in the file selector. This isonly relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN orGTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.

  • Since: 2.4

get_select_multiple()

get_select_multiple (self) -> bool

Gets whether multiple files can be selected in the fileselector. See Gtk.FileChooser:set_select_multiple().

  • Returns: True if multiple files can be selected.

  • Since: 2.4


set_show_hidden()

set_show_hidden (self, show_hidden:bool)

Sets whether hidden files and folders are displayed in the file selector.

  • Since: 2.6

get_show_hidden()

get_show_hidden (self) -> bool

Gets whether hidden files and folders are displayed in the file selector. See Gtk.FileChooser:set_show_hidden().

  • Returns: True if hidden files and folders are displayed.

  • Since: 2.6


set_do_overwrite_confirmation()

set_do_overwrite_confirmation (self, do_overwrite_confirmation:bool)

Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will presenta confirmation dialog if the user types a file name that already exists. Thisis FALSE by default. If set to True, the chooser will emit the“confirm-overwrite” signal when appropriate. If all you need is the stock confirmation dialog, set this property to True.You can override the way confirmation is done by actually handling the“confirm-overwrite” signal; please refer to its documentationfor the details.

  • Since: 2.8

get_do_overwrite_confirmation()

get_do_overwrite_confirmation (self) -> bool

Queries whether a file chooser is set to confirm for overwriting when the usertypes a file name that already exists.

  • Returns: True if the file chooser will present a confirmation dialog;FALSE otherwise.

  • Since: 2.8


set_create_folders()

set_create_folders (self, create_folders:bool)

Sets whether file choser will offer to create new folders.This is only relevant if the action is not set to be GTK_FILE_CHOOSER_ACTION_OPEN.

  • Since: 2.18

get_create_folders()

get_create_folders (self) -> bool

Gets whether file choser will offer to create new folders.See Gtk.FileChooser:set_create_folders().

  • Returns: True if the Create Folder button should be displayed.

  • Since: 2.18


set_current_name()

set_current_name (self, name:str)

Sets the current name in the file selector, as if enteredby the user. Note that the name passed in here is a UTF-8string rather than a filename. This function is meant forsuch uses as a suggested name in a “Save As...” dialog. You canpass “Untitled.doc” or a similarly suitable suggestion for the name. If you want to preselect a particular existing file, you should useGtk.FileChooser:set_filename() or Gtk.FileChooser:set_uri() instead.Please see the documentation for those functions for an example of usingGtk.FileChooser:set_current_name() as well.

  • Since: 2.4

get_current_name()

get_current_name (self) -> str

Gets the current name in the file selector, as entered by the user in thetext entry for “Name”. This is meant to be used in save dialogs, to get the currently typed filenamewhen the file itself does not exist yet. For example, an application thatadds a custom extra widget to the file chooser for “file format” may want tochange the extension of the typed filename based on the chosen format, say,from “.jpg” to “.png”.

  • Returns: The raw text from the file chooser’s “Name” entry. Free this withg_free(). Note that this string is not a full pathname or URI; it iswhatever the contents of the entry are. Note also that this string is inUTF-8 encoding, which is not necessarily the system’s encoding for filenames.

  • Since: 3.10


get_filename()

get_filename (self) -> str

Gets the filename for the currently selected file inthe file selector. The filename is returned as an absolute path. Ifmultiple files are selected, one of the filenames will be returned atrandom. If the file chooser is in folder mode, this function returns the selectedfolder.

  • Returns: The currently selected filename, or Noneif no file is selected, or the selected file can'tbe represented with a local filename. Free with g_free().

  • Since: 2.4


set_filename()

set_filename (self, filename:str) -> bool

Sets filename as the current filename for the file chooser, by changing tothe file’s parent folder and actually selecting the file in list; all otherfiles will be unselected. If the chooser is inGTK_FILE_CHOOSER_ACTION_SAVE mode, the file’s base name will also appear inthe dialog’s file name entry. Note that the file must exist, or nothing will be done exceptfor the directory change. You should use this function only when implementing a savedialog for which you already have a file name to whichthe user may save. For example, when the user opens an existing file andthen does Save As... to save a copy ora modified version. If you don’t have a file name already — forexample, if the user just created a new file and is saving it for the firsttime, do not call this function. Instead, use something similar to this: if (document_is_new) { // the user just created a new document Gtk.FileChooser:set_current_name (chooser, "Untitled document"); }else { // the user edited an existing document Gtk.FileChooser:set_filename (chooser, existing_filename); } In the first case, the file chooser will present the user with useful suggestionsas to where to save his new file. In the second case, the file’s existing locationis already known, so the file chooser will use it.

  • Returns: Not useful.

  • Since: 2.4


select_filename()

select_filename (self, filename:str) -> bool

Selects a filename. If the file name isn’t in the currentfolder of chooser, then the current folder of chooser willbe changed to the folder containing filename.

  • Returns: Not useful.

  • Since: 2.4


unselect_filename()

unselect_filename (self, filename:str)

Unselects a currently selected filename. If the filenameis not in the current directory, does not exist, oris otherwise not currently selected, does nothing.

  • Since: 2.4

select_all()

select_all (self)

Selects all the files in the current folder of a file chooser.

  • Since: 2.4

unselect_all()

unselect_all (self)

Unselects all the files in the current folder of a file chooser.

  • Since: 2.4

get_filenames()

get_filenames (self) -> list

Lists all the selected files and subfolders in the current folder ofchooser. The returned names are full absolute paths. If files in the currentfolder cannot be represented as local filenames they will be ignored. (SeeGtk.FileChooser:get_uris())

  • Returns: a GSListcontaining the filenames of all selected files and subfolders inthe current folder. Free the returned list with g_slist_free(),and the filenames with g_free().

  • Since: 2.4


set_current_folder()

set_current_folder (self, filename:str) -> bool

Sets the current folder for chooser from a local filename.The user will be shown the full contents of the current folder,plus user interface elements for navigating to other folders. In general, you should not use this function. See thesection on setting up a file chooser dialogfor the rationale behind this.

  • Returns: Not useful.

  • Since: 2.4


get_current_folder()

get_current_folder (self) -> str

Gets the current folder of chooser as a local filename.See Gtk.FileChooser:set_current_folder(). Note that this is the folder that the file chooser is currently displaying(e.g. "/home/username/Documents"), which is not the sameas the currently-selected folder if the chooser is inGTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode(e.g. "/home/username/Documents/selected-folder/". To get thecurrently-selected folder in that mode, use Gtk.FileChooser:get_uri() as theusual way to get the selection.

  • Returns: the full path of the current folder,or None if the current path cannot be represented as a localfilename. Free with g_free(). This function will also returnNone if the file chooser was unable to load the last folder thatwas requested from it; for example, as would be for callingGtk.FileChooser:set_current_folder() on a nonexistent folder.

  • Since: 2.4


get_uri()

get_uri (self) -> str

Gets the URI for the currently selected file inthe file selector. If multiple files are selected,one of the filenames will be returned at random. If the file chooser is in folder mode, this function returns the selectedfolder.

  • Returns: The currently selected URI, or Noneif no file is selected. If Gtk.FileChooser:set_local_only() is set to True(the default) a local URI will be returned for any FUSE locations.Free with g_free()

  • Since: 2.4


set_uri()

set_uri (self, uri:str) -> bool

Sets the file referred to by uri as the current file for the file chooser,by changing to the URI’s parent folder and actually selecting the URI in thelist. If the chooser is GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI’s basename will also appear in the dialog’s file name entry. Note that the URI must exist, or nothing will be done except for the directory change. You should use this function only when implementing a savedialog for which you already have a file name to whichthe user may save. For example, when the user opens an existing file and thendoes Save As... to save a copy or amodified 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, donot call this function. Instead, use something similar to this: if (document_is_new) { // the user just created a new document Gtk.FileChooser:set_current_name (chooser, "Untitled document"); }else { // the user edited an existing document Gtk.FileChooser:set_uri (chooser, existing_uri); } In the first case, the file chooser will present the user with useful suggestionsas to where to save his new file. In the second case, the file’s existing locationis already known, so the file chooser will use it.

  • Returns: Not useful.

  • Since: 2.4


select_uri()

select_uri (self, uri:str) -> bool

Selects the file to by uri. If the URI doesn’t refer to afile in the current folder of chooser, then the current folder ofchooser will be changed to the folder containing filename.

  • Returns: Not useful.

  • Since: 2.4


unselect_uri()

unselect_uri (self, uri:str)

Unselects the file referred to by uri. If the fileis not in the current directory, does not exist, oris otherwise not currently selected, does nothing.

  • Since: 2.4

get_uris()

get_uris (self) -> list

Lists all the selected files and subfolders in the current folder ofchooser. The returned names are full absolute URIs.

  • Returns: a GSList containing the URIs of all selectedfiles and subfolders in the current folder. Free the returned listwith g_slist_free(), and the filenames with g_free().

  • Since: 2.4


set_current_folder_uri()

set_current_folder_uri (self, uri:str) -> bool

Sets the current folder for chooser from an URI.The user will be shown the full contents of the current folder,plus user interface elements for navigating to other folders. In general, you should not use this function. See thesection on setting up a file chooser dialogfor the rationale behind this.

  • Returns: True if the folder could be changed successfully, FALSEotherwise.

  • Since: 2.4


get_current_folder_uri()

get_current_folder_uri (self) -> str

Gets the current folder of chooser as an URI.See Gtk.FileChooser:set_current_folder_uri(). Note that this is the folder that the file chooser is currently displaying(e.g. "file:///home/username/Documents"), which is not the sameas the currently-selected folder if the chooser is inGTK_FILE_CHOOSER_ACTION_SELECT_FOLDER mode(e.g. "file:///home/username/Documents/selected-folder/". To get thecurrently-selected folder in that mode, use Gtk.FileChooser:get_uri() as theusual way to get the selection.

  • Returns: the URI for the current folder. Free with g_free(). Thisfunction will also return None if the file chooser was unable to load thelast folder that was requested from it; for example, as would be for callingGtk.FileChooser:set_current_folder_uri() on a nonexistent folder.

  • Since: 2.4


set_preview_widget()

set_preview_widget (self, preview_widget:Gtk.Widget)

Sets an application-supplied widget to use to display a custom previewof the currently selected file. To implement a preview, after setting thepreview widget, you connect to the “update-preview”signal, and call Gtk.FileChooser:get_preview_filename() orGtk.FileChooser:get_preview_uri() on each change. If you candisplay a preview of the new file, update your widget andset the preview active using Gtk.FileChooser:set_preview_widget_active().Otherwise, set the preview inactive. When there is no application-supplied preview widget, or theapplication-supplied preview widget is not active, the file chooserwill display no preview at all.

  • Since: 2.4

get_preview_widget()

get_preview_widget (self) -> Gtk.Widget

Gets the current preview widget; seeGtk.FileChooser:set_preview_widget().

  • Returns: the current preview widget, or None.

  • Since: 2.4


set_preview_widget_active()

set_preview_widget_active (self, active:bool)

Sets whether the preview widget set byGtk.FileChooser:set_preview_widget() should be shown for thecurrent filename. When active is set to false, the file choosermay display an internally generated preview of the current fileor it may display no preview at all. SeeGtk.FileChooser:set_preview_widget() for more details.

  • Since: 2.4

get_preview_widget_active()

get_preview_widget_active (self) -> bool

Gets whether the preview widget set by Gtk.FileChooser:set_preview_widget()should be shown for the current filename. SeeGtk.FileChooser:set_preview_widget_active().

  • Returns: True if the preview widget is active for the current filename.

  • Since: 2.4


set_use_preview_label()

set_use_preview_label (self, use_label:bool)

Sets whether the file chooser should display a stock label with the name ofthe file that is being previewed; the default is True. Applications thatwant to draw the whole preview area themselves should set this to FALSE anddisplay the name themselves in their preview widget. See also: Gtk.FileChooser:set_preview_widget()

  • Since: 2.4

get_use_preview_label()

get_use_preview_label (self) -> bool

Gets whether a stock label should be drawn with the name of the previewedfile. See Gtk.FileChooser:set_use_preview_label().

  • Returns: True if the file chooser is set to display a label with thename of the previewed file, FALSE otherwise.

get_preview_filename()

get_preview_filename (self) -> str

Gets the filename that should be previewed in a custom previewwidget. See Gtk.FileChooser:set_preview_widget().

  • Returns: the filename to preview, or None ifno file is selected, or if the selected file cannot be representedas a local filename. Free with g_free().

  • Since: 2.4


get_preview_uri()

get_preview_uri (self) -> str

Gets the URI that should be previewed in a custom previewwidget. See Gtk.FileChooser:set_preview_widget().

  • Returns: the URI for the file to preview, or None if no file isselected. Free with g_free().

  • Since: 2.4


set_extra_widget()

set_extra_widget (self, extra_widget:Gtk.Widget)

Sets an application-supplied widget to provide extra options to the user.

  • Since: 2.4

get_extra_widget()

get_extra_widget (self) -> Gtk.Widget

Gets the current preview widget; seeGtk.FileChooser:set_extra_widget().

  • Returns: the current extra widget, or None.

  • Since: 2.4


add_filter()

add_filter (self, filter:Gtk.FileFilter)

Adds filter to the list of filters that the user can select between.When a filter is selected, only files that are passed by thatfilter are displayed. Note that the chooser takes ownership of the filter, so you have to ref and sink it if you want to keep a reference.

  • Since: 2.4

remove_filter()

remove_filter (self, filter:Gtk.FileFilter)

Removes filter from the list of filters that the user can select between.

  • Since: 2.4

list_filters()

list_filters (self) -> list

Lists the current set of user-selectable filters; seeGtk.FileChooser:add_filter(), Gtk.FileChooser:remove_filter().

  • Returns: aGSList containing the current set of user selectable filters. Thecontents of the list are owned by GTK+, but you must free the listitself with g_slist_free() when you are done with it.

  • Since: 2.4


set_filter()

set_filter (self, filter:Gtk.FileFilter)

Sets the current filter; only the files that pass thefilter will be displayed. If the user-selectable list of filtersis non-empty, then the filter should be one of the filtersin that list. Setting the current filter when the list offilters is empty is useful if you want to restrict the displayedset of files without letting the user change it.

  • Since: 2.4

get_filter()

get_filter (self) -> Gtk.FileFilter

Gets the current filter; see Gtk.FileChooser:set_filter().

  • Returns: the current filter, or None.

  • Since: 2.4


add_shortcut_folder()

add_shortcut_folder (self, folder:str) -> bool

Adds a folder to be displayed with the shortcut folders in a file chooser.Note that shortcut folders do not get saved, as they are provided by theapplication. For example, you can use this to add a“/usr/share/mydrawprogram/Clipart” folder to the volume list.

  • Returns: True if the folder could be added successfully, FALSEotherwise. In the latter case, the errorwill be set as appropriate.

  • Since: 2.4


remove_shortcut_folder()

remove_shortcut_folder (self, folder:str) -> bool

Removes a folder from a file chooser’s list of shortcut folders.

  • Returns: True if the operation succeeds, FALSE otherwise.In the latter case, the errorwill be set as appropriate.

  • Since: 2.4


list_shortcut_folders()

list_shortcut_folders (self) -> list or None

Queries the list of shortcut folders in the file chooser, as set byGtk.FileChooser:add_shortcut_folder().

  • Returns: A listof folder filenames, or None if there are no shortcut folders.Free the returned list with g_slist_free(), and the filenames withg_free().

  • Since: 2.4


add_shortcut_folder_uri()

add_shortcut_folder_uri (self, uri:str) -> bool

Adds a folder URI to be displayed with the shortcut folders in a filechooser. Note that shortcut folders do not get saved, as they are providedby the application. For example, you can use this to add a“file:///usr/share/mydrawprogram/Clipart” folder to the volume list.

  • Returns: True if the folder could be added successfully, FALSEotherwise. In the latter case, the errorwill be set as appropriate.

  • Since: 2.4


remove_shortcut_folder_uri()

remove_shortcut_folder_uri (self, uri:str) -> bool

Removes a folder URI from a file chooser’s list of shortcut folders.

  • Returns: True if the operation succeeds, FALSE otherwise.In the latter case, the errorwill be set as appropriate.

  • Since: 2.4


list_shortcut_folder_uris()

list_shortcut_folder_uris (self) -> list or None

Queries the list of shortcut folders in the file chooser, as set byGtk.FileChooser:add_shortcut_folder_uri().

  • Returns: A list offolder URIs, or None if there are no shortcut folders. Free thereturned list with g_slist_free(), and the URIs with g_free().

  • Since: 2.4


get_current_folder_file()

get_current_folder_file (self) -> Gio.File

Gets the current folder of chooser as GFile.See Gtk.FileChooser:get_current_folder_uri().

  • Returns: the GFile for the current folder.

  • Since: 2.14


get_file()

get_file (self) -> Gio.File

Gets the GFile for the currently selected file inthe file selector. If multiple files are selected,one of the files will be returned at random. If the file chooser is in folder mode, this function returns the selectedfolder.

  • Returns: a selected GFile. You own the returned file;use g_object_unref() to release it.

  • Since: 2.14


get_files()

get_files (self) -> list

Lists all the selected files and subfolders in the current folder of chooseras GFile. An internal function, see Gtk.FileChooser:get_uris().

  • Returns: a GSListcontaining a GFile for each selected file and subfolder in thecurrent folder. Free the returned list with g_slist_free(), andthe files with g_object_unref().

  • Since: 2.14


get_preview_file()

get_preview_file (self) -> Gio.File

Gets the GFile that should be previewed in a custom previewInternal function, see Gtk.FileChooser:get_preview_uri().

  • Returns: the GFile for the file to preview,or None if no file is selected. Free with g_object_unref().

  • Since: 2.14


select_file()

select_file (self, file:Gio.File) -> bool

Selects the file referred to by file. An internal function. See_Gtk.FileChooser:select_uri().

  • Returns: Not useful.

  • Since: 2.14


set_current_folder_file()

set_current_folder_file (self, file:Gio.File) -> bool

Sets the current folder for chooser from a GFile.Internal function, see Gtk.FileChooser:set_current_folder_uri().

  • Returns: True if the folder could be changed successfully, FALSEotherwise.

  • Since: 2.14


set_file()

set_file (self, file:Gio.File) -> bool

Sets file as the current filename for the file chooser, by changingto the file’s parent folder and actually selecting the file in list. Ifthe chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode, the file’s base namewill also appear in the dialog’s file name entry. If the file name isn’t in the current folder of chooser, then the currentfolder of chooser will be changed to the folder containing filename. Thisis equivalent to a sequence of Gtk.FileChooser:unselect_all() followed byGtk.FileChooser:select_filename(). Note that the file must exist, or nothing will be done exceptfor the directory change. If you are implementing a save dialog,you should use this function if you already have a file name to which theuser may save; for example, when the user opens an existing file and thendoes Save As... If you don’t havea file name already — for example, if the user just created a newfile 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.FileChooser:set_current_folder_file (chooser, default_file_for_saving); Gtk.FileChooser:set_current_name (chooser, "Untitled document"); }else { // the user edited an existing document Gtk.FileChooser:set_file (chooser, existing_file); }

  • Returns: Not useful.

  • Since: 2.14


unselect_file()

unselect_file (self, file:Gio.File)

Unselects the file referred to by file. If the file is not in the currentdirectory, does not exist, or is otherwise not currently selected, does nothing.

  • Since: 2.14

results matching ""

    No results matching ""