Named image for regular folder?

  • Among the new named images available on Leopard, I see:

    NSImageNameFolderBurnable
    NSImageNameFolderSmart

    I don't see an image name for a regular, unadorned folder. Have I
    overlooked it?

    Jim
  • On Jan 30, 2008, at 10:11 AM, Jim Correia wrote:

    > Among the new named images available on Leopard, I see:
    >
    > NSImageNameFolderBurnable
    > NSImageNameFolderSmart
    >
    > I don't see an image name for a regular, unadorned folder. Have I
    > overlooked it?

    If you don't find anything better, the poor man's solution is -
    [NSWorkspace iconForFile:].  If necessary, you can even name that
    image with -[NSImage setName:] so you'll be able to refer to it from
    nibs.  It won't appear in IB, but if you register the name early
    enough in application startup, it will work at runtime.

    -Ken
  • On Leopard, you can now create an NSImage from a Carbon IconRef

    Icons.h defines a whole heap of additional icons that you can then get
    to. Something like this:

    IconRef carbonIcon;

    NSImage* folderImage = nil;
    OSStatus err = GetIconRef(kOnSystemDisk, kSystemIconsCreator,
    kGenericFolderIcon, &carbonIcon);
    if (!err)
    {
      folderImage = [[NSImage alloc] initWithIconRef:carbonIcon];
      ReleaseIconRef(carbonIcon);
    }

    Matt Gough

    On 30 Jan 2008, at 17:36, Ken Thomases wrote:

    > On Jan 30, 2008, at 10:11 AM, Jim Correia wrote:
    >
    >> Among the new named images available on Leopard, I see:
    >>
    >> NSImageNameFolderBurnable
    >> NSImageNameFolderSmart
    >>
    >> I don't see an image name for a regular, unadorned folder. Have I
    >> overlooked it?
    >
    > If you don't find anything better, the poor man's solution is -
    > [NSWorkspace iconForFile:].  If necessary, you can even name that
    > image with -[NSImage setName:] so you'll be able to refer to it from
    > nibs.  It won't appear in IB, but if you register the name early
    > enough in application startup, it will work at runtime.
    >
    > -Ken
  • On Jan 30, 2008 11:55 AM, Matt Gough <matt.gough...> wrote:
    > On Leopard, you can now create an NSImage from a Carbon IconRef

    Is this supported in 64-bit?

    --Kyle Sluder
  • On Jan 30, 2008 9:19 AM, Kyle Sluder <kyle.sluder+<cocoa-dev...> wrote:
    > On Jan 30, 2008 11:55 AM, Matt Gough <matt.gough...> wrote:
    >> On Leopard, you can now create an NSImage from a Carbon IconRef
    >
    > Is this supported in 64-bit?

    Yes;

    FYI: If you look at the comments in the header, each function has a
    section called "Availability". This tells you which platforms the
    function is available on.

    --
    Clark S. Cox III
    <clarkcox3...>
  • And if your target is a previous iteration of OS X, a simple google yields
    the following:
    http://www.omnigroup.com/mailman/archive/macosx-dev/2002-January/034951.htm
    l


    IconRef -> IconFamilyHandle -> NSData -> NSImage

    That being said, I haven't tried this first hand, but it looks legit. No
    idea about 64-bit on this; I guess though, if you are targetting 64-bit, you
    are linking against 10.5 to begin with.

    Mark Stultz

    On Jan 30, 2008 10:55 AM, Matt Gough <matt.gough...> wrote:

    > On Leopard, you can now create an NSImage from a Carbon IconRef
    >
    > Icons.h defines a whole heap of additional icons that you can then get
    > to. Something like this:
    >
    > IconRef carbonIcon;
    >
    > NSImage* folderImage = nil;
    > OSStatus err = GetIconRef(kOnSystemDisk, kSystemIconsCreator,
    > kGenericFolderIcon, &carbonIcon);
    > if (!err)
    > {
    > folderImage = [[NSImage alloc] initWithIconRef:carbonIcon];
    > ReleaseIconRef(carbonIcon);
    > }
    >
    > Matt Gough
    >
    > On 30 Jan 2008, at 17:36, Ken Thomases wrote:
    >
    >> On Jan 30, 2008, at 10:11 AM, Jim Correia wrote:
    >>
    >>> Among the new named images available on Leopard, I see:
    >>>
    >>> NSImageNameFolderBurnable
    >>> NSImageNameFolderSmart
    >>>
    >>> I don't see an image name for a regular, unadorned folder. Have I
    >>> overlooked it?
    >>
    >> If you don't find anything better, the poor man's solution is -
    >> [NSWorkspace iconForFile:].  If necessary, you can even name that
    >> image with -[NSImage setName:] so you'll be able to refer to it from
    >> nibs.  It won't appear in IB, but if you register the name early
    >> enough in application startup, it will work at runtime.
    >>
    >> -Ken

    >
  • On 30 Jan 2008, at 16:11, Jim Correia wrote:

    > Among the new named images available on Leopard, I see:
    >
    > NSImageNameFolderBurnable
    > NSImageNameFolderSmart
    >
    > I don't see an image name for a regular, unadorned folder. Have I
    > overlooked it?
    >
    > Jim

    Along with the suggested NSWorkspace -iconForFile you can use the
    following:

    NSImage *folderImage = [[[NSWorkspace sharedWorkspace]
    iconForFileType:NSFileTypeForHFSTypeCode(kGenericFolderIcon)];

    Jon
  • On 30.01.2008, at 17:55, Matt Gough wrote:
    > NSImage* folderImage = nil;
    > OSStatus err = GetIconRef(kOnSystemDisk, kSystemIconsCreator,
    > kGenericFolderIcon, &carbonIcon);

      You can also use NSFileTypeForHFSTypeCode() to turn
    kGenericFolderIcon into a string that you can pass to iconForFileType:
    to get at standard icons. That will work on older OS X releases, too.

      See <http://www.zathras.de/angelweb/blog-get-standard-system-
    icons.htm
    > for an example.

    Cheers,
    -- M. Uli Kusterer
    "The Witnesses of TeachText are everywhere..."
    http://www.zathras.de
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today