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 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. Juraj Sujan juice@sofy.sk
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. MaybeThey''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. | +----------------------------------------------------------------------------+
jeroen <jeroen@fox-toolkit.org> wrote:> > They''re just fallback icons, used in case no bindings > have > been found in the registry. > > > 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. > >yes, I know about the associations and of course, I want to use my own icons for certain filetypes. But consider this example situation: There is one directory and two files displayed in list (one png and one jpg image). I will define the association for png filetype. Then it will display my own icon for png file but hard-wired icon for directory and for jpg file (as it is unassociated). But I would like to override ALSO these two icons with my own. In other words, I would like to display my own fallback icons EVEN for files without associations. So, here is my question again: How to do it ? Could it be done with associations ? I don''t think so. I imagine something like this (in FXRuby): filelist = FXFileList.new(....) filelist.miniFolderIcon = FXPNGIcon.new(@app, File.open("my_folder_icon.png", "rb").read) ...and so on Standard hard-wired icons are nice, but I would like to use my own, COMPLETELY customized iconset (KDE and GNOME iconsets are really cool, wouldn''t it be nice to use them ?). Juraj Sujan
jeroen <jeroen@fox-toolkit.org> wrote:> > They''re just fallback icons, used in case no bindings > have > been found in the registry. > > > 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. > >yes, I know about the associations and of course, I want to use my own icons for certain filetypes. But consider this example situation: There is one directory and two files displayed in list (one png and one jpg image). I will define the association for png filetype. Then it will display my own icon for png file but hard-wired icon for directory and for jpg file (as it is unassociated). But I would like to override ALSO these two icons with my own. In other words, I would like to display my own fallback icons EVEN for files without associations. So, here is my question again: How to do it ? Could it be done with associations ? I don''t think so. I imagine something like this (in FXRuby): filelist = FXFileList.new(....) filelist.miniFolderIcon = FXPNGIcon.new(@app, File.open("my_folder_icon.png", "rb").read) ...and so on Standard hard-wired icons are nice, but I would like to use my own, COMPLETELY customized iconset (KDE and GNOME iconsets are really cool, wouldn''t it be nice to use them ?). Juraj Sujan
On Wednesday 01 September 2004 11:07 am, Juraj Sujan wrote:> jeroen <jeroen@fox-toolkit.org> wrote: > > > > > They''re just fallback icons, used in case no bindings > > have > > been found in the registry. > > > > > > 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. > > > > > > yes, I know about the associations and of course, I want to > use my own icons for certain filetypes. But consider this > example situation: > > There is one directory and two files displayed in list (one > png and one jpg image). I will define the association for > png filetype. Then it will display my own icon for png file > but hard-wired icon for directory and for jpg file (as it is > unassociated). But I would like to override ALSO these two > icons with my own. In other words, I would like to display > my own fallback icons EVEN for files without associations. > > So, here is my question again: How to do it ? Could it be > done with associations ? I don''t think so.Yes, that situation is covered in the implementation already; you can ALSO create default fallbacks, for executables, directories, and normal files: [FILETYPES] defaultfilebinding = "/usr/local/bin/adie %s &;Document;document.xpm;mini/document.xpm" defaultexecbinding = ";Application;exec.xpm;mini/exec.xpm;application/x-executable-file" defaultdirbinding = ";Folder;folder.xpm:folder_open.xpm;mini/folder.xpm:mini/folder_open.xpm;application/x-folder" If you have that, then these bindings will be used when no other bindings are available. The hard-wired icons are ONLY there to make sure the program works, come hell or high water. Normally, you''d have a populated .foxrc/Desktop file and you''ll never see them... I usually have one directory binding like: /home/jeroen = ";Home Directory;kfm_home.xpm;mini/kfm_home.xpm;application/x-folder" And maybe: /mnt/zip = ";Zip Drive;zip_mount.xpm;mini/zip_mount.xpm;application/x-folder" /mnt/cdrom = ";CDROM Drive;cdrom_mount.xpm;mini/cdrom_mount.xpm;application/x-folder" /mnt/floppy = ";Floppy Drive;3floppy_mount.xpm;mini/3floppy_mount.xpm;application/x-folder" Finally, the setting: [SETTINGS] iconpath = /home/jeroen/ICONS:/usr/share/icons The iconpath determines where it looks for the icons; its just like a UNIX path, directory names separated by ":". - Jeroen
Thanks a lot for explanation. This is exactly what I wanted to know. Juraj> > Yes, that situation is covered in the implementation > already; you can ALSO > create default fallbacks, for executables, directories, > and normal files: > > [FILETYPES] > defaultfilebinding = "/usr/local/bin/adie %s > &;Document;document.xpm;mini/document.xpm" > defaultexecbinding >";Application;exec.xpm;mini/exec.xpm;application/x-executable-file"> defaultdirbinding >";Folder;folder.xpm:folder_open.xpm;mini/folder.xpm:mini/folder_open.xpm;application/x-folder"> > If you have that, then these bindings will be used when > no other bindings are > available. The hard-wired icons are ONLY there to make > sure the program works, > come hell or high water. Normally, you''d have a > populated .foxrc/Desktop file > and you''ll never see them... > > > I usually have one directory binding like: > > /home/jeroen = ";Home > Directory;kfm_home.xpm;mini/kfm_home.xpm;application/x-folder" > > And maybe: > > /mnt/zip = ";Zip > Drive;zip_mount.xpm;mini/zip_mount.xpm;application/x-folder" > /mnt/cdrom = ";CDROM >Drive;cdrom_mount.xpm;mini/cdrom_mount.xpm;application/x-folder"> /mnt/floppy = ";Floppy >Drive;3floppy_mount.xpm;mini/3floppy_mount.xpm;application/x-folder"> > Finally, the setting: > > [SETTINGS] > iconpath = /home/jeroen/ICONS:/usr/share/icons > > > The iconpath determines where it looks for the icons; its > just like > a UNIX path, directory names separated by ":". >