Re: Recently Opened in Doc

2012-02-04 Thread Brad Stone
Thanks everyone.  In the end, since this is a shoebox app like iPhoto where the 
user doesn't access their data via File->Open and the file name doesn't 
necessarily make sense to the user I suppressed the Open Recently menu (the 
user has a History menu like Safari for that purpose).  For the dock menu I 
made my own which allowed me to give the user menu item titles that would mean 
something to them.  I did it two parts.  First I did this to suppress the 
default functionality:

- (NSUInteger)maximumRecentDocumentCount {
return 0;
}

and then I provide my own using - (NSMenu *)applicationDockMenu:(NSApplication 
*)sender.  I'm not doing a lot of calculations here so it comes up quickly for 
the user.

On Jan 28, 2012, at 5:58 PM, James Merkel wrote:

> On 28 Jan 2012 08:46:48 -0800 Quincey Morris wrote:
> 
>> On Jan 28, 2012, at 08:19 , Brad Stone wrote:
>> 
>>> I have a shoebox app like iPhoto where the actual filename is irrelevant to 
>>> the user.   I control the file name.  
>>> 
>>> What I'd like to do is just capture the menu items before they're displayed 
>>> and change the menu titles into something relevant to the user.  In the 
>>> scheme of things it's a minor way to access the info in my app so if I 
>>> could eliminate them that would be OK too.  Changing the filename is not an 
>>> option at this point.
>> 
>> It seems to me you can subclass NSDocumentController, then override 
>> 'noteNewRecentDocument:' to do nothing. Presumably this will keep your 
>> filename off the "Open Recent" submenu, the "Recent Items" item on the Apple 
>> menu, and the dock menu. Then you should be able to delete the "Open Recent" 
>> item itself, and be left with no traces of recent items from your app.
>> 
>> If you wanted to go the extra mile, you could create your own recent-items 
>> implementation, driven from your 'noteNewRecentDocument:' override, and 
>> using the 'applicationDockMenu:' application delegate method, with whatever 
>> document identifiers you want.
> 
> 
> My app is not document based so I call noteNewRecentDocumentURL: directly to 
> add the filename to the Open Recent submenu list.
> If I comment that line of code out then the document is not added to the list 
> as expected. Also, the Dock menu "Show Recents" shows nothing and the 
> filename is not added to  the Dock menu list. 
> 
> So yes, noteNewRecentDocument; (which calls noteNewRecentDocumentURL: ) is 
> the key to the whole thing.
> 
> Jim Merkel

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Recently Opened in Doc

2012-01-28 Thread James Merkel
On 28 Jan 2012 08:46:48 -0800 Quincey Morris wrote:

> On Jan 28, 2012, at 08:19 , Brad Stone wrote:
> 
>> I have a shoebox app like iPhoto where the actual filename is irrelevant to 
>> the user.   I control the file name.  
>> 
>> What I'd like to do is just capture the menu items before they're displayed 
>> and change the menu titles into something relevant to the user.  In the 
>> scheme of things it's a minor way to access the info in my app so if I could 
>> eliminate them that would be OK too.  Changing the filename is not an option 
>> at this point.
> 
> It seems to me you can subclass NSDocumentController, then override 
> 'noteNewRecentDocument:' to do nothing. Presumably this will keep your 
> filename off the "Open Recent" submenu, the "Recent Items" item on the Apple 
> menu, and the dock menu. Then you should be able to delete the "Open Recent" 
> item itself, and be left with no traces of recent items from your app.
> 
> If you wanted to go the extra mile, you could create your own recent-items 
> implementation, driven from your 'noteNewRecentDocument:' override, and using 
> the 'applicationDockMenu:' application delegate method, with whatever 
> document identifiers you want.


My app is not document based so I call noteNewRecentDocumentURL: directly to 
add the filename to the Open Recent submenu list.
If I comment that line of code out then the document is not added to the list 
as expected. Also, the Dock menu "Show Recents" shows nothing and the filename 
is not added to  the Dock menu list. 

So yes, noteNewRecentDocument; (which calls noteNewRecentDocumentURL: ) is the 
key to the whole thing.

Jim Merkel
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Recently Opened in Doc

2012-01-28 Thread Quincey Morris
On Jan 28, 2012, at 11:57 , Brad Stone wrote:

> Thanks Quincey, I've already subclassed my NSDocumentController and I use 
> noteNewRecentDocument to prevent my index file from showing up in the list.   
> The code never gets past the continue call because every time this method is 
> called the only menu item  in [openRecentMenu itemArray] is "Clear Menu" 
> (except when I quit out).
> 
> - (void)noteNewRecentDocument:(NSDocument *)aDocument {
> if ([aDocument isKindOfClass:[PNDocument class]]) {
> [super noteNewRecentDocument:aDocument];
> }
> 
> NSMenu *fileMenu = [[[NSApp mainMenu] itemWithTitle:@"File"] submenu];
> if (!fileMenu) {
> return;
> }
> NSMenu *openRecentMenu = [[fileMenu itemWithTitle:@"Open Recent"] 
> submenu];
> if (!openRecentMenu) {
> return;
> }
>  
> for (NSMenuItem *openRecentMenuItem in [openRecentMenu itemArray]) {
> NSString *title = [openRecentMenuItem title];
> if ([title isEqualToString:@"Clear Menu"]) {
> continue;
> }
>// code to change the menuItem title
> 
> }
> }

There's a couple of things I don't understand here.

If your document is a PNDocument, then you never add it to the menu via the 
super call, so of course there's no item there to have its name changed.

OTOH, unless your app has multiple doc classes AND the others use regular file 
names AND you're trying to mix regular file names and your special names on the 
same menu, then why are you bothering to leverage the document controller 
mechanism? Just opt out, and create your own Recent Items mechanism to use 
instead.

