java-gnome version 4.0.19

org.gnome.gtk
Class FileChooserButton

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.freedesktop.bindings.Proxy
          extended by org.gnome.glib.Object
              extended by org.gnome.gtk.Object
                  extended by org.gnome.gtk.Widget
                      extended by org.gnome.gtk.Container
                          extended by org.gnome.gtk.Box
                              extended by org.gnome.gtk.HBox
                                  extended by org.gnome.gtk.FileChooserButton
All Implemented Interfaces:
FileChooser

public class FileChooserButton
extends HBox
implements FileChooser

Displays a filename and a Button which, if pressed, opens a FileChooserDialog allowing the user to select the file.

This Widget implements the FileChooser interface, which has most of the methods necessary to manipulate the selection in the Widget.

Note that FileChooserButton only supports selecting files (mode OPEN) or directories (mode SELECT_FOLDER). If you need something more complicated, then you'll need to use wrap a FileChooserWidget in a custom Widget or launch a FileChooserDialog.

Since:
4.0.2
Author:
Andrew Cowie
See Also:
FileChooserWidget, FileChooserDialog

Nested Class Summary
static interface FileChooserButton.FileSet
          Signal emitted when the file indicated by this FileChooserButton has been set by the user.
 
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.EnterNotifyEvent, Widget.ExposeEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.UnmapEvent, Widget.VisibilityNotifyEvent
 
Nested classes/interfaces inherited from class org.gnome.gtk.Object
Object.Destroy
 
Constructor Summary
FileChooserButton(String title, FileChooserAction action)
          Creates a new FileChooserButton.
 
Method Summary
 void addFilter(FileFilter filter)
          Add a FileFilter to the list of filters that the user can select between.
 void connect(FileChooserButton.FileSet handler)
          Hook up a callback to handle the FileChooserButton.FileSet signal generated when the file or directory has been selected by the user using this FileChooserButton.
 FileChooserAction getAction()
          Gets the type of operation that the file chooser is performing.
 String getCurrentFolder()
          Get the current folder being displayed in this FileChooser.
 String getFilename()
          Get the filename currently selected by this FileChooser.
 FileFilter getFilter()
          Gets the current filter.
 URI getURI()
          Get the URI representing the file or directory currently selected by this FileChooser.
 void setAction(FileChooserAction action)
          Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action.
 boolean setCurrentFolder(String directory)
          Set the current directory for this FileChooser.
 boolean setFilename(String filename)
          Set the file you want selected in the FileChooser.
 void setFilter(FileFilter filter)
          Sets the current filter; only the files that pass the filter will be displayed.
 
Methods inherited from class org.gnome.gtk.Box
getSpacing, packEnd, packStart, reorderChild, setSpacing
 
Methods inherited from class org.gnome.gtk.Container
add, getChildren, remove, setBorderWidth
 
Methods inherited from class org.gnome.gtk.Widget
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getRequisition, getSensitive, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, modifyBackground, modifyBase, modifyFont, modifyText, queueDraw, queueDrawArea, realize, setCanDefault, setCanFocus, setColormap, setEvents, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll
 
Methods inherited from class org.gnome.gtk.Object
connect, destroy
 
Methods inherited from class org.freedesktop.bindings.Pointer
toString
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileChooserButton

public FileChooserButton(String title,
                         FileChooserAction action)
Creates a new FileChooserButton. The selected file is unset, and will appear as "(none)" in the display.

Parameters:
title - a title for the FileChooserDialog when it is popped.
action - which style of FileChooser you want. Only OPEN (selecting a single file), and SELECT_FOLDER, (selecting a single directory) are enabled for FileChooserButton.
Since:
4.0.2
Method Detail

addFilter

public void addFilter(FileFilter filter)
Description copied from interface: FileChooser
Add a FileFilter to the list of filters that the user can select between. When a filter is selected, only files that are passed by that filter are displayed.

Specified by:
addFilter in interface FileChooser
See Also:
FileFilter

connect

public void connect(FileChooserButton.FileSet handler)
Hook up a callback to handle the FileChooserButton.FileSet signal generated when the file or directory has been selected by the user using this FileChooserButton.

Since:
4.0.5

getAction

public FileChooserAction getAction()
Description copied from interface: FileChooser
Gets the type of operation that the file chooser is performing.

Specified by:
getAction in interface FileChooser
See Also:
FileChooser.setAction(FileChooserAction)

getCurrentFolder

public String getCurrentFolder()
Description copied from interface: FileChooser
Get the current folder being displayed in this FileChooser. Note that this is not the same as the currently-selected folder if the FileChooser is in SELECT_FOLDER mode. To get the currently-selected folder in that mode, you can use FileChooser.getURI() instead.

Specified by:
getCurrentFolder in interface FileChooser
Returns:
The current folder, or null if if the FileChooser was unable to load the last folder that was requested of it (as would happen if calling FileChooser.setCurrentFolder(String) on a nonexistent directory).
See Also:
FileChooser.getFilename()

getFilename

public String getFilename()
Description copied from interface: FileChooser
Get the filename currently selected by this FileChooser.

Specified by:
getFilename in interface FileChooser
Returns:
The filename, or if no file is selected then this will return null. If multiple files are selected, one of the filenames will be returned at random. If the FileChooser is in one of the folder modes, this returns the selected folder's name.

getFilter

public FileFilter getFilter()
Description copied from interface: FileChooser
Gets the current filter.

This function is specially useful on "Save" FileChoosers, to know the file type chosen by the user.

Specified by:
getFilter in interface FileChooser
See Also:
FileFilter

getURI

public URI getURI()
Description copied from interface: FileChooser
Get the URI representing the file or directory currently selected by this FileChooser.

Specified by:
getURI in interface FileChooser
Returns:
The selected file's URI, or if no file is selected then this will return null. If multiple files are selected, one of the filenames will be returned at random. If the FileChooser is in one of the folder modes, this returns the selected folder's URI.

setAction

public void setAction(FileChooserAction action)
Description copied from interface: FileChooser
Sets the type of operation that the chooser is performing; the user interface is adapted to suit the selected action. For example, an option to create a new folder might be shown if the action is SAVE but not if the action is OPEN.

Specified by:
setAction in interface FileChooser

setCurrentFolder

public boolean setCurrentFolder(String directory)
Description copied from interface: FileChooser
Set the current directory for this FileChooser. The user will be shown the full contents of that folder, plus user interface elements for navigating to other folders.

Specified by:
setCurrentFolder in interface FileChooser
Parameters:
directory - the full path of the new current folder
Returns:
true if the folder could be changed successfully, false otherwise.

setFilename

public boolean setFilename(String filename)
Description copied from interface: FileChooser
Set the file you want selected in the FileChooser.

If the folder currently showing in the FileChooser isn't the directory containing the filename you specify, then the FileChooser will be changed to that directory.

Specified by:
setFilename in interface FileChooser
Parameters:
filename - Must be an absolute path.
Returns:
true if the the directory was changed (if necessary) and a file was successfully selected.

setFilter

public void setFilter(FileFilter filter)
Description copied from interface: FileChooser
Sets the current filter; only the files that pass the filter will be displayed. If the user-selectable list of filters is non-empty, then the filter should be one of the filters in that list.

Setting the current filter when the list of filters is empty is useful if you want to restrict the displayed set of files without letting the user change it.

Specified by:
setFilter in interface FileChooser
See Also:
FileFilter


java-gnome