Re: Getting Display Names

2009-04-29 Thread Cédric Luthi
 Perfect! Thank you. Is this documented anywhere? Not even IORegistryExplorer
 appears to display this dictionary.

There is no technote documenting the procedure, but both
IODisplayCreateInfoDictionary and CGDisplayIOServicePort are in public
headers, so it is safe to use.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Getting Display Names

2009-04-28 Thread Cédric Luthi
 Are these names only accessible from private frameworks or is there an
 AppKit or CoreGraphics API I have yet to stumble across that maps the
 display unit number or display ID to a localized (or not) display name?

The answer is in I/O Kit:


#import IOKit/graphics/IOGraphicsLib.h

#import IOKit/graphics/IOGraphicsTypes.h

NSString* screenNameForDisplayID(CGDirectDisplayID displayID)

{

NSDictionary *deviceFullDescription = (NSDictionary *)
IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kNilOptions
);

if (deviceFullDescription == nil) {

return nil;

}



NSDictionary *localizedNames = [deviceFullDescription objectForKey
:@kDisplayProductName];

if ([localizedNames count]  1) {

return nil;

}



NSString *languageKey = nil;

for (NSString *preferredLanguage in [NSLocale preferredLanguages]) {

for (NSString *localeIdentifier in [localizedNames allKeys]) {

if ([[[NSLocale componentsFromLocaleIdentifier
:preferredLanguage] objectForKey:NSLocaleLanguageCode] isEqualToString:[[
NSLocale componentsFromLocaleIdentifier:localeIdentifier] objectForKey:
NSLocaleLanguageCode]]) {

languageKey = localeIdentifier;

goto exit;

}

}

}

exit:



return [localizedNames objectForKey:languageKey ? languageKey :
[[localizedNames allKeys] objectAtIndex:0]];

}
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Getting Display Names

2009-04-27 Thread Grant Erickson
I have established for system displays the ability to retrieve numerical IDs
(unit number, vendor number, display ID, etc.) for the main and auxiliary
displays attached to the system; however, I cannot seem to find an ability
to get the localized name associated with the display (Cinema, Cinema
Display, Color LCD, etc.).

Are these names only accessible from private frameworks or is there an
AppKit or CoreGraphics API I have yet to stumble across that maps the
display unit number or display ID to a localized (or not) display name?

Thanks,

Grant


smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com