Replacement for MBS IconFamilyMBS functionality

I know that this has been discussed before, but the IconFamilyMBS is now gone and I’m looking for the proper replacement logic for this code that pulls the icon for a provided file extension:

i = New IconMBS("", "", theExtension, "") WMain.lbRestorePaths.RowPicture(WMain.lbRestorePaths.LastIndex) = i.IconFamily.Icon(26)

@Christian Schmitz ?

FolderItem.IconMBS could do it.

For a family type? In other words, I may not have a handle to an actual file, but I want to display the icon that the user’s system would normally assign to a file of the type defined by the extension provided.

IconFamily allowed that.

NSWorkspaceMBS.IconMBS gives a NSImageMBS object. You can use setSize to change size and copyPicture to get pictures for each size.

The NSImageMBS contains several resolutions.

It’s not the resolution that I’m looking for, but rather a way to retrieve the general icon for a “type” of file. In the above code, I’m getting the macOS generic “App” icon and I don’t have a folderitem to pass in. What I was doing with the older IconFamily code was getting the general icon for a family type rather than a specific file. Much the same as what you have provided with the new LinuxIconMBS.SymbolicIcon("application/vim", 22) function.

Ah - I’ve now found the NSWorkSpaceMBS.IconForFileType() function.

Does the “filetype” passed need to be part of the project’s FileTypes definition file or does passing something like “zip” as the extension work?

Any type will work :slight_smile:

I found the online docs for this and noted the discussion of the type.

Is this the correct code for retrieving a generic App icon and creating a 22x22 icon that supports the @1 and @2 sizes when the HiDPI is on?

[code]Dim iconImage As NSImageMBS
Dim iconPic As Picture

iconImage = NSWorkspaceMBS.iconForFileType(“app”)
iconImage.setSize(44, 44)
iconPic = iconImage.CopyPictureWithMask
iconPic.VerticalResolution = 144
iconPic.HorizontalResolution = 144

GenericApp = iconPic[/code]

Or - is this an equivalent?

Dim i As New NSImageMBS i = NSWorkspaceMBS.iconForFileType("fcpbundle") Me.RowPicture(Me.LastIndex) = i.CopyPictureWithMask.ScaleImageAndMaskMBS(22, 22, True)

Both seem to work.

With CopyPictureWithMask, you get a Xojo picture with 44 pixel width/height here.
So this sounds okay if you like a 2x picture.