mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 17:21:00 +00:00
Change references to ivar info to _info.
[initPrintInfoDefaults] now works if there is no PrinterAdmin resource. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7830 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
72e4558053
commit
5e18b105d3
1 changed files with 53 additions and 40 deletions
|
@ -26,7 +26,6 @@
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gnustep/gui/config.h"
|
|
||||||
#include <Foundation/NSBundle.h>
|
#include <Foundation/NSBundle.h>
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
@ -115,7 +114,7 @@ NSDictionary *paperSizes = nil;
|
||||||
// [NSPrintInfo_PAPERFILE cString]];
|
// [NSPrintInfo_PAPERFILE cString]];
|
||||||
// // NOT REACHED
|
// // NOT REACHED
|
||||||
// }
|
// }
|
||||||
// paperSizes = [[NSDictionary dictionaryWithContentsOfFile:path] retain];
|
// paperSizes = RETAIN([NSDictionary dictionaryWithContentsOfFile:path]);
|
||||||
// }
|
// }
|
||||||
// size = [paperSizes objectForKey:name];
|
// size = [paperSizes objectForKey:name];
|
||||||
// if (!size)
|
// if (!size)
|
||||||
|
@ -149,87 +148,93 @@ NSDictionary *paperSizes = nil;
|
||||||
- (id)initWithDictionary:(NSDictionary *)aDict
|
- (id)initWithDictionary:(NSDictionary *)aDict
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
info = [[NSMutableDictionary alloc] initWithDictionary:aDict];
|
_info = [[NSMutableDictionary alloc] initWithDictionary:aDict];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) dealloc
|
||||||
|
{
|
||||||
|
RELEASE(_info);
|
||||||
|
[super dealloc];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Managing the Printing Rectangle
|
// Managing the Printing Rectangle
|
||||||
//
|
//
|
||||||
- (float)bottomMargin
|
- (float)bottomMargin
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintBottomMargin] floatValue];
|
return [(NSNumber *)[_info objectForKey:NSPrintBottomMargin] floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)leftMargin
|
- (float)leftMargin
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintLeftMargin] floatValue];
|
return [(NSNumber *)[_info objectForKey:NSPrintLeftMargin] floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPrintingOrientation)orientation
|
- (NSPrintingOrientation)orientation
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintOrientation] intValue];
|
return [(NSNumber *)[_info objectForKey:NSPrintOrientation] intValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)paperName
|
- (NSString *)paperName
|
||||||
{
|
{
|
||||||
return [info objectForKey:NSPrintPaperName];
|
return [_info objectForKey:NSPrintPaperName];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSSize)paperSize
|
- (NSSize)paperSize
|
||||||
{
|
{
|
||||||
return [(NSValue *)[info objectForKey:NSPrintPaperSize] sizeValue];
|
return [(NSValue *)[_info objectForKey:NSPrintPaperSize] sizeValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)rightMargin
|
- (float)rightMargin
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintRightMargin] floatValue];
|
return [(NSNumber *)[_info objectForKey:NSPrintRightMargin] floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setBottomMargin:(float)value
|
- (void)setBottomMargin:(float)value
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithFloat:value]
|
[_info setObject:[NSNumber numberWithFloat:value]
|
||||||
forKey:NSPrintBottomMargin];
|
forKey:NSPrintBottomMargin];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setLeftMargin:(float)value
|
- (void)setLeftMargin:(float)value
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithFloat:value]
|
[_info setObject:[NSNumber numberWithFloat:value]
|
||||||
forKey:NSPrintLeftMargin];
|
forKey:NSPrintLeftMargin];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setOrientation:(NSPrintingOrientation)mode
|
- (void)setOrientation:(NSPrintingOrientation)mode
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithInt:mode]
|
[_info setObject:[NSNumber numberWithInt:mode]
|
||||||
forKey:NSPrintOrientation];
|
forKey:NSPrintOrientation];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPaperName:(NSString *)name
|
- (void)setPaperName:(NSString *)name
|
||||||
{
|
{
|
||||||
[info setObject:name forKey:NSPrintPaperName];
|
[_info setObject:name forKey:NSPrintPaperName];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPaperSize:(NSSize)size
|
- (void)setPaperSize:(NSSize)size
|
||||||
{
|
{
|
||||||
[info setObject:[NSValue valueWithSize:size]
|
[_info setObject:[NSValue valueWithSize:size]
|
||||||
forKey:NSPrintPaperSize];
|
forKey:NSPrintPaperSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRightMargin:(float)value
|
- (void)setRightMargin:(float)value
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithFloat:value]
|
[_info setObject:[NSNumber numberWithFloat:value]
|
||||||
forKey:NSPrintRightMargin];
|
forKey:NSPrintRightMargin];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setTopMargin:(float)value
|
- (void)setTopMargin:(float)value
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithFloat:value]
|
[_info setObject:[NSNumber numberWithFloat:value]
|
||||||
forKey:NSPrintTopMargin];
|
forKey:NSPrintTopMargin];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float)topMargin
|
- (float)topMargin
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintTopMargin] floatValue];
|
return [(NSNumber *)[_info objectForKey:NSPrintTopMargin] floatValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -237,25 +242,25 @@ NSDictionary *paperSizes = nil;
|
||||||
//
|
//
|
||||||
- (NSPrintingPaginationMode)horizontalPagination
|
- (NSPrintingPaginationMode)horizontalPagination
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintHorizontalPagination]
|
return [(NSNumber *)[_info objectForKey:NSPrintHorizontalPagination]
|
||||||
intValue];
|
intValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHorizontalPagination:(NSPrintingPaginationMode)mode
|
- (void)setHorizontalPagination:(NSPrintingPaginationMode)mode
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithInt:mode]
|
[_info setObject:[NSNumber numberWithInt:mode]
|
||||||
forKey:NSPrintHorizontalPagination];
|
forKey:NSPrintHorizontalPagination];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setVerticalPagination:(NSPrintingPaginationMode)mode
|
- (void)setVerticalPagination:(NSPrintingPaginationMode)mode
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithInt:mode]
|
[_info setObject:[NSNumber numberWithInt:mode]
|
||||||
forKey:NSPrintVerticalPagination];
|
forKey:NSPrintVerticalPagination];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPrintingPaginationMode)verticalPagination
|
- (NSPrintingPaginationMode)verticalPagination
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintVerticalPagination] intValue];
|
return [(NSNumber *)[_info objectForKey:NSPrintVerticalPagination] intValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -263,24 +268,24 @@ NSDictionary *paperSizes = nil;
|
||||||
//
|
//
|
||||||
- (BOOL)isHorizontallyCentered
|
- (BOOL)isHorizontallyCentered
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintHorizontallyCentered]
|
return [(NSNumber *)[_info objectForKey:NSPrintHorizontallyCentered]
|
||||||
boolValue];
|
boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)isVerticallyCentered
|
- (BOOL)isVerticallyCentered
|
||||||
{
|
{
|
||||||
return [(NSNumber *)[info objectForKey:NSPrintVerticallyCentered] boolValue];
|
return [(NSNumber *)[_info objectForKey:NSPrintVerticallyCentered] boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setHorizontallyCentered:(BOOL)flag
|
- (void)setHorizontallyCentered:(BOOL)flag
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithBool:flag]
|
[_info setObject:[NSNumber numberWithBool:flag]
|
||||||
forKey:NSPrintHorizontallyCentered];
|
forKey:NSPrintHorizontallyCentered];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setVerticallyCentered:(BOOL)flag
|
- (void)setVerticallyCentered:(BOOL)flag
|
||||||
{
|
{
|
||||||
[info setObject:[NSNumber numberWithBool:flag]
|
[_info setObject:[NSNumber numberWithBool:flag]
|
||||||
forKey:NSPrintVerticallyCentered];
|
forKey:NSPrintVerticallyCentered];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,12 +294,12 @@ NSDictionary *paperSizes = nil;
|
||||||
//
|
//
|
||||||
- (NSPrinter *)printer
|
- (NSPrinter *)printer
|
||||||
{
|
{
|
||||||
return [info objectForKey:NSPrintPrinter];
|
return [_info objectForKey:NSPrintPrinter];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPrinter:(NSPrinter *)aPrinter
|
- (void)setPrinter:(NSPrinter *)aPrinter
|
||||||
{
|
{
|
||||||
[info setObject:aPrinter forKey:NSPrintPrinter];
|
[_info setObject:aPrinter forKey:NSPrintPrinter];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -302,12 +307,12 @@ NSDictionary *paperSizes = nil;
|
||||||
//
|
//
|
||||||
- (NSString *)jobDisposition
|
- (NSString *)jobDisposition
|
||||||
{
|
{
|
||||||
return [info objectForKey:NSPrintJobDisposition];
|
return [_info objectForKey:NSPrintJobDisposition];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setJobDisposition:(NSString *)disposition
|
- (void)setJobDisposition:(NSString *)disposition
|
||||||
{
|
{
|
||||||
[info setObject:disposition forKey:NSPrintJobDisposition];
|
[_info setObject:disposition forKey:NSPrintJobDisposition];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setUpPrintOperationDefaultValues
|
- (void)setUpPrintOperationDefaultValues
|
||||||
|
@ -315,6 +320,7 @@ NSDictionary *paperSizes = nil;
|
||||||
NSEnumerator *keys, *objects;
|
NSEnumerator *keys, *objects;
|
||||||
NSString *key;
|
NSString *key;
|
||||||
id object;
|
id object;
|
||||||
|
|
||||||
if (!printInfoDefaults)
|
if (!printInfoDefaults)
|
||||||
[NSPrintInfo initPrintInfoDefaults];
|
[NSPrintInfo initPrintInfoDefaults];
|
||||||
keys = [printInfoDefaults keyEnumerator];
|
keys = [printInfoDefaults keyEnumerator];
|
||||||
|
@ -322,8 +328,8 @@ NSDictionary *paperSizes = nil;
|
||||||
while ((key = [keys nextObject]))
|
while ((key = [keys nextObject]))
|
||||||
{
|
{
|
||||||
object = [objects nextObject];
|
object = [objects nextObject];
|
||||||
if (![info objectForKey:key])
|
if (![_info objectForKey:key])
|
||||||
[info setObject:object forKey:key];
|
[_info setObject:object forKey:key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +338,7 @@ NSDictionary *paperSizes = nil;
|
||||||
//
|
//
|
||||||
- (NSMutableDictionary *)dictionary
|
- (NSMutableDictionary *)dictionary
|
||||||
{
|
{
|
||||||
return info;
|
return _info;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -340,12 +346,12 @@ NSDictionary *paperSizes = nil;
|
||||||
//
|
//
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[aCoder encodePropertyList: info];
|
[aCoder encodePropertyList: _info];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
info = [[aDecoder decodePropertyList] retain];
|
_info = RETAIN([aDecoder decodePropertyList]);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,15 +365,22 @@ NSDictionary *paperSizes = nil;
|
||||||
adminBundle = [NSBundle bundleWithPath:NSPrinterAdmin_PATH];
|
adminBundle = [NSBundle bundleWithPath:NSPrinterAdmin_PATH];
|
||||||
path = [adminBundle pathForResource:NSPrintInfo_DEFAULTSTABLE ofType:nil];
|
path = [adminBundle pathForResource:NSPrintInfo_DEFAULTSTABLE ofType:nil];
|
||||||
// If not found
|
// If not found
|
||||||
if (path == nil || [path length] == 0)
|
if (path != nil && [path length] != 0)
|
||||||
{
|
{
|
||||||
[NSException raise:NSGenericException
|
printInfoDefaults = RETAIN([NSMutableDictionary dictionaryWithContentsOfFile:path]);
|
||||||
format:@"Could not find printing defaults table, file %s",
|
|
||||||
[NSPrintInfo_DEFAULTSTABLE cString]];
|
|
||||||
// NOT REACHED
|
// NOT REACHED
|
||||||
}
|
}
|
||||||
printInfoDefaults = [[NSMutableDictionary dictionaryWithContentsOfFile:path]
|
if (printInfoDefaults == nil)
|
||||||
retain];
|
{
|
||||||
|
NSLog(@"Could not find printing defaults table, file %s",
|
||||||
|
[NSPrintInfo_DEFAULTSTABLE cString]);
|
||||||
|
// FIXME: As a replacement we add a very simple definition
|
||||||
|
printInfoDefaults = RETAIN(([NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@"Unknown", NSPrintPrinter,
|
||||||
|
@"A4", NSPrintPaperName,
|
||||||
|
NULL]));
|
||||||
|
}
|
||||||
|
|
||||||
// The loaded dictionary contains the name of the printer for NSPrintPrinter
|
// The loaded dictionary contains the name of the printer for NSPrintPrinter
|
||||||
// Load the real NSPrinter object...
|
// Load the real NSPrinter object...
|
||||||
[printInfoDefaults
|
[printInfoDefaults
|
||||||
|
|
Loading…
Reference in a new issue