Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
The FileAssociations object manages file associations between a file extension and a FileAssoc record which contains command name, mime-type, icons, and other information about a type of file. More...
#include <FXFileAssociations.h>
Public Member Functions | |
FXFileAssociations (FXApp *app) | |
Construct a dictionary mapping file-extension to file associations, using the application registry settings as a source for the bindings. More... | |
FXFileAssociations (FXApp *app, FXSettings *sdb) | |
Construct a dictionary mapping file-extension to file associations, using the specified settings database as a source for the bindings. More... | |
void | setSettings (FXSettings *sdb) |
Change settings database being used to determine extension mappings. | |
FXSettings * | getSettings () const |
Return settings database. | |
void | setIconSource (FXIconSource *src) |
Change the IconSource object used by the icon cache to load icons. | |
FXIconSource * | getIconSource () const |
Return the current IconSource object. | |
void | setIconPath (const FXString &path) |
Set the icon search paths for the icon cache. | |
const FXString & | getIconPath () const |
Return the current icon search paths from the icon cache. | |
virtual FXFileAssoc * | parse (const FXString &assoc) |
Parse string containing description of the association. | |
virtual FXFileAssoc * | fetch (const FXString &ext) |
Return mapping of input string to file-association; if no mapping exists, try to add a new association mapping by consulting the FILETYPES section of the settings database. More... | |
virtual FXFileAssoc * | findFileBinding (const FXString &pathname) |
Determine binding for the given file. More... | |
virtual FXFileAssoc * | findDirBinding (const FXString &pathname) |
Find directory binding from registry. More... | |
virtual FXFileAssoc * | findExecBinding (const FXString &pathname) |
Determine binding for the given executable. More... | |
void | clear () |
Delete all file-associations, and clear all icons from the cache. | |
virtual void | save (FXStream &store) const |
Save object to stream. | |
virtual void | load (FXStream &store) |
Load object from stream. | |
virtual | ~FXFileAssociations () |
Delete all FileAssoc's, and the IconCache. | |
Public Member Functions inherited from FX::FXObject | |
const FXchar * | getClassName () const |
Get class name of some object. | |
FXbool | isMemberOf (const FXMetaClass *metaclass) const |
Check if object is member of metaclass. | |
virtual long | tryHandle (FXObject *sender, FXSelector sel, void *ptr) |
Try handle message safely, catching certain exceptions. | |
virtual long | onDefault (FXObject *, FXSelector, void *) |
Called for unhandled messages. | |
virtual | ~FXObject () |
Virtual destructor. | |
Static Public Attributes | |
static const FXchar | defaultExecBinding [] |
Registry key used to find fallback executable icons. | |
static const FXchar | defaultDirBinding [] |
Registry key used to find fallback directory icons. | |
static const FXchar | defaultFileBinding [] |
Registry key used to find fallback document icons. | |
Protected Attributes | |
FXFileAssocDictionary | bindings |
FXIconCache | cache |
FXSettings * | settings |
The FileAssociations object manages file associations between a file extension and a FileAssoc record which contains command name, mime-type, icons, and other information about a type of file.
Icons referenced by the FileAssoc record are managed by an icon cache, which guarantees that each icon is loaded into memory only once, when it is encountered for the first time. Associations for a file or directory are determined by the information in the FOX Registry setting under the "FILETYPES" section. Each entry maps a (partial) pathname to an association record comprising command name, description, large and small icons, mime-types, and flags:
command ';' description ';' bigicon [ ':' bigiconopen ] ';' icon [ ':' iconopen ] ';' mime [ ';' flags ]
For example, the binding for "bmp" would be:
[FILETYPES] bmp="eog %s &;Bitmap Image;bigimage.bmp;miniimage.bmp;image/x-ms-bmp;"
And bindings for directories would be like:
[FILETYPES] /=";Root Folder;bigroot.bmp:bigroot_open.bmp;miniroot.bmp:miniroot_open.bmp;application/x-folder;" /home/jane=";Home Folder;mansion.bmp:mansion_open.bmp;hut.bmp:hut_open.bmp;application/x-folder;"
Three types of pathnames are distinguished: regular files, directories, and executable files. The association for a regular file name is determined by first looking at the entire file name, then at the whole extension, and then at sub-extensions. For example, "package.tar.gz", "tar.gz", and "gz" can each be given a different file associations. If no extension is found, then a special fallback extension "defaultfilebinding" is consulted. Thus, you can assign fallback properties for all reguler files by setting the "defaultfilebinding" entry under the "FILETYPES" section. The association for a directory name is found by first checking the full pathname, then dropping leading directory components in turn. For example: "/usr/local/include", "/local/include", and "/include" are checked in turn. This scheme allows convenient assignment of an association for projects with common directory-structures but different project roots. If a directory association is not found, a fallback association "defaultdirbinding" is used to determine the association. The association for an executable file is found by looking up the binding for the "defaultexecbinding" under the "FILETYPES" section. The flags field is used for a number of bit-flags; two flags are currently defined: 'cd' and 'term'. The first one is intended to cause a launcher to execute the application in the shown directory; the second one is meant to indicate that the application is to be ran inside a new terminal.
FX::FXFileAssociations::FXFileAssociations | ( | FXApp * | app | ) |
Construct a dictionary mapping file-extension to file associations, using the application registry settings as a source for the bindings.
The pointer to the application class is passed down to the icon source which is inside the icon dictionary.
FX::FXFileAssociations::FXFileAssociations | ( | FXApp * | app, |
FXSettings * | sdb | ||
) |
Construct a dictionary mapping file-extension to file associations, using the specified settings database as a source for the bindings.
The pointer to the application class is passed down to the icon source which is inside the icon dictionary.
|
virtual |
Return mapping of input string to file-association; if no mapping exists, try to add a new association mapping by consulting the FILETYPES section of the settings database.
You can overload this function if you need to supply custom mappings for selected extensions.
|
virtual |
Find directory binding from registry.
The default implementation tries the whole pathname first, then tries successively smaller parts of the path. For example, a pathname "/usr/people/jeroen":
"/usr/people/jeroen" "/people/jeroen" "/jeroen"
are tried in succession. If no bindings are found, the key "defaultdirbinding" is tried as a fallback association. A NULL is returned if no association of any kind is found.
|
virtual |
Determine binding for the given executable.
The default implementation returns the fallback binding associated with the key "defaultexecbinding". A NULL is returned if no association of any kind is found.
|
virtual |
Determine binding for the given file.
The default implementation tries the whole filename first, then tries the extensions. For example, for a file "source.tar.gz":
"source.tar.gz", "tar.gz", "gz"
are tried in succession. If no association is found the key "defaultfilebinding" is tried as a fallback association. A NULL is returned if no association of any kind is found.
Copyright © 1997-2022 Jeroen van der Zijp |