[fxruby-users] FXFileList & default icons

jeroen jeroen at fox-toolkit.org
Mon Aug 30 09:41:30 EDT 2004


On Sunday 29 August 2004 10:06 pm, Juraj Sujan wrote:
> Hello,
>
> I'm developing the simple file manager using FXFileList. I
> don't know how to override the default filelist icons for
> directory/file/application with my own icons. There are no
> methods/functions to do that. I looked into the cpp fox code
> of FXFileList and there are (in constructor) initialized
> these variables:
>
>
> big_folder=new FXGIFIcon(getApp(),bigfolder);
> mini_folder=new FXGIFIcon(getApp(),minifolder);
> big_doc=new FXGIFIcon(getApp(),bigdoc);
> mini_doc=new FXGIFIcon(getApp(),minidoc);
> big_app=new FXGIFIcon(getApp(),bigapp);
> mini_app=new FXGIFIcon(getApp(),miniapp);
>
> The icon streams are from icons.cpp. As far as I can
> understand, these default icons cannot be customized. Maybe

They're just fallback icons, used in case no bindings have
been found in the registry.

> in cpp but I don't know how it could be done through FXRuby.
>  At the beginning I thought I could do it through
> associations but it seems to me like these variables have
> nothing to do with them. In fact these icons are the
> fallback icons, in case there are no defined assotiations.
> See the code later in FXFileList.cpp:
>
>       // Assume no associations
>       fileassoc=NULL;
>
>       // Determine icons and type
>       if(item->state&FXFileItem::FOLDER){
>         big=big_folder;
>         mini=mini_folder;
>         extension="File Folder";
>         if(associations)
> fileassoc=associations->findDirBinding(pathname.text());
>         }
>       else if(item->state&FXFileItem::EXECUTABLE){
>         big=big_app;
>         mini=mini_app;
>         extension="Application";
>         if(associations)
> fileassoc=associations->findExecBinding(pathname.text());
>         }
>       else{
>         big=big_doc;
>         mini=mini_doc;
>         extension=FXFile::extension(pathname).upper();
>         if(!extension.empty()) extension+=" File";
>         if(associations)
> fileassoc=associations->findFileBinding(pathname.text());
>         }
>
>       // If association is found, use it
>       if(fileassoc){
>         extension=fileassoc->extension;
>         if(fileassoc->bigicon) big=fileassoc->bigicon;
>         if(fileassoc->miniicon) mini=fileassoc->miniicon;
>         // FIXME use open icons also, useful when dragging
> over directory
>         }
>
> Have anybody some solution for this ? Thanks.

In principle, you can (1) load your file associations
under the [FILETYPES] section.  For example:

	[FILETYPES]
	bmp = "/usr/local/bin/xv %s &;Bitmap Image;image.xpm;mini/image.xpm;image/x-bmp"

Or (2) replace the bindings programmatically using FXFileDict::replace().
A subsequent lookup of the binding will then use the new binding, and
moreover, when the application quits the binding will be logged into
the registry.

FXFileList will ONLY use the hard-wired icons if no bindings have been
found.  We want to make sure programs still work when no bindings 
are available.



	- Jeroen



-- 
+----------------------------------------------------------------------------+
| Copyright (C) 08:30 08/30/2004 Jeroen van der Zijp.   All Rights Reserved. |
+----------------------------------------------------------------------------+



More information about the fxruby-users mailing list