11.59Class GtkFileChooser

File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog

Class GtkFileChooser

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

[...]

Methods
get_actionGets the type of operation that the file chooser is performing.
get_create_foldersGets whether file choser will offer to create new folders.
get_current_folderGets the current folder of chooser as a local filename.
get_current_folder_uriGets the current folder of chooser as an URI.
get_do_overwrite_confirmationQueries whether a file chooser is set to confirm for overwriting when the user types a file name that already exists.
get_extra_widgetGets the current preview widget.
get_filenameGets the filename for the currently selected file in the file selector.
get_filenamesLists all the selected files and subfolders in the current folder of chooser.
get_local_onlyGets whether only local files can be selected in the file selector.
get_preview_filenameGets the filename that should be previewed in a custom preview widget.
get_preview_uriGets the URI that should be previewed in a custom preview widget.
get_preview_widgetGets the current preview widget.
get_preview_widget_activeGets whether the preview widget set by gtk_file_chooser_set_preview_widget() should be shown for the current filename.
get_select_multipleGets whether multiple files can be selected in the file selector.
get_show_hiddenGets whether hidden files and folders are displayed in the file selector.
get_uriGets the URI for the currently selected file in the file selector.
get_urisLists all the selected files and subfolders in the current folder of chooser.
get_use_preview_labelGets whether a stock label should be drawn with the name of the previewed file.
select_allSelects all the files in the current folder of a file chooser.
select_filenameSelects a filename.
select_uriSelects the file to by uri.
set_actionSets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action.
set_create_foldersSets whether file choser will offer to create new folders.
set_current_folderSets the current folder for chooser from a local filename.
set_current_folder_uriSets the current folder for chooser from an URI.
set_current_nameSets the current name in the file selector, as if entered by the user.
set_do_overwrite_confirmationSets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present a confirmation dialog if the user types a file name that already exists.
set_extra_widgetSets an application_supplied widget to provide extra options to the user.
set_filenameSets filename as the current filename for the file chooser, by changing to the file's parent folder and actually selecting the file in list.
set_local_onlySets whether only local files can be selected in the file selector.
set_preview_widgetSets an application_supplied widget to use to display a custom preview of the currently selected file.
set_preview_widget_activeSets whether the preview widget set by gtk_file_chooser_set_preview_widget() should be shown for the current filename.
set_select_multipleSets whether multiple files can be selected in the file selector.
set_show_hiddenSets whether hidden files and folders are displayed in the file selector.
set_uriSets 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 the list.
set_use_preview_labelSets whether the file chooser should display a stock label with the name of the file that is being previewed.
signal_confirm_overwriteThis signal gets emitted whenever it is appropriate to present a confirmation dialog when the user has selected a file name that already exists.
signal_current_folder_changedThis signal is emitted when the current folder in a GtkFileChooser changes.
signal_file_activatedThis signal is emitted when the user "activates" a file in the file chooser.
signal_selection_changedThis signal is emitted when there is a change in the set of selected files in a GtkFileChooser.
signal_update_previewThis signal is emitted when the preview in a file chooser should be regenerated.
unselect_allUnselects all the files in the current folder of a file chooser.
unselect_filenameUnselects a currently selected filename.
unselect_uriUnselects the file referred to by uri.

Methods

get_action

Gets the type of operation that the file chooser is performing.

GtkFileChooser.get_action()
Returnthe action that the file selector is performing (GtkFileChooserAction).

get_create_folders

Gets whether file choser will offer to create new folders.

GtkFileChooser.get_create_folders()
ReturnTRUE if the New Folder button should be displayed.

get_current_folder

Gets the current folder of chooser as a local filename.

GtkFileChooser.get_current_folder()
Returnthe full path of the current folder, or nil if the current path cannot be represented as a local filename.

