mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 12:01:16 +00:00
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@16705 72102866-910b-0410-8b05-ffd578937521
101 lines
1.9 KiB
Objective-C
101 lines
1.9 KiB
Objective-C
#include "GormHeadersPref.h"
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
|
|
|
#include <AppKit/NSButton.h>
|
|
#include <AppKit/NSBrowser.h>
|
|
#include <AppKit/NSWindow.h>
|
|
#include <AppKit/NSNibLoading.h>
|
|
#include <AppKit/NSOpenPanel.h>
|
|
|
|
@implementation GormHeadersPref
|
|
|
|
|
|
- (id) init
|
|
{
|
|
_view = nil;
|
|
|
|
self = [super init];
|
|
|
|
if ( ! [NSBundle loadNibNamed:@"GormPrefHeaders" owner:self] )
|
|
{
|
|
NSLog(@"Can not load bundle GormPrefHeaders");
|
|
return nil;
|
|
}
|
|
|
|
_view = [[window contentView] retain];
|
|
return self;
|
|
}
|
|
|
|
- (void) dealloc
|
|
{
|
|
TEST_RELEASE(_view);
|
|
[super dealloc];
|
|
}
|
|
|
|
|
|
-(NSView *) view
|
|
{
|
|
return _view;
|
|
}
|
|
|
|
|
|
- (void) addAction: (id)sender
|
|
{
|
|
NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", nil];
|
|
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
|
|
int result;
|
|
|
|
[openPanel setAllowsMultipleSelection: YES];
|
|
[openPanel setCanChooseFiles: YES];
|
|
[openPanel setCanChooseDirectories: NO];
|
|
result = [openPanel runModalForDirectory: nil
|
|
file: nil
|
|
types: fileTypes];
|
|
if (result == NSOKButton)
|
|
{
|
|
[headers addObjectsFromArray: [openPanel filenames]];
|
|
[browser reloadColumn: 0];
|
|
}
|
|
}
|
|
|
|
|
|
- (void) removeAction: (id)sender
|
|
{
|
|
NSCell *cell = [browser selectedCellInColumn: 0];
|
|
|
|
if(cell != nil)
|
|
{
|
|
NSString *stringValue = [NSString stringWithString: [cell stringValue]];
|
|
[headers removeObject: stringValue];
|
|
[browser reloadColumn: 0];
|
|
NSLog(@"Header removed");
|
|
}
|
|
}
|
|
|
|
|
|
- (void) preloadAction: (id)sender
|
|
{
|
|
if (sender != preloadButton)
|
|
return;
|
|
|
|
{
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
[defaults setInteger:[preloadButton state] forKey:@"BACKUPFILE"];
|
|
[defaults synchronize];
|
|
if ( [preloadButton state] == NSOnState )
|
|
{
|
|
[addButton setEnabled:YES];
|
|
[removeButton setEnabled: YES];
|
|
}
|
|
else
|
|
{
|
|
[addButton setEnabled:NO];
|
|
[removeButton setEnabled:NO];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
@end
|