commit 4317b2c3dc3b5e33d4db89a90d03405f3ac06586 Author: R. Tyler Ballance Date: Sun Oct 29 14:39:14 2006 +0000 Import the trunk into the actual bloody trunk/ git-svn-id: svn://svn.geekisp.com/bleep/trunk/XmlToolbar@2 a256dd88-e320-0410-9161-d397f098afaa diff --git a/English.lproj/InfoPlist.strings b/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..d34bd9e Binary files /dev/null and b/English.lproj/InfoPlist.strings differ diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 0000000..94c7529 --- /dev/null +++ b/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,12 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + CLASS = MainController; + LANGUAGE = ObjC; + OUTLETS = {mainWindow = NSWindow; }; + SUPERCLASS = NSObject; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 0000000..602aeb7 --- /dev/null +++ b/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,21 @@ + + + + + IBDocumentLocation + 68 68 356 240 0 0 1024 746 + IBEditorPositions + + 29 + 256 399 338 44 0 0 1024 746 + + IBFramework Version + 446.1 + IBOpenObjects + + 21 + + IBSystem Version + 8L2127 + + diff --git a/English.lproj/MainMenu.nib/keyedobjects.nib b/English.lproj/MainMenu.nib/keyedobjects.nib new file mode 100644 index 0000000..faf3b8a Binary files /dev/null and b/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/English.lproj/Toolbar.xml b/English.lproj/Toolbar.xml new file mode 100644 index 0000000..316cd67 --- /dev/null +++ b/English.lproj/Toolbar.xml @@ -0,0 +1,32 @@ + + + + XmlToolbar + NSToolbarSizeModeSmall + NSToolbarDisplayModeIconOnly + + + + + + + Edit + Edit Something + NotePad.tiff + Edit + + + + Calendar + Open up iCal + Calendar.tiff + Open Calendar + + + + Email + Send an email + Envelope.tiff + Send Email + + \ No newline at end of file diff --git a/Info.plist b/Info.plist new file mode 100644 index 0000000..b10d705 --- /dev/null +++ b/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + com.bleepsoft.XmlToolbar + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/XmlToolbar.xcodeproj/project.pbxproj b/XmlToolbar.xcodeproj/project.pbxproj new file mode 100644 index 0000000..328a2ae --- /dev/null +++ b/XmlToolbar.xcodeproj/project.pbxproj @@ -0,0 +1,328 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 2F101ECF0AEC486C003431C3 /* NotePad.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 2F101ECE0AEC486C003431C3 /* NotePad.tiff */; }; + 2F5B37950AEB4D58006BC5A0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F5B37940AEB4D58006BC5A0 /* main.m */; }; + 2F5B37A10AEB4E2E006BC5A0 /* MainController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F5B37A00AEB4E2E006BC5A0 /* MainController.m */; }; + 2F5B37A70AEB4E6C006BC5A0 /* XmlToolbarItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F5B37A60AEB4E6C006BC5A0 /* XmlToolbarItem.m */; }; + 2F83DAFD0AEB499700097BF7 /* Toolbar.xml in Resources */ = {isa = PBXBuildFile; fileRef = 2F83DAFB0AEB499700097BF7 /* Toolbar.xml */; }; + 2F87DABD0AF0FCC500F65471 /* XmlToolbar.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F87DABC0AF0FCC500F65471 /* XmlToolbar.m */; }; + 2FBC91E80AEB5E0700034674 /* Calendar.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 2FBC91E60AEB5E0700034674 /* Calendar.tiff */; }; + 2FBC91E90AEB5E0700034674 /* Envelope.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 2FBC91E70AEB5E0700034674 /* Envelope.tiff */; }; + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; + 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; }; + 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; + 2F101ECE0AEC486C003431C3 /* NotePad.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = NotePad.tiff; path = resources/NotePad.tiff; sourceTree = ""; }; + 2F5B37940AEB4D58006BC5A0 /* main.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = main.m; path = source/main.m; sourceTree = ""; }; + 2F5B379F0AEB4E2E006BC5A0 /* MainController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MainController.h; path = source/MainController.h; sourceTree = ""; }; + 2F5B37A00AEB4E2E006BC5A0 /* MainController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MainController.m; path = source/MainController.m; sourceTree = ""; }; + 2F5B37A50AEB4E6C006BC5A0 /* XmlToolbarItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XmlToolbarItem.h; path = source/XmlToolbarItem.h; sourceTree = ""; }; + 2F5B37A60AEB4E6C006BC5A0 /* XmlToolbarItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XmlToolbarItem.m; path = source/XmlToolbarItem.m; sourceTree = ""; }; + 2F83DAFC0AEB499700097BF7 /* English */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; name = English; path = English.lproj/Toolbar.xml; sourceTree = ""; }; + 2F87DABC0AF0FCC500F65471 /* XmlToolbar.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = XmlToolbar.m; path = source/XmlToolbar.m; sourceTree = ""; }; + 2FBC91E60AEB5E0700034674 /* Calendar.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Calendar.tiff; path = resources/Calendar.tiff; sourceTree = ""; }; + 2FBC91E70AEB5E0700034674 /* Envelope.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Envelope.tiff; path = resources/Envelope.tiff; sourceTree = ""; }; + 2FBC91FE0AEB606000034674 /* XmlToolbar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XmlToolbar.h; path = source/XmlToolbar.h; sourceTree = ""; }; + 32CA4F630368D1EE00C91783 /* XmlToolbar_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XmlToolbar_Prefix.pch; sourceTree = ""; }; + 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + 8D1107320486CEB800E47090 /* XmlToolbar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XmlToolbar.app; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D11072E0486CEB800E47090 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 080E96DDFE201D6D7F000001 /* Classes */ = { + isa = PBXGroup; + children = ( + 2F5B37A40AEB4E43006BC5A0 /* Toolbar Specific */, + 2F5B379F0AEB4E2E006BC5A0 /* MainController.h */, + 2F5B37A00AEB4E2E006BC5A0 /* MainController.m */, + ); + name = Classes; + sourceTree = ""; + }; + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, + ); + name = "Linked Frameworks"; + sourceTree = ""; + }; + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { + isa = PBXGroup; + children = ( + 29B97324FDCFA39411CA2CEA /* AppKit.framework */, + 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, + 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + ); + name = "Other Frameworks"; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D1107320486CEB800E47090 /* XmlToolbar.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* XmlToolbar */ = { + isa = PBXGroup; + children = ( + 080E96DDFE201D6D7F000001 /* Classes */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97317FDCFA39411CA2CEA /* Resources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = XmlToolbar; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + 2F5B37940AEB4D58006BC5A0 /* main.m */, + 32CA4F630368D1EE00C91783 /* XmlToolbar_Prefix.pch */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA /* Resources */ = { + isa = PBXGroup; + children = ( + 2F83DAFB0AEB499700097BF7 /* Toolbar.xml */, + 2F83DAF40AEB487700097BF7 /* Toolbar Icons */, + 8D1107310486CEB800E47090 /* Info.plist */, + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, + ); + name = Resources; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, + 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, + ); + name = Frameworks; + sourceTree = ""; + }; + 2F5B37A40AEB4E43006BC5A0 /* Toolbar Specific */ = { + isa = PBXGroup; + children = ( + 2FBC91FE0AEB606000034674 /* XmlToolbar.h */, + 2F87DABC0AF0FCC500F65471 /* XmlToolbar.m */, + 2F5B37A50AEB4E6C006BC5A0 /* XmlToolbarItem.h */, + 2F5B37A60AEB4E6C006BC5A0 /* XmlToolbarItem.m */, + ); + name = "Toolbar Specific"; + sourceTree = ""; + }; + 2F83DAF40AEB487700097BF7 /* Toolbar Icons */ = { + isa = PBXGroup; + children = ( + 2F101ECE0AEC486C003431C3 /* NotePad.tiff */, + 2FBC91E60AEB5E0700034674 /* Calendar.tiff */, + 2FBC91E70AEB5E0700034674 /* Envelope.tiff */, + ); + name = "Toolbar Icons"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 8D1107260486CEB800E47090 /* XmlToolbar */ = { + isa = PBXNativeTarget; + buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "XmlToolbar" */; + buildPhases = ( + 8D1107290486CEB800E47090 /* Resources */, + 8D11072C0486CEB800E47090 /* Sources */, + 8D11072E0486CEB800E47090 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = XmlToolbar; + productInstallPath = "$(HOME)/Applications"; + productName = XmlToolbar; + productReference = 8D1107320486CEB800E47090 /* XmlToolbar.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XmlToolbar" */; + hasScannedForEncodings = 1; + mainGroup = 29B97314FDCFA39411CA2CEA /* XmlToolbar */; + projectDirPath = ""; + targets = ( + 8D1107260486CEB800E47090 /* XmlToolbar */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D1107290486CEB800E47090 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, + 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, + 2F83DAFD0AEB499700097BF7 /* Toolbar.xml in Resources */, + 2FBC91E80AEB5E0700034674 /* Calendar.tiff in Resources */, + 2FBC91E90AEB5E0700034674 /* Envelope.tiff in Resources */, + 2F101ECF0AEC486C003431C3 /* NotePad.tiff in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D11072C0486CEB800E47090 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 2F5B37950AEB4D58006BC5A0 /* main.m in Sources */, + 2F5B37A10AEB4E2E006BC5A0 /* MainController.m in Sources */, + 2F5B37A70AEB4E6C006BC5A0 /* XmlToolbarItem.m in Sources */, + 2F87DABD0AF0FCC500F65471 /* XmlToolbar.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C165DFE840E0CC02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; + 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = { + isa = PBXVariantGroup; + children = ( + 29B97319FDCFA39411CA2CEA /* English */, + ); + name = MainMenu.nib; + sourceTree = ""; + }; + 2F83DAFB0AEB499700097BF7 /* Toolbar.xml */ = { + isa = PBXVariantGroup; + children = ( + 2F83DAFC0AEB499700097BF7 /* English */, + ); + name = Toolbar.xml; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C01FCF4B08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = XmlToolbar; + WRAPPER_EXTENSION = app; + ZERO_LINK = YES; + }; + name = Debug; + }; + C01FCF4C08A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_MODEL_TUNING = G5; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = "$(HOME)/Applications"; + PRODUCT_NAME = XmlToolbar; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "XmlToolbar" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4B08A954540054247B /* Debug */, + C01FCF4C08A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "XmlToolbar" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/XmlToolbar_Prefix.pch b/XmlToolbar_Prefix.pch new file mode 100644 index 0000000..fc674a0 --- /dev/null +++ b/XmlToolbar_Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'XmlToolbar' target in the 'XmlToolbar' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/resources/Calendar.tiff b/resources/Calendar.tiff new file mode 100644 index 0000000..a4a4467 Binary files /dev/null and b/resources/Calendar.tiff differ diff --git a/resources/Envelope.tiff b/resources/Envelope.tiff new file mode 100644 index 0000000..6324718 Binary files /dev/null and b/resources/Envelope.tiff differ diff --git a/resources/NotePad.tiff b/resources/NotePad.tiff new file mode 100644 index 0000000..fc0f21d Binary files /dev/null and b/resources/NotePad.tiff differ diff --git a/source/MainController.h b/source/MainController.h new file mode 100644 index 0000000..ea3de37 --- /dev/null +++ b/source/MainController.h @@ -0,0 +1,19 @@ +// +// MainController.h +// XmlToolbar +// +// Created by R. Tyler Ballance on 10/22/06. +// Copyright 2006 bleep. LLC. All rights reserved. +// + +#import + +#import "XmlToolbar.h" + +@interface MainController : NSObject { + IBOutlet NSWindow *mainWindow; + + XmlToolbar *toolbarLoader; +} + +@end diff --git a/source/MainController.m b/source/MainController.m new file mode 100644 index 0000000..89fb72a --- /dev/null +++ b/source/MainController.m @@ -0,0 +1,20 @@ +// +// MainController.m +// XmlToolbar +// +// Created by R. Tyler Ballance on 10/22/06. +// Copyright 2006 bleep. LLC. All rights reserved. +// + +#import "MainController.h" + + +@implementation MainController + +- (void)awakeFromNib +{ + NSString *xmlFile = [[NSBundle mainBundle] pathForResource:@"Toolbar" ofType:@"xml"]; + toolbarLoader = [[XmlToolbar alloc] initializeForWindow:mainWindow withXml:xmlFile]; +} + +@end diff --git a/source/XmlToolbar.h b/source/XmlToolbar.h new file mode 100644 index 0000000..ebab5a6 --- /dev/null +++ b/source/XmlToolbar.h @@ -0,0 +1,34 @@ +// +// ToolbarLoader.h +// XmlToolbar +// +// Created by R. Tyler Ballance on 10/22/06. +// Copyright 2006 bleep. LLC. All rights reserved. +// + +#import + +#import "XmlToolbarItem.h" + +@interface XmlToolbar : NSObject { + NSWindow *window; + NSToolbar *toolbar; + + NSMutableDictionary *toolbarItems; + NSMutableArray *toolbarOrderedIdentifiers; +} + +- (id)initializeForWindow:(NSWindow *)window withXml:(NSString *)pathToXmlFile; + +/* Toolbar related methods */ +- (void)toolbarItemClicked:(XmlToolbarItem *)item; + +- (void)setToolbarDelegate:(id)delegate; +- (void)setToolbarDisplayMode:(NSToolbarDisplayMode)displayMode; +- (void)setToolbarSizeMode:(NSToolbarSizeMode)sizeMode; +- (void)setToolbarAllowsUserCustomization:(BOOL)allowsCustomization; +- (void)setToolbarAutosavesConfiguration:(BOOL)flag; +- (void)setToolbarShowsBaselineSeparator:(BOOL)flag; +- (void)setToolbarVisible:(BOOL)shown; + +@end diff --git a/source/XmlToolbar.m b/source/XmlToolbar.m new file mode 100644 index 0000000..2848ad8 --- /dev/null +++ b/source/XmlToolbar.m @@ -0,0 +1,180 @@ +// +// XmlToolbar.m +// XmlToolbar +// +// Created by R. Tyler Ballance on 10/22/06. +// Copyright 2006 bleep. LLC. All rights reserved. +// + +#import "XmlToolbar.h" + +@implementation XmlToolbar + + +#pragma "General Methods" +- (id)initializeForWindow:(NSWindow *)theWindow withXml:(NSString *)pathToXmlFile +{ + self = [super init]; + + if (self != nil) + { + NSError *error = nil; + NSXMLDocument *xmlDocument = [[NSXMLDocument alloc] initWithContentsOfURL:[NSURL fileURLWithPath:pathToXmlFile] + options:NSXMLDocumentTidyXML error:&error]; + // XXX: Define a DTD at some point to validate against + //if (!([xmlDocument validateAndReturnError:&error])) + // NSLog(@"Failed to validate Xml with error: %@", error); + + toolbarItems = [[NSMutableDictionary alloc] init]; + toolbarOrderedIdentifiers = [[NSMutableArray alloc] init]; + toolbarItems = [self processToolbarTree:xmlDocument]; + + toolbar = [[NSToolbar alloc] initWithIdentifier:[self processToolbarIdentifier:xmlDocument]]; + window = theWindow; + + [self setToolbarDelegate:self]; + [self processToolbarSettings:xmlDocument]; + + [window setToolbar:toolbar]; + [window makeKeyAndOrderFront:nil]; + } + + return self; +} +#pragma mark - + +#pragma mark "Internal Methods" +// XXX: This whole function sucks/is hackish. +- (void)processToolbarSettings:(NSXMLDocument *)xmlDocument +{ + NSError *error = nil; + NSArray *nodes = [[xmlDocument rootElement] nodesForXPath:@"//autosavesconfiguration" error:&error]; + + if ([nodes count] > 0) + [toolbar setAutosavesConfiguration:TRUE]; + + nodes = [[xmlDocument rootElement] nodesForXPath:@"//allowsusercustomization" error:&error]; + + if ([nodes count] > 0) + [toolbar setAllowsUserCustomization:TRUE]; + + nodes = [[xmlDocument rootElement] nodesForXPath:@"//showsbaselineseparator" error:&error]; + + if ([nodes count] > 0) + [toolbar setShowsBaselineSeparator:TRUE]; + + // Process + nodes = [[xmlDocument rootElement] nodesForXPath:@"//sizemode" error:&error]; + if ([nodes count] > 0) + { + NSString *mode = [[nodes objectAtIndex:0] stringValue]; + + /* + NSToolbarSizeModeDefault, + NSToolbarSizeModeRegular, + NSToolbarSizeModeSmall + */ + + if (![mode compare:@"NSToolbarSizeModeRegular"]) + [toolbar setSizeMode:NSToolbarSizeModeRegular]; + else if (![mode compare:@"NSToolbarSizeModeSmall"]) + [toolbar setSizeMode:NSToolbarSizeModeSmall]; + } + + // Process + nodes = [[xmlDocument rootElement] nodesForXPath:@"//displaymode" error:&error]; + if ([nodes count] > 0) + { + NSString *mode = [[nodes objectAtIndex:0] stringValue]; + + /* + NSToolbarDisplayModeDefault, + NSToolbarDisplayModeIconAndLabel, + NSToolbarDisplayModeIconOnly, + NSToolbarDisplayModeLabelOnly + */ + + if (![mode compare:@"NSToolbarDisplayModeIconAndLabel"]) + [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel]; + else if (![mode compare:@"NSToolbarDisplayModeIconOnly"]) + [toolbar setDisplayMode:NSToolbarDisplayModeIconOnly]; + else if (![mode compare:@"NSToolbarDisplayModeLabelOnly"]) + [toolbar setDisplayMode:NSToolbarDisplayModeLabelOnly]; + } +} + +- (NSString *)processToolbarIdentifier:(NSXMLDocument *)xmlDocument +{ + NSError *error = nil; + NSArray *identifierNodes = [[xmlDocument rootElement] nodesForXPath:@"//identifier" error:&error]; + return [[identifierNodes objectAtIndex:0] stringValue]; +} + +- (NSMutableDictionary *)processToolbarTree:(NSXMLDocument *)xmlDocument +{ + NSMutableDictionary *items = [[NSMutableDictionary alloc] init]; + NSError *error = nil; + NSArray *nodes = [[xmlDocument rootElement] nodesForXPath:@"//toolbaritem" error:&error]; + + for (int i = 0; i < [nodes count]; ++i) + { + NSXMLElement *element = [nodes objectAtIndex:i]; + NSString *identifierAndLabel = [[[element elementsForName:@"label"] objectAtIndex:0] stringValue]; + XmlToolbarItem *item = [[XmlToolbarItem alloc] initWithItemIdentifier:identifierAndLabel]; + + [item setLabel:identifierAndLabel]; + [item setPaletteLabel:[[[element elementsForName:@"palettelabel"] objectAtIndex:0] stringValue]]; + [item setToolTip:[[[element elementsForName:@"tooltip"] objectAtIndex:0] stringValue]]; + [item setImage:[NSImage imageNamed:[[[element elementsForName:@"image"] objectAtIndex:0] stringValue]]]; + [item setNotificationName:[NSString stringWithFormat:@"%@", + [[[element elementsForName:@"notification"] objectAtIndex:0] stringValue]]]; + [item setTarget:self]; + [item setAction:@selector(toolbarItemClicked:)]; + + // Add to dictionary + [toolbarOrderedIdentifiers addObject:[item itemIdentifier]]; + [items setObject:item forKey:identifierAndLabel]; + } + + return items; +} +#pragma mark - + +#pragma mark "NSToolbar Related Methods" +- (void)toolbarItemClicked:(XmlToolbarItem *)item +{ + NSLog(@"Firing off \"%@\" notification", [item notificationName]); + [[NSNotificationCenter defaultCenter] postNotificationName:[item notificationName] object:item]; +} + +- (XmlToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier + willBeInsertedIntoToolbar:(BOOL)flag +{ + return [toolbarItems objectForKey:itemIdentifier]; +} + +- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar +{ + return toolbarOrderedIdentifiers; +} + +- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar +{ + return toolbarOrderedIdentifiers; +} + +- (int)count +{ + return [toolbarItems count]; +} + +- (void)setToolbarDelegate:(id)delegate { [toolbar setDelegate:delegate]; } +- (void)setToolbarDisplayMode:(NSToolbarDisplayMode)displayMode { [toolbar setDisplayMode:displayMode]; } +- (void)setToolbarSizeMode:(NSToolbarSizeMode)sizeMode { [toolbar setSizeMode:sizeMode]; } +- (void)setToolbarAllowsUserCustomization:(BOOL)allowsCustomization { [toolbar setAllowsUserCustomization:allowsCustomization]; } +- (void)setToolbarAutosavesConfiguration:(BOOL)flag { [toolbar setAutosavesConfiguration:flag]; } +- (void)setToolbarShowsBaselineSeparator:(BOOL)flag { [toolbar setShowsBaselineSeparator:flag]; } +- (void)setToolbarVisible:(BOOL)shown { [toolbar setVisible:shown]; } +#pragma mark - + +@end diff --git a/source/XmlToolbarItem.h b/source/XmlToolbarItem.h new file mode 100644 index 0000000..459b84a --- /dev/null +++ b/source/XmlToolbarItem.h @@ -0,0 +1,19 @@ +// +// XmlToolbarItem.h +// XmlToolbar +// +// Created by R. Tyler Ballance on 10/22/06. +// Copyright 2006 bleep. LLC. All rights reserved. +// + +#import + + +@interface XmlToolbarItem : NSToolbarItem { + NSString *notificationName; +} + +- (void)setNotificationName:(NSString *)theNotification; +- (NSString *)notificationName; + +@end diff --git a/source/XmlToolbarItem.m b/source/XmlToolbarItem.m new file mode 100644 index 0000000..c99ca90 --- /dev/null +++ b/source/XmlToolbarItem.m @@ -0,0 +1,24 @@ +// +// XmlToolbarItem.m +// XmlToolbar +// +// Created by R. Tyler Ballance on 10/22/06. +// Copyright 2006 bleep. LLC. All rights reserved. +// + +#import "XmlToolbarItem.h" + + +@implementation XmlToolbarItem + +- (void)setNotificationName:(NSString *)theNotification +{ + notificationName = [theNotification copy]; +} + +- (NSString *)notificationName +{ + return notificationName; +} + +@end diff --git a/source/main.m b/source/main.m new file mode 100644 index 0000000..5a012d8 --- /dev/null +++ b/source/main.m @@ -0,0 +1,14 @@ +// +// main.m +// XmlToolbar +// +// Created by R. Tyler Ballance on 10/22/06. +// Copyright bleep. LLC 2006. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) +{ + return NSApplicationMain(argc, (const char **) argv); +}