From 757fa3d68db901ceba2d597c96631b2b01251fc2 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 27 Feb 2008 14:59:39 -0500 Subject: [PATCH] Adding a Printers.plist file so that the printers aren't hard-coded into PrintDrop but rather are in an XML file * English.lproj/Printers.plist: New file * PrintDrop.xcodeproj: Project updates for the plist file * Source/AppController.h: Changing printers to be an NSArray instead of NSMutableArray * Source/AppController.m: ([AppController init]): Simply load the plist instead of creating a NSMutableArray of NSDictionary's --- English.lproj/Printers.plist | 33 +++++++++++++++++++++++++++++ PrintDrop.xcodeproj/project.pbxproj | 14 +++++++++++- Source/AppController.h | 2 +- Source/AppController.m | 15 +------------ 4 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 English.lproj/Printers.plist diff --git a/English.lproj/Printers.plist b/English.lproj/Printers.plist new file mode 100644 index 0000000..0dd9745 --- /dev/null +++ b/English.lproj/Printers.plist @@ -0,0 +1,33 @@ + + + + + printers + + + displayName + Central Printing — Double-Sided, Stapled (5¢) + unixName + publp + + + displayName + Central Printing — Single-Sided, Stapled (10¢) + unixName + pubps + + + displayName + Central Printing — Double-Sided, Not Stapled (5¢) + unixName + publpns + + + displayName + Central Printing — Single-Sided, Not Stapled (10¢) + unixName + pubpsns + + + + diff --git a/PrintDrop.xcodeproj/project.pbxproj b/PrintDrop.xcodeproj/project.pbxproj index 9cdfe55..1797378 100644 --- a/PrintDrop.xcodeproj/project.pbxproj +++ b/PrintDrop.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ 1EE1E4870D748AE4002999AD /* transport.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE1E46F0D748AE4002999AD /* transport.c */; }; 1EE1E4880D748AE4002999AD /* userauth.c in Sources */ = {isa = PBXBuildFile; fileRef = 1EE1E4700D748AE4002999AD /* userauth.c */; }; 1EE1E48C0D748B19002999AD /* liblibssh2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EE1E4500D748AC9002999AD /* liblibssh2.a */; }; + 1EE653530D75F5AC00D7A7FA /* Printers.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1EE653510D75F5AC00D7A7FA /* Printers.plist */; }; 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; @@ -46,7 +47,7 @@ isa = PBXContainerItemProxy; containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */; proxyType = 1; - remoteGlobalIDString = 1EE1E44F0D748AC9002999AD /* libssh2 */; + remoteGlobalIDString = 1EE1E44F0D748AC9002999AD; remoteInfo = libssh2; }; /* End PBXContainerItemProxy section */ @@ -86,6 +87,7 @@ 1EE1E46E0D748AE4002999AD /* sftp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sftp.c; sourceTree = ""; }; 1EE1E46F0D748AE4002999AD /* transport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = transport.c; sourceTree = ""; }; 1EE1E4700D748AE4002999AD /* userauth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = userauth.c; sourceTree = ""; }; + 1EE653520D75F5AC00D7A7FA /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = English; path = English.lproj/Printers.plist; sourceTree = ""; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; 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 = ""; }; @@ -227,6 +229,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + 1EE653510D75F5AC00D7A7FA /* Printers.plist */, 1EE1E3E30D7482E7002999AD /* gradient.png */, 8D1107310486CEB800E47090 /* Info.plist */, 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, @@ -327,6 +330,7 @@ 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */, 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, 1EE1E3E50D7482E7002999AD /* gradient.png in Resources */, + 1EE653530D75F5AC00D7A7FA /* Printers.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -410,6 +414,14 @@ name = gradient.png; sourceTree = ""; }; + 1EE653510D75F5AC00D7A7FA /* Printers.plist */ = { + isa = PBXVariantGroup; + children = ( + 1EE653520D75F5AC00D7A7FA /* English */, + ); + name = Printers.plist; + sourceTree = ""; + }; 29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = { isa = PBXVariantGroup; children = ( diff --git a/Source/AppController.h b/Source/AppController.h index 2e3180e..e45903f 100644 --- a/Source/AppController.h +++ b/Source/AppController.h @@ -29,7 +29,7 @@ IBOutlet DraggableImageView *dragRegion; IBOutlet NSArrayController *printersController; - NSMutableArray *printers; + NSArray *printers; } - (IBAction)print:(id)sender; diff --git a/Source/AppController.m b/Source/AppController.m index 5d557e8..2e4dcb3 100644 --- a/Source/AppController.m +++ b/Source/AppController.m @@ -39,20 +39,7 @@ { if (self = [super init]) { - printers = [NSMutableArray array]; - - NSArray *values = [NSArray arrayWithObjects:@"Double-Sided, Stapled $0.05", @"publp", nil]; - NSArray *keys = [NSArray arrayWithObjects:@"displayName", @"unixName", nil]; - [printers addObject:[NSDictionary dictionaryWithObjects:values forKeys:keys]]; - - values = [NSArray arrayWithObjects:@"Single-Sided, Stapled $0.10", @"pubps", nil]; - [printers addObject:[NSDictionary dictionaryWithObjects:values forKeys:keys]]; - - values = [NSArray arrayWithObjects:@"Double-Sided, Not Stapled $0.05", @"publpns", nil]; - [printers addObject:[NSDictionary dictionaryWithObjects:values forKeys:keys]]; - - values = [NSArray arrayWithObjects:@"Single-Sided, Not Stapled $0.10", @"pubpsns", nil]; - [printers addObject:[NSDictionary dictionaryWithObjects:values forKeys:keys]]; + printers = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Printers" ofType:@"plist"]]; } return self; } -- 2.22.5