From: Tom Medhurst Date: 2009-03-14T02:11:36+09:00 Subject: Re: RubyCocoa and Mac System Icons --0016364d2633303b840465033903 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Adam,Sorry it has taken me a while to reply; I have been away from my precious Mac for a couple of weeks (it's been tough! :)) When I ran the ruby code you suggested I got: *ServerListViewBrowserItem#imageRepresentation: ArgumentError: invalid value for Integer: "root"* * /Users/tom/dev/proj/bonjour-graphviz/gui-tools/mac/ZeroConfNetworkBrowser/build/Debug/ZeroConfNetworkBrowser.app/Contents/Resources/serverlistviewbrowseritem.rb:42:in `NSFileTypeForHFSTypeCode'* * /Users/tom/dev/proj/bonjour-graphviz/gui-tools/mac/ZeroConfNetworkBrowser/build/Debug/ZeroConfNetworkBrowser.app/Contents/Resources/serverlistviewbrowseritem.rb:42:in `imageRepresentation'* * /Users/tom/dev/proj/bonjour-graphviz/gui-tools/mac/ZeroConfNetworkBrowser/build/Debug/ZeroConfNetworkBrowser.app/Contents/Resources/rb_main.rb:26:in `NSApplicationMain'* It would appear that NSFileTypeForHFPTypeCode is expecting an integer value instead of 'root'. Any ideas? Many Thanks, Tom On Tue, Feb 24, 2009 at 1:00 AM, Adam Gardner wrote: > Tom Medhurst wrote: > > Hi Adam, > > Thanks for looking into this for me! > > kComputer is defined in the IconsCore.h header file in > > CoreServices.framework/LaunchServices.framework. (tried referencing it > > as > > KComputer, but that didn't work) > > > > I tried your example and it just returned the generic "unknown > > file-type" > > icon. :( > > > > I am trying to load the system icon for the computer... it's really easy > > in > > Ubuntu to load stock (system) icons, so I am really frustrated when I > > can't > > seem to figure this out on my lovely mac :'( > > > > Any ideas..? > > Thanks > > Tom > > On my machine, the constant is kComputerIcon, not kComputer, and yes, it > evaluates to Root. RubyCocoa isn't going to recognize the Ruby constant > KComptuerIcon or anything like it, though, because at least on my > machine all that stuff is pure C stuff (not Objective-C) which isn't > accounted for yet by custom bridge-support files. You can try fooling > around with bridge-support, but I'd just skip kComputerIcon entirely and > use what it evaluates to, the string 'root'. > > That out of the way, according this source: [1], the correct line in > Objective-C would be > SImage* macIcon = [[NSWorkspace sharedWorkspace] iconForFileType: > NSFileTypeForHFSTypeCode(kComputerIcon)]; > > To me, that translates as: > > OSX::NSWorkspace.sharedWorkspace.iconForFileType(OSX::NSFileTypeForHFSTypeCode('root')) > > so, try that out. > > > [1] http://zathras.de/angelweb/blog-get-standard-system-icons.htm > -- > Posted via http://www.ruby-forum.com/. > > --0016364d2633303b840465033903--