Revision: 4071
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4071&view=rev
Author:   hofman
Date:     2008-06-25 13:42:03 -0700 (Wed, 25 Jun 2008)

Log Message:
-----------
Add menu convenience method to remove double separators and use that in the 
windows menu. Use static set for selection action items to remove from the 
PDFView contextual menu.

Modified Paths:
--------------
    trunk/NSMenu_SKExtensions.h
    trunk/NSMenu_SKExtensions.m
    trunk/SKApplication.m
    trunk/SKPDFView.m

Modified: trunk/NSMenu_SKExtensions.h
===================================================================
--- trunk/NSMenu_SKExtensions.h 2008-06-25 18:59:18 UTC (rev 4070)
+++ trunk/NSMenu_SKExtensions.h 2008-06-25 20:42:03 UTC (rev 4071)
@@ -56,6 +56,7 @@
 - (NSMenuItem *)addItemWithTitle:(NSString *)aString submenu:(NSMenu 
*)aSubmenu;
 
 - (void)removeAllItems;
+- (void)removeDoubleSeparators;
 
 @end
 

Modified: trunk/NSMenu_SKExtensions.m
===================================================================
--- trunk/NSMenu_SKExtensions.m 2008-06-25 18:59:18 UTC (rev 4070)
+++ trunk/NSMenu_SKExtensions.m 2008-06-25 20:42:03 UTC (rev 4071)
@@ -97,6 +97,21 @@
         [self removeItemAtIndex:i];
 }
 
+- (void)removeDoubleSeparators {
+    int anIndex = [self numberOfItems];
+    BOOL wasSeparator = YES;
+    
+    while (anIndex--) {
+        if ([[self itemAtIndex:anIndex] isSeparatorItem]) {
+            if (wasSeparator)
+                [self removeItemAtIndex:anIndex];
+            wasSeparator = YES;
+        } else {
+            wasSeparator = NO;
+        }
+    }
+}
+
 @end
 
 

Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m       2008-06-25 18:59:18 UTC (rev 4070)
+++ trunk/SKApplication.m       2008-06-25 20:42:03 UTC (rev 4071)
@@ -41,6 +41,7 @@
 #import "SKPDFSynchronizer.h"
 #import "SKPDFView.h"
 #import "NSString_SKExtensions.h"
+#import "NSMenu_SKExtensions.h"
 
 NSString *SKApplicationStartsTerminatingNotification = 
@"SKApplicationStartsTerminatingNotification";
 
@@ -130,22 +131,6 @@
     return;
 }
 
-- (void)removeDoubleSpearatorsFromWindowMenu {
-    int anIndex = [[self windowsMenu] numberOfItems];
-    BOOL wasSeparator = YES;
-    
-    while (anIndex--) {
-        if ([[[self windowsMenu] itemAtIndex:anIndex] isSeparatorItem]) {
-            if (wasSeparator)
-                [[self windowsMenu] removeItemAtIndex:anIndex];
-            else
-                wasSeparator = YES;
-        } else {
-            wasSeparator = NO;
-        }
-    }
-}
-
 - (void)reorganizeWindowsItem:(NSWindow *)aWindow {
     NSMenu *windowsMenu = [self windowsMenu];
     NSWindowController *windowController = [aWindow windowController];
@@ -249,7 +234,7 @@
     }
     
     // shouldn't be necessary, but just be sure. There have been reports of 
extra separators being inserted after a "swipe" event
-    [self removeDoubleSpearatorsFromWindowMenu];
+    [[self windowsMenu] removeDoubleSeparators];
 }
 
 - (void)addWindowsItem:(NSWindow *)aWindow title:(NSString *)aString 
filename:(BOOL)isFilename {
@@ -270,7 +255,7 @@
 - (void)removeWindowsItem:(NSWindow *)aWindow {
     [super removeWindowsItem:aWindow];
     
-    [self removeDoubleSpearatorsFromWindowMenu];
+    [[self windowsMenu] removeDoubleSeparators];
 }
 
 #pragma mark Scripting support

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2008-06-25 18:59:18 UTC (rev 4070)
+++ trunk/SKPDFView.m   2008-06-25 20:42:03 UTC (rev 4071)
@@ -1258,11 +1258,13 @@
     
     // On Leopard the selection is automatically set. In some cases we never 
want a selection though.
     if ((interactionMode == SKPresentationMode) || (toolMode != SKTextToolMode 
&& [self currentSelection])) {
+        static NSSet *selectionActions = nil;
+        if (selectionActions == nil)
+            selectionActions = [[NSSet alloc] 
initWithObjects:@"_searchInSpotlight:", @"_searchInGoogle:", 
@"_searchInDictionary:", nil];
         [self setCurrentSelection:nil];
         while ([menu numberOfItems]) {
             item = [menu itemAtIndex:0];
-            NSString *action = NSStringFromSelector([item action]);
-            if ([item isSeparatorItem] || [action 
isEqualToString:@"_searchInSpotlight:"] ||  [action 
isEqualToString:@"_searchInGoogle:"] ||  [action 
isEqualToString:@"_searchInDictionary:"] || [self validateMenuItem:item] == NO)
+            if ([item isSeparatorItem] || [self validateMenuItem:item] == NO 
|| [selectionActions containsObject:NSStringFromSelector([item action])])
                 [menu removeItemAtIndex:0];
             else
                 break;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to