Notification for printer getting added
Notification for printer getting added
- Subject: Notification for printer getting added
- From: Trever Wilhelm <email@hidden>
- Date: Wed, 31 Mar 2004 15:35:39 -0800
Hello,
I am trying to write a small app that has a button which launches the Print
Center, and another button that gets enabled or disabled depending on
whether a specific type of printer is in the Print Center.
I have a notification subscription to the NSDistributedNotificationCenter
that disables my button when this specific printer is removed from the Print
Center:
[[NSDistributedNotificationCenter defaultCenter]
addObserver:self selector:@selector(updatePrintTestButton:)
name:(NSString *)kCMDeviceUnregisteredNotification
object:nil];
This works perfectly. I see the notification get triggered when a printer
is removed from the print center, and my app disables the button as I want
it to.
I thought I could subscribe to the CMDeviceRegisteredNotification to see
when a new printer is added, then check the [NSPrinters printerTypes] array
to test for the printer I want and then enable my button. I get the
notification, but it seems to trigger before the printer actually shows up
in the [NSPrinters printerTypes] array. Because the notification seems to
be sent before the printer is added to the array of available printers, my
app button does not get properly enabled. I tried to look at what other
notifications get posted to the Distributed Notification Center and the only
one that seems to work for my needs is subscribing to
3com.apple.print.userDefaultPrinterChanged2 notification.
This seems to work because every time I add a printer to my computer via
Print Center on 10.3.3, it makes that printer the default printer.
Does anyone know if all OS X from 10.1.5 up to Panther send this
notification every time a printer is manually added to the computer via
Print Center / Printer Setup Utility? Or is there a better way to get
triggered when a printer is added to the computer via the Print Center?
Thanks for any suggestions.
--
Trever Wilhelm
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.