Adding a Printers.plist file so that the printers aren't hard-coded into PrintDrop...
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 27 Feb 2008 19:59:39 +0000 (14:59 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 27 Feb 2008 19:59:39 +0000 (14:59 -0500)
* 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 [new file with mode: 0644]
PrintDrop.xcodeproj/project.pbxproj
Source/AppController.h
Source/AppController.m

diff --git a/English.lproj/Printers.plist b/English.lproj/Printers.plist
new file mode 100644 (file)
index 0000000..0dd9745
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>printers</key>
+       <array>
+               <dict>
+                       <key>displayName</key>
+                       <string>Central Printing — Double-Sided, Stapled (5¢)</string>
+                       <key>unixName</key>
+                       <string>publp</string>
+               </dict>
+               <dict>
+                       <key>displayName</key>
+                       <string>Central Printing — Single-Sided, Stapled (10¢)</string>
+                       <key>unixName</key>
+                       <string>pubps</string>
+               </dict>
+               <dict>
+                       <key>displayName</key>
+                       <string>Central Printing — Double-Sided, Not Stapled (5¢)</string>
+                       <key>unixName</key>
+                       <string>publpns</string>
+               </dict>
+               <dict>
+                       <key>displayName</key>
+                       <string>Central Printing — Single-Sided, Not Stapled (10¢)</string>
+                       <key>unixName</key>
+                       <string>pubpsns</string>
+               </dict>
+       </array>
+</dict>
+</plist>
index 9cdfe55e09c959b7cb9ca18bb0e36e3fd44ce49d..179737845c5bccb23660f3b7031336c0a72f2f5d 100644 (file)
@@ -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 = "<group>"; };
                1EE1E46F0D748AE4002999AD /* transport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = transport.c; sourceTree = "<group>"; };
                1EE1E4700D748AE4002999AD /* userauth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = userauth.c; sourceTree = "<group>"; };
+               1EE653520D75F5AC00D7A7FA /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = English; path = English.lproj/Printers.plist; sourceTree = "<group>"; };
                29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
                29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = "<group>"; };
                29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
                29B97317FDCFA39411CA2CEA /* Resources */ = {
                        isa = PBXGroup;
                        children = (
+                               1EE653510D75F5AC00D7A7FA /* Printers.plist */,
                                1EE1E3E30D7482E7002999AD /* gradient.png */,
                                8D1107310486CEB800E47090 /* Info.plist */,
                                089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
                                8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */,
                                8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
                                1EE1E3E50D7482E7002999AD /* gradient.png in Resources */,
+                               1EE653530D75F5AC00D7A7FA /* Printers.plist in Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        name = gradient.png;
                        sourceTree = "<group>";
                };
+               1EE653510D75F5AC00D7A7FA /* Printers.plist */ = {
+                       isa = PBXVariantGroup;
+                       children = (
+                               1EE653520D75F5AC00D7A7FA /* English */,
+                       );
+                       name = Printers.plist;
+                       sourceTree = "<group>";
+               };
                29B97318FDCFA39411CA2CEA /* MainMenu.nib */ = {
                        isa = PBXVariantGroup;
                        children = (
index 2e3180edccf823cb1f87e42b238fd86f455caad3..e45903f5c98a28653d642f3c38233c36420a6388 100644 (file)
@@ -29,7 +29,7 @@
        IBOutlet DraggableImageView *dragRegion;
        
        IBOutlet NSArrayController *printersController;
-       NSMutableArray *printers;
+       NSArray *printers;
 }
 
 - (IBAction)print:(id)sender;
index 5d557e8126066fa69c90613a18c06852557c43e8..2e4dcb35c3ae9a4384221a7b63ddf4e9def86855 100644 (file)
 {
        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;
 }