Note that this is the folder that the file chooser is currently displaying (e.g. "/home/username/Documents"), which is not the same as the currently_selected folder if the chooser is in GTK_FILE_CHOOSER_SELECT_FOLDER mode (e.g. "/home/username/Documents/selected_folder/". To get the currently_selected folder in that mode, use gtk_file_chooser_get_uri() as the usual way to get the selection.

get_current_folder_uri

Gets the current folder of chooser as an URI.

GtkFileChooser.get_current_folder_uri()
Returnthe URI for the current folder (or nil).

Note that this is the folder that the file chooser is currently displaying (e.g. "file:/home/username/Documents"), which is not the same as the currently_selected folder if the chooser is in GTK_FILE_CHOOSER_SELECT_FOLDER mode (e.g. "file:/home/username/Documents/selected_folder/". To get the currently_selected folder in that mode, use gtk_file_chooser_get_uri() as the usual way to get the selection.

get_do_overwrite_confirmation

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

GtkFileChooser.get_do_overwrite_confirmation()
ReturnTRUE if the file chooser will present a confirmation dialog; FALSE otherwise.

get_extra_widget

Gets the current preview widget.

GtkFileChooser.get_extra_widget()
Returnthe current extra widget, or NULL

get_filename

Gets the filename for the currently selected file in the file selector.

GtkFileChooser.get_filename()
ReturnThe currently selected filename, or nil if no file is selected, or the selected file can't be represented with a local filename.

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 selected folder.

get_filenames

Lists all the selected files and subfolders in the current folder of chooser.

GtkFileChooser.get_filenames()
ReturnAn array of strings

The returned names are full absolute paths. If files in the current folder cannot be represented as local filenames they will be ignored.

get_local_only

Gets whether only local files can be selected in the file selector.

GtkFileChooser.get_local_only()
Returntrue if only local files can be selected.

get_preview_filename

Gets the filename that should be previewed in a custom preview widget.

GtkFileChooser.get_preview_filename()
Returnthe filename to preview, or NULL if no file is selected, or if the selected file cannot be represented as a local filename.

get_preview_uri

Gets the URI that should be previewed in a custom preview widget.

GtkFileChooser.get_preview_uri()
Returnthe URI for the file to preview, or NULL if no file is selected.

get_preview_widget

Gets the current preview widget.

GtkFileChooser.get_preview_widget()
Returnthe current preview widget, or nil.

get_preview_widget_active

Gets whether the preview widget set by gtk_file_chooser_set_preview_widget() should be shown for the current filename.

GtkFileChooser.get_preview_widget_active()
Returntrue if the preview widget is active for the current filename

get_select_multiple

Gets whether multiple files can be selected in the file selector.

GtkFileChooser.get_select_multiple()
ReturnTRUE if multiple files can be selected.

get_show_hidden

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

GtkFileChooser.get_show_hidden()
Returntrue if hidden files and folders are displayed.

get_uri

Gets the URI for the currently selected file in the file selector.

GtkFileChooser.get_uri()
ReturnThe currently selected URI, or NULL if no file is selected.

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 selected folder.

get_uris

Lists all the selected files and subfolders in the current folder of chooser.

GtkFileChooser.get_uris()
ReturnAn array of strings.

The returned names are full absolute URIs.

get_use_preview_label

Gets whether a stock label should be drawn with the name of the previewed file.

GtkFileChooser.get_use_preview_label()
ReturnTRUE if the file chooser is set to display a label with the name of the previewed file, FALSE otherwise

select_all

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

GtkFileChooser.select_all()

select_filename

Selects a filename.

GtkFileChooser.select_filename( filename )
filename the filename to select
Returntrue if both the folder could be changed and the file was selected successfully, false otherwise

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.

select_uri

Selects the file to by uri.

GtkFileChooser.select_uri( uri )
uri the URI to set as current
Returntrue if both the folder could be changed and the URI was selected successfully, false otherwise

If the URI doesn't refer to a file in the current folder of chooser, then the current folder of chooser will be changed to the folder containing filename.

set_action

Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action.

GtkFileChooser.set_action( action )
action the action that the file selector is performing (GtkFileChooserAction).

For example, an option to create a new folder might be shown if the action is GTK_FILE_CHOOSER_ACTION_SAVE but not if the action is GTK_FILE_CHOOSER_ACTION_OPEN.

set_create_folders

Sets whether file choser will offer to create new folders.

GtkFileChooser.set_create_folders( create_folders )
create_folders TRUE if the New Folder button should be displayed

This is only relevant if the action is not set to be GTK_FILE_CHOOSER_ACTION_OPEN.

set_current_folder

Sets the current folder for chooser from a local filename.

GtkFileChooser.set_current_folder( filename )
filename the full path of the new current folder
Returntrue if the folder could be changed successfully, false otherwise.

The user will be shown the full contents of the current folder, plus user interface elements for navigating to other folders.

set_current_folder_uri

Sets the current folder for chooser from an URI.

GtkFileChooser.set_current_folder_uri( uri )
uri the URI for the new current folder
Returntrue if the folder could be changed successfully, false otherwise

The user will be shown the full contents of the current folder, plus user interface elements for navigating to other folders.

set_current_name

Sets the current name in the file selector, as if entered by the user.

GtkFileChooser.set_current_name( the )
the filename to use, as a UTF_8 string.

Note that the name passed in here is a UTF_8 string rather than a filename.

This function is meant for such uses as a suggested name in a "Save As..." dialog. If you want to preselect a particular existing file, you should use gtk_file_chooser_set_filename() or gtk_file_chooser_set_uri() instead. Please see the documentation for those functions for an example of using gtk_file_chooser_set_current_name() as well.

set_do_overwrite_confirmation

Sets whether a file chooser in GTK_FILE_CHOOSER_ACTION_SAVE mode will present a confirmation dialog if the user types a file name that already exists.

GtkFileChooser.set_do_overwrite_confirmation( do_overwrite_confirmation )
do_overwrite_confirmation whether to confirm overwriting in save mode

This is FALSE by default.

Regardless of this setting, 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 documentation for the details.

set_extra_widget

Sets an application_supplied widget to provide extra options to the user.

GtkFileChooser.set_extra_widget( extra_widget )
extra_widget widget for extra options

set_filename

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.

GtkFileChooser.set_filename( filename )
filename the filename to set as current
Returntrue if both the folder could be changed and the file was selected successfully, false otherwise.

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.

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 gtk_file_chooser_unselect_all() followed by gtk_file_chooser_select_filename().

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

set_local_only

Sets whether only local files can be selected in the file selector.

GtkFileChooser.set_local_only( local_only )
local_only true if only local files can be selected

If local_only is TRUE (the default), then the selected file are files are guaranteed to be accessible through the operating systems native file file system and therefore the application only needs to worry about the filename functions in GtkFileChooser, like gtk_file_chooser_get_filename(), rather than the URI functions like gtk_file_chooser_get_uri().

set_preview_widget

Sets an application_supplied widget to use to display a custom preview of the currently selected file.

GtkFileChooser.set_preview_widget( preview_widget )
preview_widget widget for displaying preview.

To implement a preview, after setting the preview widget, you connect to the "update_preview" signal, and call gtk_file_chooser_get_preview_filename() or gtk_file_chooser_get_preview_uri() on each change. If you can display a preview of the new file, update your widget and set the preview active using gtk_file_chooser_set_preview_widget_active(). Otherwise, set the preview inactive.

When there is no application_supplied preview widget, or the application_supplied preview widget is not active, the file chooser may display an internally generated preview of the current file or it may display no preview at all

set_preview_widget_active

Sets whether the preview widget set by gtk_file_chooser_set_preview_widget() should be shown for the current filename.

GtkFileChooser.set_preview_widget_active( active )
active whether to display the user_specified preview widget

When active is set to false, the file chooser may display an internally generated preview of the current file or it may display no preview at all. See gtk_file_chooser_set_preview_widget() for more details.

set_select_multiple

Sets whether multiple files can be selected in the file selector.

GtkFileChooser.set_select_multiple( select_multiple )
select_multiple true if multiple files can be selected.

This is only relevant if the action is set to be GTK_FILE_CHOOSER_ACTION_OPEN or GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.

set_show_hidden

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

GtkFileChooser.set_show_hidden( show_hidden )
show_hidden true if hidden files and folders should be displayed.

set_uri

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 the list.

GtkFileChooser.set_uri( uri )
uri the URI to set as current
Returntrue if both the folder could be changed and the URI was selected successfully, false otherwise.

If the chooser is GTK_FILE_CHOOSER_ACTION_SAVE mode, the URI's base name will also appear in the dialog's file name entry.

If the URI isn't in the current folder of chooser, then the current folder of chooser will be changed to the folder containing uri. This is equivalent to a sequence of gtk_file_chooser_unselect_all() followed by gtk_file_chooser_select_uri().

set_use_preview_label

Sets whether the file chooser should display a stock label with the name of the file that is being previewed.

GtkFileChooser.set_use_preview_label( use_label )
use_label whether to display a stock label with the name of the previewed file

The default is true. Applications that want to draw the whole preview area themselves should set this to FALSE and display the name themselves in their preview widget.

signal_confirm_overwrite

This signal gets emitted whenever it is appropriate to present a confirmation dialog when the user has selected a file name that already exists.

GtkFileChooser.signal_confirm_overwrite()

The signal only gets emitted when the file chooser is in GTK_FILE_CHOOSER_ACTION_SAVE mode.

Most applications just need to turn on the "do-overwrite-confirmation" property (or call the gtk_file_chooser_set_do_overwrite_confirmation() function), and they will automatically get a stock confirmation dialog. Applications which need to customize this behavior should do that, and also connect to the "confirm-overwrite" signal.

A signal handler for this signal must return a GtkFileChooserConfirmation value, which indicates the action to take. If the handler determines that the user wants to select a different filename, it should return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN. If it determines that the user is satisfied with his choice of file name, it should return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME. On the other hand, if it determines that the stock confirmation dialog should be used, it should return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM.

signal_current_folder_changed

This signal is emitted when the current folder in a GtkFileChooser changes.

GtkFileChooser.signal_current_folder_changed()

This can happen due to the user performing some action that changes folders, such as selecting a bookmark or visiting a folder on the file list. It can also happen as a result of calling a function to explicitly change the current folder in a file chooser.

Normally you do not need to connect to this signal, unless you need to keep track of which folder a file chooser is showing.

signal_file_activated

This signal is emitted when the user "activates" a file in the file chooser.

GtkFileChooser.signal_file_activated()

This can happen by double-clicking on a file in the file list, or by pressing Enter.

Normally you do not need to connect to this signal. It is used internally by GtkFileChooserDialog to know when to activate the default button in the dialog.

signal_selection_changed

This signal is emitted when there is a change in the set of selected files in a GtkFileChooser.

GtkFileChooser.signal_selection_changed()

This can happen when the user modifies the selection with the mouse or the keyboard, or when explicitly calling functions to change the selection.

[...]

signal_update_preview

This signal is emitted when the preview in a file chooser should be regenerated.

GtkFileChooser.signal_update_preview()

For example, this can happen when the currently selected file changes. You should use this signal if you want your file chooser to have a preview widget.

Once you have installed a preview widget with gtk_file_chooser_set_preview_widget(), you should update it when this signal is emitted. You can use the functions gtk_file_chooser_get_preview_filename() or gtk_file_chooser_get_preview_uri() to get the name of the file to preview. Your widget may not be able to preview all kinds of files; your callback must call gtk_file_chooser_set_preview_widget_active() to inform the file chooser about whether the preview was generated successfully or not.

unselect_all

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

GtkFileChooser.unselect_all()

unselect_filename

Unselects a currently selected filename.

GtkFileChooser.unselect_filename( filename )
filename the filename to unselect

If the filename is not in the current directory, does not exist, or is otherwise not currently selected, does nothing.

unselect_uri

Unselects the file referred to by uri.

GtkFileChooser.unselect_uri( uri )
uri the URI to unselect

If the file is not in the current directory, does not exist, or is otherwise not currently selected, does nothing.

Made with http://www.falconpl.org