[Clickdrag-cvs] ClickDrag ClickDrag.m,1.5,1.6
Status: Pre-Alpha
Brought to you by:
stevecheckoway
|
From: Steve C. <ste...@us...> - 2005-10-31 03:20:28
|
Update of /cvsroot/clickdrag/ClickDrag In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32298 Modified Files: ClickDrag.m Log Message: If Preferences does not exist, put it above the separator. Index: ClickDrag.m =================================================================== RCS file: /cvsroot/clickdrag/ClickDrag/ClickDrag.m,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -p -r1.5 -r1.6 --- ClickDrag.m 31 Aug 2004 10:45:27 -0000 1.5 +++ ClickDrag.m 31 Oct 2005 03:20:21 -0000 1.6 @@ -265,21 +265,29 @@ { NSMenu *menu = [[[NSApp mainMenu] itemAtIndex:0] submenu]; NSArray *items = [menu itemArray]; - id<NSMenuItem> item; - int index; + NSMenuItem *item; + unsigned int index = 0; - for (index = 0; index < [items count]; ++index) + if ([items count]) { - NSString *title = [(NSMenuItem *)[items objectAtIndex:index] title]; - - if ([title hasPrefix:@"Preferences"]) - break; + for (index = 0; index < [items count]; ++index) + { + NSString *title = [(NSMenuItem *)[items objectAtIndex:index] title]; + + if ([title hasPrefix:@"Preferences"]) + break; + } + + if (index == [items count]) + { + --index; // before Quit + if ([items count] > 1 && [[menu itemAtIndex:index-1] isSeparatorItem]) + --index; // before the separator + } + else + ++index; // after Preferences } - if (index == [items count]) - --index; // before Quit - else - ++index; // after Preferences item = [menu insertItemWithTitle:(mEnabled ? @"Disable ClickDrag" : @"Enable ClickDrag") action:@selector(changeCDState:) @@ -298,7 +306,7 @@ ClickDrag *gClickDrag; /* - * Copyright (c) 2004 Steve Checkoway + * Copyright (c) 2004-2005 Steve Checkoway * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the |