Revision: 13970
          http://sourceforge.net/p/skim-app/code/13970
Author:   hofman
Date:     2023-12-24 09:52:21 +0000 (Sun, 24 Dec 2023)
Log Message:
-----------
Move convenience methods over from SKToolbarItem class to NSToolbarItem category

Modified Paths:
--------------
    trunk/SKBookmarkController.m
    trunk/SKDownloadController.m
    trunk/SKMainToolbarController.m
    trunk/SKMainWindowController.m
    trunk/SKNotesDocument.m
    trunk/SKToolbarItem.h
    trunk/SKToolbarItem.m
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/NSToolbarItem_SKExtensions.h
    trunk/NSToolbarItem_SKExtensions.m

Added: trunk/NSToolbarItem_SKExtensions.h
===================================================================
--- trunk/NSToolbarItem_SKExtensions.h                          (rev 0)
+++ trunk/NSToolbarItem_SKExtensions.h  2023-12-24 09:52:21 UTC (rev 13970)
@@ -0,0 +1,51 @@
+//
+//  NSToolbarItem_SKExtensions.h
+//  Skim
+//
+//  Created by Christiaan Hofman on 24/12/2023.
+/*
+ This software is Copyright (c) 2023
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NSToolbarItem (NSToolbarItem_SKExtensions)
+
+- (void)setLabels:(NSString *)label;
+- (void)setViewWithSizes:(NSView *)view;
+- (void)setImageNamed:(NSString *)name;
+
+@end
+
+NS_ASSUME_NONNULL_END

Added: trunk/NSToolbarItem_SKExtensions.m
===================================================================
--- trunk/NSToolbarItem_SKExtensions.m                          (rev 0)
+++ trunk/NSToolbarItem_SKExtensions.m  2023-12-24 09:52:21 UTC (rev 13970)
@@ -0,0 +1,59 @@
+//
+//  NSToolbarItem_SKExtensions.m
+//  Skim
+//
+//  Created by Christiaan Hofman on 24/12/2023.
+/*
+ This software is Copyright (c) 2023
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSToolbarItem_SKExtensions.h"
+
+@implementation NSToolbarItem (NSToolbarItem_SKExtensions)
+
+- (void)setLabels:(NSString *)label {
+    [self setLabel:label];
+    [self setPaletteLabel:label];
+}
+
+- (void)setViewWithSizes:(NSView *)view {
+    if ([view isKindOfClass:[NSSegmentedControl class]] || [view 
isKindOfClass:[NSStepper class]]) {
+        [(NSSegmentedControl *)view sizeToFit];
+    }
+    [self setView:view];
+}
+
+- (void)setImageNamed:(NSString *)name {
+    [self setImage:[NSImage imageNamed:name]];
+}
+
+@end

Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m        2023-12-23 22:52:50 UTC (rev 13969)
+++ trunk/SKBookmarkController.m        2023-12-24 09:52:21 UTC (rev 13970)
@@ -41,6 +41,7 @@
 #import "SKTypeSelectHelper.h"
 #import "SKStatusBar.h"
 #import "SKToolbarItem.h"
+#import "NSToolbarItem_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "NSMenu_SKExtensions.h"
 #import "NSURL_SKExtensions.h"
@@ -1117,7 +1118,7 @@
 - (void)setupToolbar {
     // Create a new toolbar instance, and attach it to our document window
     NSToolbar *toolbar = [[NSToolbar alloc] 
initWithIdentifier:SKBookmarksToolbarIdentifier];
-    SKToolbarItem *item;
+    NSToolbarItem *item;
     NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:3];
     
     // Set up toolbar properties: Allow customization, give a default display 
mode, and remember state in user defaults

Modified: trunk/SKDownloadController.m
===================================================================
--- trunk/SKDownloadController.m        2023-12-23 22:52:50 UTC (rev 13969)
+++ trunk/SKDownloadController.m        2023-12-24 09:52:21 UTC (rev 13970)
@@ -51,7 +51,6 @@
 #import "NSEvent_SKExtensions.h"
 #import "NSFileManager_SKExtensions.h"
 #import "NSView_SKExtensions.h"
-#import "SKToolbarItem.h"
 #import "NSImage_SKExtensions.h"
 
 #define SKDownloadsToolbarIdentifier                
@"SKDownloadsToolbarIdentifier"

Modified: trunk/SKMainToolbarController.m
===================================================================
--- trunk/SKMainToolbarController.m     2023-12-23 22:52:50 UTC (rev 13969)
+++ trunk/SKMainToolbarController.m     2023-12-24 09:52:21 UTC (rev 13970)
@@ -41,6 +41,7 @@
 #import "SKMainWindowController_Actions.h"
 #import "SKMainWindowController_FullScreen.h"
 #import "SKToolbarItem.h"
+#import "NSToolbarItem_SKExtensions.h"
 #import "NSSegmentedControl_SKExtensions.h"
 #import "SKStringConstants.h"
 #import "SKPDFView.h"
@@ -169,7 +170,7 @@
 }
 
 - (NSToolbarItem *)toolbarItemForItemIdentifier:(NSString *)identifier {
-    SKToolbarItem *item = (SKToolbarItem *)[toolbarItems 
objectForKey:identifier];
+    NSToolbarItem *item = [toolbarItems objectForKey:identifier];
     NSMenu *menu;
     NSMenuItem *menuItem;
     
@@ -737,11 +738,11 @@
             [pacerSpeedStepper setToolTip:NSLocalizedString(@"Pacer Speed", 
@"Tool tip message")];
             [item setMenuFormRepresentation:menuItem];
             
-            SKToolbarItem *item1 = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKDocumentToolbarPacerButtonItemIdentifier];
+            NSToolbarItem *item1 = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKDocumentToolbarPacerButtonItemIdentifier];
             [item1 setViewWithSizes:pacerButton];
-            SKToolbarItem *item2 = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKDocumentToolbarPacerSpeedFieldItemIdentifier];
+            NSToolbarItem *item2 = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKDocumentToolbarPacerSpeedFieldItemIdentifier];
             [item2 setViewWithSizes:pacerSpeedField];
-            SKToolbarItem *item3 = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKDocumentToolbarPacerSpeedStepperItemIdentifier];
+            NSToolbarItem *item3 = [[SKToolbarItem alloc] 
initWithItemIdentifier:SKDocumentToolbarPacerSpeedStepperItemIdentifier];
             [item3 setViewWithSizes:pacerSpeedStepper];
             [group setSubitems:@[item1, item2, item3]];
             

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2023-12-23 22:52:50 UTC (rev 13969)
+++ trunk/SKMainWindowController.m      2023-12-24 09:52:21 UTC (rev 13970)
@@ -67,7 +67,6 @@
 #import "NSWindowController_SKExtensions.h"
 #import "SKImageToolTipWindow.h"
 #import "PDFSelection_SKExtensions.h"
-#import "SKToolbarItem.h"
 #import "NSValue_SKExtensions.h"
 #import "NSString_SKExtensions.h"
 #import "SKReadingBar.h"

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2023-12-23 22:52:50 UTC (rev 13969)
+++ trunk/SKNotesDocument.m     2023-12-24 09:52:21 UTC (rev 13970)
@@ -58,6 +58,7 @@
 #import "NSView_SKExtensions.h"
 #import "NSFileManager_SKExtensions.h"
 #import "SKToolbarItem.h"
+#import "NSToolbarItem_SKExtensions.h"
 #import "SKPrintableView.h"
 #import "SKPDFView.h"
 #import "NSPointerArray_SKExtensions.h"
@@ -871,7 +872,7 @@
 - (void)setupToolbarForWindow:(NSWindow *)aWindow {
     // Create a new toolbar instance, and attach it to our document window
     NSToolbar *toolbar = [[NSToolbar alloc] 
initWithIdentifier:SKNotesDocumentToolbarIdentifier];
-    SKToolbarItem *item;
+    NSToolbarItem *item;
     NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:1];
     
     // Set up toolbar properties: Allow customization, give a default display 
mode, and remember state in user defaults

Modified: trunk/SKToolbarItem.h
===================================================================
--- trunk/SKToolbarItem.h       2023-12-23 22:52:50 UTC (rev 13969)
+++ trunk/SKToolbarItem.h       2023-12-24 09:52:21 UTC (rev 13970)
@@ -38,14 +38,6 @@
 
 #import <Cocoa/Cocoa.h>
 
-NS_ASSUME_NONNULL_BEGIN
 
 @interface SKToolbarItem : NSToolbarItem
-
-- (void)setLabels:(NSString *)label;
-- (void)setViewWithSizes:(NSView *)view;
-- (void)setImageNamed:(NSString *)name;
-
 @end
-
-NS_ASSUME_NONNULL_END

Modified: trunk/SKToolbarItem.m
===================================================================
--- trunk/SKToolbarItem.m       2023-12-23 22:52:50 UTC (rev 13969)
+++ trunk/SKToolbarItem.m       2023-12-24 09:52:21 UTC (rev 13970)
@@ -49,20 +49,4 @@
     [super validate];
 }
 
-- (void)setLabels:(NSString *)label {
-    [self setLabel:label];
-    [self setPaletteLabel:label];
-}
-
-- (void)setViewWithSizes:(NSView *)view {
-    if ([view isKindOfClass:[NSSegmentedControl class]] || [view 
isKindOfClass:[NSStepper class]]) {
-        [(NSSegmentedControl *)view sizeToFit];
-    }
-    [self setView:view];
-}
-
-- (void)setImageNamed:(NSString *)name {
-    [self setImage:[NSImage imageNamed:name]];
-}
-
 @end

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2023-12-23 22:52:50 UTC (rev 
13969)
+++ trunk/Skim.xcodeproj/project.pbxproj        2023-12-24 09:52:21 UTC (rev 
13970)
@@ -92,6 +92,7 @@
                CE20B1950C9F23CC007C72F9 /* NSView_SKExtensions.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE20B1930C9F23CC007C72F9 /* 
NSView_SKExtensions.m */; };
                CE21F736239944990078B257 /* SKColorMenuView.m in Sources */ = 
{isa = PBXBuildFile; fileRef = CE21F735239944990078B257 /* SKColorMenuView.m 
*/; };
                CE24875C112C9651006B4FA5 /* NSFont_SKExtensions.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CE24875B112C9651006B4FA5 /* 
NSFont_SKExtensions.m */; };
+               CE2526362B3834E40084F43D /* NSToolbarItem_SKExtensions.m in 
Sources */ = {isa = PBXBuildFile; fileRef = CE2526352B3834E40084F43D /* 
NSToolbarItem_SKExtensions.m */; };
                CE25BB6B163FFB770046A348 /* Skim.help in Resources */ = {isa = 
PBXBuildFile; fileRef = CE25BB43163FFB770046A348 /* Skim.help */; };
                CE26175F16CCFC4900BDCE7C /* SKSyncDot.m in Sources */ = {isa = 
PBXBuildFile; fileRef = CE26175E16CCFC4900BDCE7C /* SKSyncDot.m */; };
                CE2DE4920B85D48F00D0DA12 /* SKThumbnail.m in Sources */ = {isa 
= PBXBuildFile; fileRef = CE2DE4910B85D48F00D0DA12 /* SKThumbnail.m */; };
@@ -866,6 +867,8 @@
                CE21F735239944990078B257 /* SKColorMenuView.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
SKColorMenuView.m; sourceTree = "<group>"; };
                CE24875A112C9651006B4FA5 /* NSFont_SKExtensions.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
NSFont_SKExtensions.h; sourceTree = "<group>"; };
                CE24875B112C9651006B4FA5 /* NSFont_SKExtensions.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= NSFont_SKExtensions.m; sourceTree = "<group>"; };
+               CE2526342B3834E40084F43D /* NSToolbarItem_SKExtensions.h */ = 
{isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = 
NSToolbarItem_SKExtensions.h; sourceTree = "<group>"; };
+               CE2526352B3834E40084F43D /* NSToolbarItem_SKExtensions.m */ = 
{isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
NSToolbarItem_SKExtensions.m; sourceTree = "<group>"; };
                CE25BB43163FFB770046A348 /* Skim.help */ = {isa = 
PBXFileReference; lastKnownFileType = folder; path = Skim.help; sourceTree = 
"<group>"; };
                CE26175D16CCFC4900BDCE7C /* SKSyncDot.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKSyncDot.h; sourceTree = "<group>"; };
                CE26175E16CCFC4900BDCE7C /* SKSyncDot.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKSyncDot.m; sourceTree = "<group>"; };
@@ -2165,6 +2168,8 @@
                                CEE54F6F0DA3FBE00037169F /* 
NSSegmentedControl_SKExtensions.m */,
                                CE5234A41A6424F200710CF2 /* 
NSShadow_SKExtensions.h */,
                                CE5234A51A6424F200710CF2 /* 
NSShadow_SKExtensions.m */,
+                               CE2526342B3834E40084F43D /* 
NSToolbarItem_SKExtensions.h */,
+                               CE2526352B3834E40084F43D /* 
NSToolbarItem_SKExtensions.m */,
                                CEF7119F0B90B714003A2771 /* 
NSUserDefaultsController_SKExtensions.h */,
                                CEF711A00B90B714003A2771 /* 
NSUserDefaultsController_SKExtensions.m */,
                                CE20B1920C9F23CC007C72F9 /* 
NSView_SKExtensions.h */,
@@ -2803,6 +2808,7 @@
                                CE3A45530B7A04A4006B64D3 /* 
NSBezierPath_SKExtensions.m in Sources */,
                                CEBCA4C02868A93A00E6376E /* SKLine.m in Sources 
*/,
                                CE4EBDDA0B7BF3B30091F228 /* SKSideWindow.m in 
Sources */,
+                               CE2526362B3834E40084F43D /* 
NSToolbarItem_SKExtensions.m in Sources */,
                                CE4EC88C0B7E6EDB0091F228 /* SKSplitView.m in 
Sources */,
                                CE38ECD30B8093B200A1B779 /* 
NSString_SKExtensions.m in Sources */,
                                F9CDD67B0B837A7F006363C3 /* 
SKPreferenceController.m in Sources */,

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to