• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
desktop picture
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

desktop picture


  • Subject: desktop picture
  • From: email@hidden
  • Date: Wed, 22 May 2002 11:49:59 -0700

I *really* hate to ask this again...

but I've looked through the archives and found several different ways to do this, but none of them work any more.

How do you change the desktop picture dynamically from a Cocoa program?

I've found two references, one a program called ChangeDesktop, which is a stunning 7,610 lines of code, seems to use tons and tons of Carbon/AppleEvents code... which I could neither decipher, nor make work in my cocoa app.

The second was RandomBackground, which seems to work, but it only changes things at login.

I want to change the background picture and have it reflected immediately.

The code I have now properly updates com.apple.desktop's defaults... but it seems that the notification is ignored by finder.

Can anyone see what's wrong with my code?

I'm on 10.1.4 (5Q25)

- (void)setDesktopPicture:(id)path
{
id desktop = [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.desktop"] mutableCopy];
id background = [[desktop objectForKey:@"Background"] mutableCopy];
int i, n = [background count];
id displayIDs = [background allKeys];
for (i = 0; i < n; i++) {
id did = [displayIDs objectAtIndex:i];
id display = [[background objectForKey:did] mutableCopy];
[display setObject: path forKey:@"ImageFilePath"];
[display setObject:@"Crop" forKey:@"Placement"];
[background setObject:display forKey:did];
}
[desktop setObject:background forKey:@"Background"];

[[NSUserDefaults standardUserDefaults] setPersistentDomain:desktop forName:@"com.apple.desktop"];
[[NSUserDefaults standardUserDefaults] synchronize];
[[NSNotificationCenter defaultCenter] postNotificationName:@"com.apple.desktop" object:@"BackgroundChanged"];
}
_______________________________________________
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.
  • Follow-Ups:
    • Re: desktop picture
      • From: "Pierre d'Herbemont" <email@hidden>
    • Re: desktop picture
      • From: Finlay Dobbie <email@hidden>
  • Prev by Date: Re: Ints in NSDictionaries
  • Next by Date: casting an int to string
  • Previous by thread: Re: validateMenuItem: issues
  • Next by thread: Re: desktop picture
  • Index(es):
    • Date
    • Thread