Learn R Programming

RGtk2 (version 2.12.17)

GtkFileChooser: GtkFileChooser

Description

File chooser interface used by GtkFileChooserWidget and GtkFileChooserDialog

Arguments

Methods and Functions

gtkFileChooserSetAction(object, action) gtkFileChooserGetAction(object) gtkFileChooserSetLocalOnly(object, local.only) gtkFileChooserGetLocalOnly(object) gtkFileChooserSetSelectMultiple(object, select.multiple) gtkFileChooserGetSelectMultiple(object) gtkFileChooserSetShowHidden(object, show.hidden) gtkFileChooserGetShowHidden(object) gtkFileChooserSetDoOverwriteConfirmation(object, do.overwrite.confirmation) gtkFileChooserGetDoOverwriteConfirmation(object) gtkFileChooserSetCurrentName(object, name) gtkFileChooserGetFilename(object) gtkFileChooserSetFilename(object, filename) gtkFileChooserSelectFilename(object, filename) gtkFileChooserUnselectFilename(object, filename) gtkFileChooserSelectAll(object) gtkFileChooserUnselectAll(object) gtkFileChooserGetFilenames(object) gtkFileChooserSetCurrentFolder(object, filename) gtkFileChooserGetCurrentFolder(object) gtkFileChooserGetUri(object) gtkFileChooserSetUri(object, uri) gtkFileChooserSelectUri(object, uri) gtkFileChooserUnselectUri(object, uri) gtkFileChooserGetUris(object) gtkFileChooserSetCurrentFolderUri(object, uri) gtkFileChooserGetCurrentFolderUri(object) gtkFileChooserSetPreviewWidget(object, preview.widget) gtkFileChooserGetPreviewWidget(object) gtkFileChooserSetPreviewWidgetActive(object, active) gtkFileChooserGetPreviewWidgetActive(object) gtkFileChooserSetUsePreviewLabel(object, use.label) gtkFileChooserGetUsePreviewLabel(object) gtkFileChooserGetPreviewFilename(object) gtkFileChooserGetPreviewUri(object) gtkFileChooserSetExtraWidget(object, extra.widget) gtkFileChooserGetExtraWidget(object) gtkFileChooserAddFilter(object, filter) gtkFileChooserRemoveFilter(object, filter) gtkFileChooserListFilters(object) gtkFileChooserSetFilter(object, filter) gtkFileChooserGetFilter(object) gtkFileChooserAddShortcutFolder(object, folder, .errwarn = TRUE) gtkFileChooserRemoveShortcutFolder(object, folder, .errwarn = TRUE) gtkFileChooserListShortcutFolders(object) gtkFileChooserAddShortcutFolderUri(object, uri, .errwarn = TRUE) gtkFileChooserRemoveShortcutFolderUri(object, uri, .errwarn = TRUE) gtkFileChooserListShortcutFolderUris(object)

Hierarchy

GInterface +----GtkFileChooser

Implementations

GtkFileChooser is implemented by GtkFileChooserButton, GtkFileChooserWidget and GtkFileChooserDialog.

File Names and Encodings

When the user is finished selecting files in a GtkFileChooser, 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. PLEASE NOTE: This means that while you can pass the result of gtkFileChooserGetFilename to open(2) or fopen(3), you may not be able to directly set it as the text of a GtkLabel widget unless you convert it first to UTF-8, which all GTK+ widgets expect. You should use gFilenameToUtf8() 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 gtkFileChooserSetPreviewWidget. Then, connect to the "update-preview" signal to get notified when you need to update the contents of the preview. Your callback should use gtkFileChooserGetPreviewFilename to see what needs previewing. Once you have generated the preview for the corresponding file, you must call gtkFileChooserSetPreviewWidgetActive with a boolean flag that indicates whether your callback could successfully generate a preview. Sample Usage update_preview_cb <- function(file_chooser, preview) { filename <- file_chooser$getPreviewFilename()

pixbuf <- gdkPixbuf(file=filename, w=128, h=128)[[1]] have_preview <- !is.null(pixbuf)

preview$setFromPixbuf(pixbuf)

file_chooser$setPreviewWidgetActive(have_preview) }

preview <- gtkImage() my_file_chooser$setPreviewWidget(preview) gSignalConnect(my_file_chooser, "update-preview", update_preview_cb, preview)

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 gtkFileChooserSetExtraWidget to insert additional widgets in a file chooser. Sample Usage toggle <- gtkCheckButton("Open file read-only") my_file_chooser$setExtraWidget(toggle) PLEASE NOTE: If you want to set more than one extra widget in the file chooser, you can a container such as a GtkVBox or a GtkTable and include your widgets in it. Then, set the container as the whole extra widget.

References

http://developer.gnome.org/doc/API/2.0/gtk/GtkFileChooser.html

See Also

GtkFileChooserDialog GtkFileChooserWidget GtkFileChooserButton