The problem with trying to integrate into any of document controller's standard 
behavior is that you might end up "fixing" the menu, but that won't solve 
anything for the dock menu, which was your original question.

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Recently Opened in Doc

2012-01-28 Thread Brad Stone
Thanks Quincey, I've already subclassed my NSDocumentController and I use 
noteNewRecentDocument to prevent my index file from showing up in the list.   
The code never gets past the continue call because every time this method is 
called the only menu item  in [openRecentMenu itemArray] is "Clear Menu" 
(except when I quit out).

- (void)noteNewRecentDocument:(NSDocument *)aDocument {
if ([aDocument isKindOfClass:[PNDocument class]]) {
[super noteNewRecentDocument:aDocument];
}

NSMenu *fileMenu = [[[NSApp mainMenu] itemWithTitle:@"File"] submenu];
if (!fileMenu) {
return;
}
NSMenu *openRecentMenu = [[fileMenu itemWithTitle:@"Open Recent"] submenu];
if (!openRecentMenu) {
return;
}
 
for (NSMenuItem *openRecentMenuItem in [openRecentMenu itemArray]) {
NSString *title = [openRecentMenuItem title];
if ([title isEqualToString:@"Clear Menu"]) {
continue;
}
   // code to change the menuItem title

}
}





On Jan 28, 2012, at 11:46 AM, Quincey Morris wrote:

> On Jan 28, 2012, at 08:19 , Brad Stone wrote:
> 
>> I have a shoebox app like iPhoto where the actual filename is irrelevant to 
>> the user.   I control the file name.  
>> 
>> What I'd like to do is just capture the menu items before they're displayed 
>> and change the menu titles into something relevant to the user.  In the 
>> scheme of things it's a minor way to access the info in my app so if I could 
>> eliminate them that would be OK too.  Changing the filename is not an option 
>> at this point.
> 
> It seems to me you can subclass NSDocumentController, then override 
> 'noteNewRecentDocument:' to do nothing. Presumably this will keep your 
> filename off the "Open Recent" submenu, the "Recent Items" item on the Apple 
> menu, and the dock menu. Then you should be able to delete the "Open Recent" 
> item itself, and be left with no traces of recent items from your app.
> 
> If you wanted to go the extra mile, you could create your own recent-items 
> implementation, driven from your 'noteNewRecentDocument:' override, and using 
> the 'applicationDockMenu:' application delegate method, with whatever 
> document identifiers you want.
> 
> 

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Recently Opened in Doc

2012-01-28 Thread Quincey Morris
On Jan 28, 2012, at 08:19 , Brad Stone wrote:

> I have a shoebox app like iPhoto where the actual filename is irrelevant to 
> the user.   I control the file name.  
> 
> What I'd like to do is just capture the menu items before they're displayed 
> and change the menu titles into something relevant to the user.  In the 
> scheme of things it's a minor way to access the info in my app so if I could 
> eliminate them that would be OK too.  Changing the filename is not an option 
> at this point.

It seems to me you can subclass NSDocumentController, then override 
'noteNewRecentDocument:' to do nothing. Presumably this will keep your filename 
off the "Open Recent" submenu, the "Recent Items" item on the Apple menu, and 
the dock menu. Then you should be able to delete the "Open Recent" item itself, 
and be left with no traces of recent items from your app.

If you wanted to go the extra mile, you could create your own recent-items 
implementation, driven from your 'noteNewRecentDocument:' override, and using 
the 'applicationDockMenu:' application delegate method, with whatever document 
identifiers you want.


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Recently Opened in Doc

2012-01-28 Thread Brad Stone
I have a shoebox app like iPhoto where the actual filename is irrelevant to the 
user.   I control the file name.  

What I'd like to do is just capture the menu items before they're displayed and 
change the menu titles into something relevant to the user.  In the scheme of 
things it's a minor way to access the info in my app so if I could eliminate 
them that would be OK too.  Changing the filename is not an option at this 
point.


On Jan 27, 2012, at 11:19 PM, James Merkel wrote:

> On 27 Jan 2012 10:20:37 Brad Stone wrote:
>> I'd like to 
>> 1) change the menu titles of the recently opened documents listed in the 
>> dock menu
>> 
>> if I can't do that I'd like to 
>> 
>> 2) remove the list of recently opened documents all together.
>> 
>> I haven't been able to find a way to do this.  Can someone provide guidance?
>> 
>> Thanks
> 
> I don't  have an answer to your question -- but something I didn't notice 
> before.
> If you rename a file, the new filename appears in the recently opened files 
> menu (replacing the old filename).
> However the old filename stays in the doc menu.
> Seems like that's a bug.
> 
> Jim Merkel


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Recently Opened in Doc

2012-01-27 Thread James Merkel
On 27 Jan 2012 10:20:37 Brad Stone wrote:
> I'd like to 
> 1) change the menu titles of the recently opened documents listed in the dock 
> menu
> 
> if I can't do that I'd like to 
> 
> 2) remove the list of recently opened documents all together.
> 
> I haven't been able to find a way to do this.  Can someone provide guidance?
> 
> Thanks

I don't  have an answer to your question -- but something I didn't notice 
before.
If you rename a file, the new filename appears in the recently opened files 
menu (replacing the old filename).
However the old filename stays in the doc menu.
Seems like that's a bug.

Jim Merkel
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Recently Opened in Doc

2012-01-27 Thread Brad Stone
I'd like to 
1) change the menu titles of the recently opened documents listed in the dock 
menu

if I can't do that I'd like to 

2) remove the list of recently opened documents all together.
 
I haven't been able to find a way to do this.  Can someone provide guidance?

Thanks
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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