FX::FXFileDict Class Reference

#include <FXFileDict.h>

Inheritance diagram for FX::FXFileDict:

Inheritance graph
[legend]

List of all members.


Detailed Description

The File Association dictionary associates a file extension with a File Association record which contains command name, mime type, icons, and other information about the file type. The icons referenced by the file association are managed by the Icon Dictionary; this guarantees that each icon is loaded only once into memory. The associations are determined by the information by the FOX Registry settings; each entry under the FILETYPES registry section comprises the command line, extension name, large icon, small icon, and mime type:

command ';' extension ';' bigicon [ ':' bigiconopen ] ';' icon [ ':' iconopen ] ';' mime [ ';' flags ]

For example, the binding for "jpg" could be:

xv s &;JPEG Image;bigimage.xpm;miniimage.xpm;image/jpeg;term

The association for a file name is determined by first looking at the entire file name, then at the whole extension, and then at sub-extensions. For example, "name.tar.gz", "tar.gz", and "gz" can each be given a different file association. Directory names may also be given associations; there is no command-line association for a directory, however. The association for a directory is found by first checking the whole pathname, then checking the pathname less the first component, and so on. So, "/usr/local/include", "/local/include", and "/include" can each be given their own file associations. If the above lookup procedure has not found a file association, the system uses a fallback associations: for files, the fallback association is determined by the binding "defaultfilebinding". For directories, the "defaultdirbinding" is used, and for executables the "defaultexecbinding" is used. 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.

Public Member Functions

 FXFileDict (FXApp *app)
 FXFileDict (FXApp *app, FXSettings *db)
void setSettings (FXSettings *s)
FXSettingsgetSettings () const
void setIconDict (FXIconDict *icns)
FXIconDictgetIconDict () const
void setIconPath (const FXString &path)
const FXStringgetIconPath () const
FXFileAssocreplace (const FXchar *ext, const FXchar *str)
FXFileAssocremove (const FXchar *ext)
FXFileAssocfind (const FXchar *ext)
virtual FXFileAssocfindFileBinding (const FXchar *pathname)
virtual FXFileAssocfindDirBinding (const FXchar *pathname)
virtual FXFileAssocfindExecBinding (const FXchar *pathname)
virtual void save (FXStream &store) const
virtual void load (FXStream &store)
virtual ~FXFileDict ()
void size (FXint m)
FXint size () const
FXint no () const
void * insert (const FXchar *ky, const void *ptr, bool mrk=false)
void * replace (const FXchar *ky, const void *ptr, bool mrk=false)
void * find (const FXchar *ky) const
bool empty (FXint pos) const
const FXchar * key (FXuint pos) const
void * data (FXuint pos) const
bool mark (FXuint pos) const
FXint first () const
FXint last () const
FXint next (FXint pos) const
FXint prev (FXint pos) const
void clear ()
virtual long onDefault (FXObject *, FXSelector, void *)
const FXchar * getClassName () const
bool isMemberOf (const FXMetaClass *metaclass) const
virtual long tryHandle (FXObject *sender, FXSelector sel, void *ptr)
QTransString tr (const char *text, const char *hint=0)
virtual void * getPythonObject () const
virtual void decouplePythonObject () const

Static Public Attributes

static const FXchar * defaultExecBinding
static const FXchar * defaultDirBinding
static const FXchar * defaultFileBinding

Protected Member Functions

virtual void * createData (const void *)
virtual void deleteData (void *)

Static Protected Member Functions

static FXint hash (const FXchar *str)

Protected Attributes

FXDictEntry * dict
FXint total
FXint number


Constructor & Destructor Documentation

