/* GSWIN32PrintInfo.m Stores information used in printing Copyright (C) 1996,1997,2004 Free Software Foundation, Inc. Author: Simon Frankau Date: July 1997 Modified for Printing Backend Support Author: Chad Hardin Date: June 2004 This file is part of the GNUstep GUI Library. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; see the file COPYING.LIB. If not, see or write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #import #import #import #import #import #import "AppKit/NSPrinter.h" #import "GSWIN32PrintInfo.h" @implementation GSWIN32PrintInfo // // Class methods // + (void)initialize { if (self == [GSWIN32PrintInfo class]) { // Initial version [self setVersion:1]; } } + (id) allocWithZone: (NSZone*)zone { return NSAllocateObject(self, 0, zone); } +(NSPrinter*) defaultPrinter { NSUserDefaults *defaults; NSString *name; NSDebugMLLog(@"GSPrinting", @"defaultPrinter"); defaults = [NSUserDefaults standardUserDefaults]; name = [defaults objectForKey: @"GSWIN32DefaultPrinter"]; if (name == nil) { name = [[NSPrinter printerNames] objectAtIndex: 0]; } else { if ([NSPrinter printerWithName: name] == nil) { name = [[NSPrinter printerNames] objectAtIndex: 0]; } } return [NSPrinter printerWithName: name]; } + (void)setDefaultPrinter:(NSPrinter *)printer { NSUserDefaults *defaults; NSMutableDictionary *globalDomain; NSDebugMLLog(@"GSPrinting", @"setDefaultPrinter"); defaults = [NSUserDefaults standardUserDefaults]; globalDomain = (NSMutableDictionary*)[defaults persistentDomainForName: NSGlobalDomain]; if (globalDomain) { globalDomain = [globalDomain mutableCopy]; [globalDomain setObject: [printer name] forKey: @"GSWIN32DefaultPrinter"]; [defaults setPersistentDomain: globalDomain forName: NSGlobalDomain]; RELEASE(globalDomain); } else { NSDebugMLLog(@"GSPrinting", @"(GSWIN32) Could not save default printer named %@ to NSUserDefaults GSWIN32DefaultPrinter in NSGlobalDomain.", [printer name]); } } @end