2005-04-23 18:43:36 +00:00
|
|
|
#/* GormPalettesPref.m
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Author: Gregory John Casamento <greg_casamento@yahoo.com>
|
|
|
|
* Date: 2004
|
|
|
|
*
|
|
|
|
* This file is part of GNUstep.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-11-05 23:44:36 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-04-23 18:43:36 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-05-26 03:37:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
2005-04-23 18:43:36 +00:00
|
|
|
*/
|
|
|
|
|
2019-11-03 01:57:39 +00:00
|
|
|
#include <Foundation/Foundation.h>
|
|
|
|
#include <AppKit/AppKit.h>
|
|
|
|
|
|
|
|
#include <GormCore/GormCore.h>
|
2005-04-23 18:43:36 +00:00
|
|
|
|
2005-03-31 03:01:36 +00:00
|
|
|
#include "GormPalettesPref.h"
|
2004-10-24 00:08:42 +00:00
|
|
|
|
|
|
|
@class NSTableView;
|
2004-07-12 04:16:09 +00:00
|
|
|
|
|
|
|
// data source...
|
|
|
|
@interface PaletteDataSource : NSObject
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation PaletteDataSource
|
2013-01-30 12:43:27 +00:00
|
|
|
- (NSInteger) numberOfRowsInTableView: (NSTableView *)tv
|
2004-07-12 04:16:09 +00:00
|
|
|
{
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSArray *list = [defaults objectForKey: @"UserPalettes"];
|
|
|
|
return [list count];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) tableView: (NSTableView *)tv
|
|
|
|
objectValueForTableColumn: (NSTableColumn *)tc
|
2013-01-30 12:43:27 +00:00
|
|
|
row: (NSInteger)rowIndex
|
2004-07-12 04:16:09 +00:00
|
|
|
{
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSArray *list = [defaults objectForKey: @"UserPalettes"];
|
2004-07-14 03:10:44 +00:00
|
|
|
id value = nil;
|
2004-07-12 04:16:09 +00:00
|
|
|
if([list count] > 0)
|
|
|
|
{
|
|
|
|
value = [[list objectAtIndex: rowIndex] lastPathComponent];
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation GormPalettesPref
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
_view = nil;
|
|
|
|
|
|
|
|
self = [super init];
|
|
|
|
|
|
|
|
if ( ! [NSBundle loadNibNamed:@"GormPrefPalettes" owner:self] )
|
|
|
|
{
|
|
|
|
NSLog(@"Can not load bundle GormPrefPalettes");
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2005-04-23 18:43:36 +00:00
|
|
|
_view = [[(NSWindow *)window contentView] retain];
|
2004-07-12 04:16:09 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
TEST_RELEASE(_view);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(NSView *) view
|
|
|
|
{
|
|
|
|
return _view;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) addAction: (id)sender
|
|
|
|
{
|
2023-06-17 16:14:48 +00:00
|
|
|
[[(id<GormAppDelegate>)[NSApp delegate] palettesManager] openPalette: self];
|
2004-07-12 04:16:09 +00:00
|
|
|
[table reloadData];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) removeAction: (id)sender
|
|
|
|
{
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
NSMutableArray *list = [defaults objectForKey: @"UserPalettes"];
|
|
|
|
int row = [table selectedRow];
|
|
|
|
|
|
|
|
if(row >= 0)
|
|
|
|
{
|
|
|
|
NSString *stringValue = [list objectAtIndex: row];
|
|
|
|
|
|
|
|
if(stringValue != nil)
|
|
|
|
{
|
|
|
|
[list removeObject: stringValue];
|
|
|
|
[defaults setObject: list forKey: @"UserPalettes"];
|
|
|
|
[table reloadData];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) tableView: (NSTableView *)tableView
|
|
|
|
shouldEditTableColumn: (NSTableColumn *)aTableColumn
|
2013-01-30 12:43:27 +00:00
|
|
|
row: (NSInteger)rowIndex
|
2004-07-12 04:16:09 +00:00
|
|
|
{
|
|
|
|
BOOL result = NO;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) tableView: (NSTableView *)tv
|
2013-01-30 12:43:27 +00:00
|
|
|
shouldSelectRow: (NSInteger)rowIndex
|
2004-07-12 04:16:09 +00:00
|
|
|
{
|
|
|
|
BOOL result = YES;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|