FX::FXFileDict::FXFileDict ( 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::FXFileDict::FXFileDict ( FXApp app,
FXSettings db 
)

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 FX::FXFileDict::~FXFileDict (  )  [virtual]

Destructor.


Member Function Documentation

virtual void* FX::FXFileDict::createData ( const void *   )  [protected, virtual]

Overload this function in a derived class to return the data pointer given an input pointer; the default implementation just returns the input pointer.

Reimplemented from FX::FXDict.

virtual void FX::FXFileDict::deleteData ( void *   )  [protected, virtual]

Overload this function in a derived class to delete the pointer previously returned by createData(); the default implementation does nothing.

Reimplemented from FX::FXDict.

void FX::FXFileDict::setSettings ( FXSettings s  )  [inline]

Change settings database.

FXSettings* FX::FXFileDict::getSettings (  )  const [inline]

Return settings database.

void FX::FXFileDict::setIconDict ( FXIconDict icns  )  [inline]

Change icon dictionary.

FXIconDict* FX::FXFileDict::getIconDict (  )  const [inline]

Return icon dictionary.

void FX::FXFileDict::setIconPath ( const FXString path  ) 

Set icon search path; the initial search path is determined by the "iconpath" registry setting in the SETTINGS section.

const FXString& FX::FXFileDict::getIconPath (  )  const

Return current icon search path.

FXFileAssoc* FX::FXFileDict::replace ( const FXchar *  ext,
const FXchar *  str 
)

Replace file association. The new association is written into the settings database under the FILETYPES section; the format of the association is as follows:

<extension> = "<command> ; <type> ; <bigicon> [ : <bigopenicon> ] ; <smallicon> [ : <smalliconopen> ] ; <mimetype>"

Where <command> is the command used to launch the application (e.g. "xv %s &"), and <type> is the file type string (e.g. "GIF Image"), <bigicon> and <bigiconopen> are the large icons shown in "Icons" mode, <smallicon> and <smalliconopen> are the small icons shown in "Details" mode, and <mimetype> is the RFC2045 mime type of the file.

For example:

[FILETYPES] gif="xv s &;GIF Image;big.xpm:bigopen.xpm;mini.xpm:miniopen.xpm;image/gif" /home/jeroen=";Home;home.xpm;minihome.xpm;application/x-folder"

FXFileAssoc* FX::FXFileDict::remove ( const FXchar *  ext  ) 

Remove file association.

Reimplemented from FX::FXDict.

FXFileAssoc* FX::FXFileDict::find ( const FXchar *  ext  ) 

Find file association from registry.

virtual FXFileAssoc* FX::FXFileDict::findFileBinding ( const FXchar *  pathname  )  [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.

virtual FXFileAssoc* FX::FXFileDict::findDirBinding ( const FXchar *  pathname  )  [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 FXFileAssoc* FX::FXFileDict::findExecBinding ( const FXchar *  pathname  )  [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 void FX::FXFileDict::save ( FXStream store  )  const [virtual]

Save to stream.

Reimplemented from FX::FXObject.

virtual void FX::FXFileDict::load ( FXStream store  )  [virtual]

Load from stream.

Reimplemented from FX::FXObject.

void FX::FXDict::size ( FXint  m  )  [inherited]

Resize the table to the given size.

FXint FX::FXDict::size (  )  const [inline, inherited]

Return the size of the table, including the empty slots.

FXint FX::FXDict::no (  )  const [inline, inherited]

Return the total number of entries in the table.

void* FX::FXDict::insert ( const FXchar *  ky,
const void *  ptr,
bool  mrk = false 
) [inherited]

Insert a new entry into the table given key and mark. If there is already an entry with that key, leave it unchanged, otherwise insert the new entry.

Referenced by FX::FXStringDict::insert(), and FX::FXIconDict::insert().

void* FX::FXDict::replace ( const FXchar *  ky,
const void *  ptr,
bool  mrk = false 
) [inherited]

Replace data at key, if the entry's mark is less than or equal to the given mark. If there was no existing entry, a new entry is inserted with the given mark.

Referenced by FX::FXStringDict::replace().

void* FX::FXDict::find ( const FXchar *  ky  )  const [inherited]

Find data pointer given key.

Reimplemented in FX::FXSettings, and FX::FXStringDict.

Referenced by FX::FXStringDict::find(), FX::FXSettings::find(), and FX::FXIconDict::find().

bool FX::FXDict::empty ( FXint  pos  )  const [inline, inherited]

Return true if slot is empty.

const FXchar* FX::FXDict::key ( FXuint  pos  )  const [inline, inherited]

Return key at position pos.

void* FX::FXDict::data ( FXuint  pos  )  const [inline, inherited]

return data pointer at position pos.

Reimplemented in FX::FXSettings, and FX::FXStringDict.

Referenced by FX::FXSettings::data().

bool FX::FXDict::mark ( FXuint  pos  )  const [inline, inherited]

Return mark flag of entry at position pos.

FXint FX::FXDict::first (  )  const [inherited]

Return position of first filled slot, or >= total

FXint FX::FXDict::last (  )  const [inherited]

Return position of last filled slot or -1

FXint FX::FXDict::next ( FXint  pos  )  const [inherited]

Return position of next filled slot in hash table or a value greater than or equal to total if no filled slot was found

FXint FX::FXDict::prev ( FXint  pos  )  const [inherited]

Return position of previous filled slot in hash table or a -1 if no filled slot was found

void FX::FXDict::clear (  )  [inherited]

Clear all entries.

Reimplemented in FX::FXSettings.

virtual long FX::FXObject::onDefault ( FXObject ,
FXSelector  ,
void *   
) [virtual, inherited]

Called for unhandled messages.

Reimplemented in FX::FXDelegator, FX::FXGLViewer, FX::FXMDIChild, and FX::FXMDIClient.

const FXchar* FX::FXObject::getClassName (  )  const [inherited]

Get class name of some object.

bool FX::FXObject::isMemberOf ( const FXMetaClass metaclass  )  const [inherited]

Check if object is member of metaclass.

virtual long FX::FXObject::tryHandle ( FXObject sender,
FXSelector  sel,
void *  ptr 
) [virtual, inherited]

Try handle message safely.

QTransString FX::FXObject::tr ( const char *  text,
const char *  hint = 0 
) [inherited]

Returns a human translated version of the text to the locale language (warning: uses a virtual method call, so can't use before construction)

virtual void* FX::FXObject::getPythonObject (  )  const [inline, virtual, inherited]

Returns the python object representing this instance (if created in python).

virtual void FX::FXObject::decouplePythonObject (  )  const [inline, virtual, inherited]

Causes decoupling of python object from this object (deletes self).


Member Data Documentation

const FXchar* FX::FXFileDict::defaultExecBinding [static]

Registry key used to find fallback executable icons.

const FXchar* FX::FXFileDict::defaultDirBinding [static]

Registry key used to find fallback directory icons.

const FXchar* FX::FXFileDict::defaultFileBinding [static]

Registry key used to find fallback document icons.


The documentation for this class was generated from the following file:

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 21:58:50 2008 for TnFOX by doxygen v1.5.6